Smart Title Case

Tagged: , ,

Viewing 16 reply threads
  • Author
    Posts
    • #52851

      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/06/smart-title-case-revisited.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)>)lThe words in the pipes are ignored, and you can add more if you want.

      Thoughts?

    • #52852
      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! :-) ) 

    • #52853
      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/indesign/plugins/formatting-tools/formatting-tools-1-0-5

    • #52854

      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)

    • #52855
      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.

    • #52856

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

    • #52857
      Eugene Tyson
      Member

      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.

    • #52858
      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.

    • #52859

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

    • #79186
      Scott Rudy
      Participant

      bringing this back from the dead….

      this is working for me until i add a forced line break before a excluded word (i.e., and)

      when I force break and the word i do not want to be capped is the first word on the next line it gets recognized as the first word of a new sentence capitalizing it. is there a remedy?

    • #85470
      Chris Haynes
      Member

      GREP style : CAPS

      \<\w(?=\w{3,}\s)

      Change first letter of any word larger than 3 letters

      (It is not perfect)

    • #85486
      Chris Haynes
      Member

      – EDIT you dont want the space at the end

      \<\w(?=\w{3,})

    • #96345

      I found this post looking for a proper Sentence Case method. Found a post and editing it a bit i got it to work i think.
      You make a Character Style CAPS with Caps as Casing of course. Then make a Paragraph Style with a grep using; ^.+~j|[\w-] If you add a + on the end it will take the complete word and make this TITLE Cased. Handy for index or so.

      But now i still need a version which takes the first word in a sentence and not per row.

    • #96347

      I think i found it i replace +~j to \r, so it look at the paragraph letter??? Seems to work. So now the code is ^.\r|[\w-] this will automatically Sentence Case a Paragraph

    • #96357
      Scott Rudy
      Participant

      would this work?

      apply an all cap character style to…

      (?<=\p{punctuation} )\l|^\l

      it looks for any punctuation followed by a space then caps the next letter, then it caps all first letters of a paragraph

      this will work for a multi sentenced paragraph.

      • #96362

        Yes this seems to work as well. So both codes work, thats great. Now i need to dive in this stuff, so much power here :)
        With more knowledge hours of work can be solved in a couple of minutes of coding.

    • #96365

      After double checking yours works better and exaclty what i needed. My version some still did soft returns as regular returns

    • #97014

      Just tried the original Smart Title Case script, but it doesn’t seem to be working with CC2017. Is there an updated version around?

Viewing 16 reply threads
  • You must be logged in to reply to this topic.
>