Highlighted

GREP Style Title Case Exceptions

New Here ,
Apr 11, 2020

Copy link to clipboard

Copied

A couple years ago I found a set of GREP Styles to display text as title case (as described here), but still allow me to cross-reference it in sentence case. I can't seem to dig up where I had gotten it from, but putting it to work in a new document I found it capitalizing things it shouldn't, so I've started to revise the expressions to better reflect "proper" title casing. Originally posting here to seek assistance, I eventually scrapped together enough comprehension of GREP to fix it on my own. Here's what I came up with, maybe you know a better way?

 

Apply Style: All Caps (style only contains Case set to All Caps)
To Text: ^\S

 

Apply Style: All Caps
To Text: /\S

 

Apply Style: All Caps

To Text: :\s\l|[-\s]\l(?!(f|he|nd?|o|y|rom|or|r|ut)?\b)

 

Apply Style: Normal Case (style only contains Case set to Normal)

To Text: \s(a)\s|\s(an)\s|\s(and)\s|\s(are)\s|\s(but)\s|\s(down)\s|\s(in)\s|\s(is)\s|\s(of)\s|\s(on)\s|\s(or)\s|\s(the)\s|\s(to)\s|\s(up)\s|\s(up,)\s|\s(with)\s

TOPICS
Scripting, Type

Views

249

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

GREP Style Title Case Exceptions

New Here ,
Apr 11, 2020

Copy link to clipboard

Copied

A couple years ago I found a set of GREP Styles to display text as title case (as described here), but still allow me to cross-reference it in sentence case. I can't seem to dig up where I had gotten it from, but putting it to work in a new document I found it capitalizing things it shouldn't, so I've started to revise the expressions to better reflect "proper" title casing. Originally posting here to seek assistance, I eventually scrapped together enough comprehension of GREP to fix it on my own. Here's what I came up with, maybe you know a better way?

 

Apply Style: All Caps (style only contains Case set to All Caps)
To Text: ^\S

 

Apply Style: All Caps
To Text: /\S

 

Apply Style: All Caps

To Text: :\s\l|[-\s]\l(?!(f|he|nd?|o|y|rom|or|r|ut)?\b)

 

Apply Style: Normal Case (style only contains Case set to Normal)

To Text: \s(a)\s|\s(an)\s|\s(and)\s|\s(are)\s|\s(but)\s|\s(down)\s|\s(in)\s|\s(is)\s|\s(of)\s|\s(on)\s|\s(or)\s|\s(the)\s|\s(to)\s|\s(up)\s|\s(up,)\s|\s(with)\s

TOPICS
Scripting, Type

Views

250

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 11, 2020 0
Most Valuable Participant ,
Apr 27, 2020

Copy link to clipboard

Copied

I think you can (rather vastly) simplify in the following way:

 

Apply All Caps to:

(?<!\w')\b\l

 

which means "word break, lower case, unless preceded by a word character and apostrophe" -- the latter to prevent "I'Ll Be Back".

 

Apply Normal to:

\b(a|an|the|it|of|with|at|from|into|during|including|until|against|among|throughout|despite|towards|upon|concerning|to|in|for|on|by|about|like|through|over|before|between|after|since|without|under|within|along|following|across|behind|beyond|plus|except|but|up|out|around|down|off|above|near)\b

 

which is the common definitie and indefinite articles, plus the 75-or-so most common prepositions, preceded and succeeded by a word break and separated by the vertical bar for OR.

Compare yours against mine: I can spot a few minor differences, such as "as", but the overall format of the GREP style is easy enough to add these if you want.

 

sample usesample use

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 27, 2020 2