Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Smart Title Case

Return to Member Forum

  • Author
    Posts
    • #55820

      The comments in my post about Configurator 2.0 and ID started veering to the topic of a “smart” Title Case function, so I'm redirecting people interested in that to this thread.

      There actually *is* an intelligent Smart Title Case script around, written by Dave Saunders a while ago (2006):
      https://jsid.blogspot.com/2006/…..sited.html

      Or you can include the following GREP Style in your paragraph style for the Title grafs. It finds the first lowercase character of every word and makes it a cap because in the GREP style you specify a Character style that sets the case to All Caps.
      <(?!(a|the|of)>)l

      The words in the pipes are ignored, and you can add more if you want.

      Thoughts?

    • #55821
      KlausNordby
      Member

      Whoa! Yes, of course, GREP to the rescue again! I'm still very much a GREP newbie, hence I didn't think of that myself <kicks self>. I'll also check out the Saunders scripts, so thanks! (I have indeed been kind of scarce around here for a while, due to some travels and other personal stuff — thanks for “missing” me, even if only very, verrrry little! :-) )

    • #55822
      Harbs
      Member

      I don't think you can come up with a GREP to really solve this problem. The problem is: Smart Title Case is not just converting the first letter to caps except for cetain words.

      The first word of a title should always be capitalised — even if it's “A” or “The” etc. There's also words like USA, InDesign, etc.

      FWIW, my Formatting Tools solves all these problems and can convert by style: https://in-tools.com/wordpress/&#8230;..ools-1-0-5

    • #55827

      Don't forget: a GREP style can only change lowercase to uppercase, since that's all that is possible with a character style. So a GREP style cannot convert an uppercase to a lowercase character to 'correct' from “InDesign Is A Rather Good Program” to “InDesign is a Rather Good Program”.

      The same goes for the first word of a title — this would typically already be entered as a capital.

      (Harbs' tool does not have these limitations.)

      That said, A-M's GREP can be adjusted to this to change the first character as well (and it shows where the backslashes go):

      (^s*l)|(<(?!(the|an?|in|to|o[rfn]|for)>)l)

    • #55831
      Phil Frank
      Participant

      So I must be doing something wrong. I've typed myself a few titles, all in lower case, and complete with instances of and, the, and of. I have a nice character style called all caps that sets the case to All Caps. When I use A-M's GREP, all the words in my titles stay all lower case. When I use Jongware's, each word is capitalized. Clearly I am missing something. Any ideas about what that might be?

      Thanks.

    • #55832

      Oops. Gremlins Ate My Backslash! :-(

      (^s*l)|(<(?!(the|an?|in|to|o[rfn]|for)>)l)

      (It was the one right before '>' that went missing … this time.)

      The Ye-Shall-Not-Find-This list is a bit obfuscated because of my shorthand notations:

      an? = 'a', optionally followed by one 'n'

      o[rfn] = 'o', followed by one of 'r', 'f', or 'n'

      After that the word should end (A-M thought of that), which is done by the last > code (End Word). If none of the above applies, the first lowercase character is matched.

      The stuff at the start is “Beginning of line, any amount of whitespace (including zero), then a lowercase character. This ensures the first word is always capitalized — try it with “iPads are expensive toys” … (You'll see ID toggle between lowercase and uppercase while entering this.)

    • #55833
      Anonymous
      Inactive

      The Script is far easier imho, lol.

      But the GREP stuff is pretty awesome.

      I wish that Paragraph styles catered for more cases though, like Title Case or even implemented a Smart Title Case with a list of words in preferences to ignore.

      But all the same, I prefer the script here rather than a Grep Style, imho too much can go wrong with the GREP.

    • #55834
      Phil Frank
      Participant

      Yes, that makes a big difference. I haven't figured out why A-M's doesn't have any effect, but yours is now working as expected.

      Much obliged.

    • #55837

      Thank you Jongware!

      It's not really “my” GREP, btw, I picked it up from a forum post somewhere. (not this forum.)

      I like Harb's solution, myself. ;-)

Viewing 8 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads