We have moved over to full pagination now along with our redesign for our newspaper...and have also moved completely over to InDesign. When we import our classified listing into InDesign and apply all the styles...everything works perfectly except for ONE thing which is causing us a lot of extra time. For the majority of the listings, we need to make all words before the hyphen BOLD. This is pretty hard to explain, so let me give an example...say hypothetically speaking, a single classified ad runs as such:
Peachtree City Single Family Home - 3 bedrooms, 2 bathrooms, huge basement. Only $123,000! Call Joey Jones at 123-456-7890.
What we need to do is make all the words BEFORE the hyphen BOLD ....and try to incorporate this into a style somehow. At present we are doing this manually and it is taking a lot of time. The problem is also that there is never a set number of words before the hyphen. I know very little about scripting...is there ANY way I could set up a script to do this for us? Is a script the direction to go in?
(The normal portion of the classifieds is done in Univers condensed...the bold portions will be done in Univers Bold Condensed.)
(Keeping my fingers tightly crossed that there is some solution.....however I have a sinking feeling that there isn't......)
That's a snap of the fingers with ID CS's Nested Styles feature.
With ID 2, you have to use a script. Are you Mac or PC?
Dave
Chris
Initially, I had indeed thought it WOULD be resolved with ID 3, and if it is going to be, then we can wait because we plan on getting ID 3 asap anyway:) However, I had ALSO thought before that the number of words before the hyphen would always be the same in the listings (which would be easy to work with using ID 3's nested styles) but it is not. Will ID's nested styles still solve this problem even tho' there is a different number of words before the hyphen in each listing?
Let me answer your questions...
I am using a Mac.
Here is our workflow summed up:
We use a software program called CAMS to do all the classifieds. When we get the text file from the classifieds department with all the listings, it comes to us as a word doc file with the words before the hyphen in bold. We place it into ID, select all the text and apply the paragraph style to the entire listing (which changes everything to the correct font..Univers Condensed and adds in all the lines between the listings as well. Of course, applying this style removes the "bold" of those first few words.) We then select the headers (e.g. For Sale, Help Wanted, etc.) individually and apply the appropriate para style.
Each listing will always have that lead and will not ever consist of just a phone number.
It is an "em dash" and not just a regular hyphen.
Is there a way to select a large chunk of text and apply the script instead of applying it to the whole text block? (Or I guess the workaround would be for us to apply the script before applying the para style to the headers....or of course the script will not affect the headers at all since there are no hypens/em dashes in the headers.)
If you run it with a text selected, it will operate on the story that contains the text. If you run it with nothing selected, it will operate on the whole document:
property runinParaStyles : {"First", "Second"}
tell application "InDesign 2.0.2"
try
set myRange to object reference of parent story of selection
on error
set myRange to document 1
end try
set find preferences to nothing
set change preferences to nothing
repeat with myStyle in runinParaStyles
set myParaStyle to (paragraph style 1 of document 1 whose name is myStyle)
set myEms to search myRange for "^_" with find attributes {applied paragraph style:myParaStyle}
repeat with myEm in myEms
set myStory to object reference of parent story of myEm
set myEnd to (index of character 1 of myEm) - 1
set myStart to index of paragraph 1 of myEm
set applied character style of characters myStart through myEnd of myStory to character style "Bold" of document 1
end repeat
end repeat
end tell
Like I said, this script will be obsolete with the release of ID CS, which will allow you to call for the run-in in those paragrah styles using a nested style.
Dave
1. If there's more than one em-dash in a paragraph, the script will bold up to the last em-dash, which is probably not what you want.
If you need to deal with this, set up a variable call oldStart and add immediately before the repeat with myEm statement:
set oldStart to 0
and then add replace the set applied character style statement with:
if myStart is not equal to oldStart then
set oldStart to myStart
set applied character style of characters myStart through myEnd of myStory to character style "Bold" of document 1
end if
With that change, the script will operate only up to the first em-dash in any paragraph.
2. If you have a paragraph in one of the identified styles that starts with an em-dash, then the return at the end of the previous paragraph is what actually would be boldened.
3. If the first paragraph in a story is in one of the identified styles AND it starts with an em-dash, you'll get an error.
4. If any of the listed paragraph style names doesn't exist (be careful about case; paragraph style names are case sensitive), you'll get an error.
5. If a paragraph exists in one of the styles but doesn't have an em-dash, the paragraph will be ignored, no bolding will be applied to it.
Dave
tell application "InDesign 2.0.2"
if (count documents) > 0 then
set myDocument to active document
set myCharStyle to character style "Bold" of myDocument
set myHyphen to "-"
tell myDocument
try
set myPink to swatch "C=0 M=100 Y=0 K=0"
on error
set myPink to make color with properties {color model:process, color space:cmyk, color value:{0, 100, 0, 0}, name:"C=0 M=100 Y=0 K=0"}
end try
try
set myStory to object reference of parent story of selection
on error
activate
display dialog "Please select some text in the story you want to process."
end try
tell myStory
repeat with myCounter from 1 to (count paragraphs)
try
set myBoldThis to object reference of text from character 1 to (character 1 whose contents = myHyphen) of paragraph myCounter
set applied character style of myBoldThis to myCharStyle
on error
set fill color of text of paragraph myCounter to myPink
end try
end repeat
end tell
end tell
else
activate
display dialog "Please open a document and try again."
end if
end tell
This script assumes:
1) you have some text selected in the story you want to convert;
2) you have a character style named "Bold" (basically your regular style w/ bold applied, this is much slicker than simply applying bold.)
3) your hyphen is a regular hyphen. If you want to change that, change the character between the quotes in the 4th line to an en-dash or whatever. (in fact, you can even change it to a character like "c" & get some really cool effects. [grin] )
If the script has a problem with a paragraph, (for instance, if it can't find a hyphen) it changes the color of the text to magenta, then moves on. If this bugs you I can tell you how to disable it, but I find it helps with proofing.
HTH.
As I understand it, the number of words before the hyphen wouldn't matter with nested styles in InDesign CS. The hyphen would be the delimeter that marked the spot where the bold styling would change.
The InDesign overview PDF at adobe.com details some of this:
"You can choose to apply the nested style up to or through sentences, words, characters, digits, letters, or a wide variety of special characters, such as an em space, a tab mark, or a forced linebreak."
Carl
Thank you ALL SO MUCH FOR YOUR HELP!! Gosh, I really really appreciate it:))
I am going to try these out tonight and will come back to let you know how it worked. It looks like our problem may indeed be solved now thanks to your help!
Jay, I tried out yours but it is not taking:(( Is it because there is no place in the script where I can reference my specific paragraph styles? As suggested I changed the regular hyphen in the 4th line of the script to an em dash (which is what we use in the classifieds just after the words we need bolded) but after applying the script, everything just turns to pink....as if it cannot find the hyphens (em dashes).
(P.S. I am a COMPLETE NEWBIE at scripting so pls. bear with me if my questions sound a bit "dumb" :)
Dave
Glad Dave's script works. I can help you de-bug mine if you'd like, but if you've got a working model, why bother, right ? [grin]
Jay
I've been writing whose clauses all morning. Invaluable when working on the page items in a group, where the page items each have a label.
Dave
I saw a demo recently of InDy CS' nested styles: very, very awsome. I can hardly wait.
jay
It's scriptable, too.<g>
Thanks,
Ole
Dave
The really neat thing about nested styles, though, is that it obsoletes
the need to script so many tedious things ...
Yeah, I probably won't need 90% of my scripts ... but scripting's much more fun!
Jay
> I've been writing whose clauses all morning.
Watch it. They're addictive ;-)
--
Shane Stanley, ssta...@myriad-com.com.au
> Yeah, I probably won't need 90% of my scripts
As one door closes, many more open ;-)
--
Shane Stanley, ssta...@myriad-com.com.au
But i never ran into a Whose Clause!
I have seen the script Jay putted here. It seems to me it's some kind of aa loop condition.
Can it be used in vb and why are you guys so happy about it?
I'm just wondering :)
It's AppleScript only. The more formal name is a filtered reference, and you
use it instead of iteration to find objects whose property or properties
match certain criteria. So you might say something like 'every word of story
1 whose contents contains "script"' or or 'every text frame of page 1 whose
fill color is color "A color"'.
--
Shane Stanley, ssta...@myriad-com.com.au
On 03-10-17 10.06, in article BBB5E023.6A1B4%ssta...@myriad-com.com.au,