Friday, June 16, 2006

 

Smart Title Case Revisited

In response to a request, I've updated the Smart Title Case script I posted last August (and wrote about here). The new version is now available in the Featured Scripts Downloads section.

I've made two changes, one trivial and one significant. The significant change is that the script now adds an initial cap to the first word after a forward slash, so, instead of having:
absolutely/positively
convert to:
Absolutely/positively
it now converts to:
Absolutely/Positively
The lesser change is a clean-up of the built-in list of words to ignore. I had "is" in there. To my eye, capitalizing "is" in title case text looks wrong, but because it is a verb, it apparently ought to be capitalized according to the style guides I have read. My reaction to this is to avoid using "is" in a title, but I don't always have control over the contents of titles in the documents for which I do the composition.

Usage Note

This script includes two word lists you can edit to customize it to your own use. Or, you can use an external word list in a text file for each of the two lists.

If you don't use the script very often, it is easy to confuse yourself by creating an external word list and then forgetting that you did this. I've done it myself and found myself trying to debug a non-existent problem because the script was apparently ignoring my changes to the word lists -- it wasn't ignoring my change: it was ignoring the whole list.

I suggest if you do decide to add an external list you should edit the corresponding list in the script to say so. For example, change the ignoreWords line to read:
var ignoreWords = ["using external file"]
Then, when you come back to the script a month or so later and want to add another word to the list, the script itself will remind you what you did.

Comments:
Great script! There are so many exceptions, though, that it makes it harder to use (for example, all the State abbreviations, many tech companies, Apple's product line, etc.).

You mention you had an update that handled words split by a /... I don't see that code in the zip file I downloaded. Can you point us to it?

I'd also like to make a change so that words with periods in them (H.P.) and separated by hyphens could also be properly capitalized.
 
Thanks for the kind words and for pointing out the error. Somehow, in July, I managed to upload an old version of the script over the new version. The download should now be correct.

Ah, I see what you mean about H.P., etc.

With a large number of exceptions its best to work with an external exceptions file. I recommend changing the strings inside the script to say that you're doing that -- a number of times, I've been frustrated because I'd edit the words in the script and it would mysteriously fail until I remembered the external file.
 
Thanks for reposting it. I ended up doing it a different way so I could base it on a list of different separators that it goes through (I'm using / . - ).

I also have a flag to disable the ignore words (for example, if I know I'm looking at someone's name -- John A. Smith).

Let me know if you'd like me to send this to you. It's not as elegantly coded as yours, but it seems to work. (It's also for a different platform than what you're using).
 
I was thinking that some kind of list was the way to go, possibly even using RegExp to sort out what are the words in the selection.

Glad you sorted it out for your needs.

Dave
 
I have felt plagued by the absence of this "Smart" title capitalization functionality for a LONG time. Thanks for the great script.
 
I was SO excited about this script, because I was told today by the boss that I would have to hand-capitalize all of the mixed-case states that come by me (due to coding errors) -- which would be 200+ a day.

However, like you said, it effects the case settings of all the text in the same text boxes/paths as the words I've set up in the script (all of the states for example.)

Is there ANY way to preserve the case settings of the text not included in the script? I deal mainly with names and addresses -- IMPOSSIBLE to enter every possible word, as you can imagine.

I never could get the hang of javascript.

Thanks!
 
Nicole,

I'm afraid I'm not understanding your problem. Can't you just set up an external file of exceptions?

Dave
 
I set up all of the states, and that works perfectly to force caps onto them. tx -> TX, Tx -> TX, etc.

But I'm pulling in huge data entry sheets of addresses from all over the country, so I can't possibly specify all of the exceptions needed.

What's happening is this:

I have text set up, "3334 KITTY LANE * DALLAS, Tx 77777"

I want it to stay like that with the exception of the state, but when I run the script, it changes it to, "3334 Kitty Lane * Dallas, TX 77777." The state is right, but the rest of the address is wrong.

Is this an easy solution that I'm looking over? I hope I'm making sense.
 
Nicole,

You're using the wrong script. This script is intended to change the text as you indicated. That's what Title Case is all about. You need a different, simpler script.
 
Well that sucks! I have yours all set up and ready -- what a bummer. Oh well, I can use it for other things when I need.

Can you give me an idea of what to google for to get the right script, please? I've searched and searched.
 
Nicole,

Check the U2U forum again. I realized that CS2 comes with the FindChangeByList script (or some name like that) which will do the job for you.

Dave
 
Okay, this is a great script, but I've not been able to find a way to use it in a "Find & Replace" fashion, just going through one object at a time, and doing it. At this rate, it's not much faster than using a hot key for Change Case/Title Case, and then correcting the few non-conformities.

If there is a way to use it as find and replace, I could find all text assigned a certain Paragraph Style and make them Title Case. That would be very handy!!

Is there a way to do that? I read the enclosed ReadMe, but saw nothing about it there.
 
Wrapping a Find/Replace around the script would be a good idea. It's been a while since I've done anything here -- real work has been keeping me very busy. Maybe that would be a good thing to add, something along the lines of the scripts being discussed at InDesign Secrets:

http://indesignsecrets.com/find-change-scripting-goodness.php

Dave
 
Dave, just wanted to take the opportunity to thank you again for this script. In updating to a new version of InDesign, I someone lost this script, but you can believe that this is one of the first that I hunted down on the internet to add into my repertoire again! :-)
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?