Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

"Bolding" all words before hyphen in classifieds...advice please?

0 views
Skip to first unread message

Christine...@adobeforums.com

unread,
Oct 14, 2003, 10:52:11 PM10/14/03
to
Hi all,
I know this is a strange question and probably will not have an easy answer, but I thought I would try anyway since just about everything else I have ever asked here has always been resolved by all of you:))

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......)

Dave_S...@adobeforums.com

unread,
Oct 14, 2003, 10:57:31 PM10/14/03
to
Christine,

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...@adobeforums.com

unread,
Oct 14, 2003, 11:00:41 PM10/14/03
to
Couple of questions before going forward. Biggest one, are you Mac or PC?
Second, how does the copy get into ID? Manually? It should be fairly easy to
script it out. We run similar ones here. You select a textbox and
double-click a script in the scripts palette and it formats the text block.
We also have ones that format all blocks on the page. Which one would you
like? Finally, there might be a slight margin of error involved. Your
example actually includes 3 hyphens. Is it possible that a block will come
through without a lead paragraph but still have a phone number? Okay, last
question. Is it a hyphen or one of the special dashes?

Chris


Christine...@adobeforums.com

unread,
Oct 14, 2003, 11:29:45 PM10/14/03
to
Wow...such a quick response already:)) Thank you...my hopes are already rising....

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.)

Dave_S...@adobeforums.com

unread,
Oct 15, 2003, 7:22:22 AM10/15/03
to
Here you go. Just change the property to have the names of the paragraph styles on which you want the script to operate, and make sure there's a character style named Bold.

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

Dave_S...@adobeforums.com

unread,
Oct 15, 2003, 8:23:06 AM10/15/03
to
Some usage notes:

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

Jay_F...@adobeforums.com

unread,
Oct 15, 2003, 11:49:51 AM10/15/03
to
Here's another option. It uses a "whose" clause -- which, IIRC, Dave dislikes [grin]:

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.

Carl_...@adobeforums.com

unread,
Oct 15, 2003, 1:15:48 PM10/15/03
to
Christine,

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

Christine...@adobeforums.com

unread,
Oct 15, 2003, 5:15:41 PM10/15/03
to
(Aaaargghh...today has been CHAOS since the moment I walked in so I have only been able to come and check on this forum now...today was our first day with our new redesigned look and thank God it came out GREAT!....Now all we have to do is solve all the little 'bugs' that cropped up along the way.)

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!

Christine...@adobeforums.com

unread,
Oct 15, 2003, 10:41:18 PM10/15/03
to
Okay....I have tried out the scripts...the first one works PERFECTLY!! Thanks VERY MUCH DAVE:)) This is EXACTLY what we needed!! (We are going to celebrate tomorrow....:)
As you directed, I changed the names of the property to have our paragraph styles we were referencing and I also changed the character style in the script to match exactly the name of the character style we are using — I did not want to have a character style that read just as "bold" because we needed something more specific such as "classified bold" for example.

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_S...@adobeforums.com

unread,
Oct 16, 2003, 7:51:56 AM10/16/03
to
Enjoy the script while it lasts. When ID CS comes along, you'll be able to integrate the calls for that character styles into the paragraph styles themselves (using the Nested Styles feature).

Dave

Jay_F...@adobeforums.com

unread,
Oct 16, 2003, 11:42:48 AM10/16/03
to
Christine --

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

Dave_S...@adobeforums.com

unread,
Oct 16, 2003, 1:14:07 PM10/16/03
to
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

Jay_F...@adobeforums.com

unread,
Oct 16, 2003, 2:48:21 PM10/16/03
to
Cool. I love 'em.

I saw a demo recently of InDy CS' nested styles: very, very awsome. I can hardly wait.

jay

Olav_...@adobeforums.com

unread,
Oct 16, 2003, 3:23:29 PM10/16/03
to
Jay--

It's scriptable, too.<g>

Thanks,

Ole

Dave_S...@adobeforums.com

unread,
Oct 16, 2003, 3:28:08 PM10/16/03
to
The really neat thing about nested styles, though, is that it obsoletes the need to script so many tedious things, like the need that Christine had when she posted this topic.

Dave

Jay_F...@adobeforums.com

unread,
Oct 16, 2003, 5:14:11 PM10/16/03
to

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

Shane_...@adobeforums.com

unread,
Oct 16, 2003, 6:32:10 PM10/16/03
to
On 17/10/03 3:14 AM +1000, Dave Saunders, mem...@adobeforums.com, wrote:

> I've been writing whose clauses all morning.

Watch it. They're addictive ;-)

--
Shane Stanley, ssta...@myriad-com.com.au

Shane_...@adobeforums.com

unread,
Oct 16, 2003, 6:26:34 PM10/16/03
to
On 17/10/03 7:14 AM +1000, Jay Fraser, mem...@adobeforums.com, wrote:

> Yeah, I probably won't need 90% of my scripts

As one door closes, many more open ;-)

--
Shane Stanley, ssta...@myriad-com.com.au

Eelko_He...@adobeforums.com

unread,
Oct 17, 2003, 3:21:58 AM10/17/03
to
I'm not very used with VB
I understand programming in general and had some courses in other languages. These days i'm concentrating on Vb and scripts.

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 :)

Shane_...@adobeforums.com

unread,
Oct 17, 2003, 4:06:28 AM10/17/03
to

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

Richard_...@adobeforums.com

unread,
Oct 17, 2003, 1:54:38 PM10/17/03
to
To which one might add that they are sometimes very tricky to understand.
There are a lot of times I just can't figure out HOW to use them, even
though I know they should be possible.

On 03-10-17 10.06, in article BBB5E023.6A1B4%ssta...@myriad-com.com.au,

0 new messages