Grep style for finding words at the end of a line
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Grep style for finding words at the end of a line
Tagged: grep style, orphan, widow
- This topic has 5 replies, 4 voices, and was last updated 9 years, 4 months ago by Gavin Anderson.
-
AuthorPosts
-
-
September 25, 2013 at 8:20 am #65508Cindy KelleyParticipant
Hi,
I have an anal client who hates hyphenation and a line of text that ends with words such as “and”, “but”, “or” or any word smaller than four letters. I know, I know, this is going to make for some ugly paragraphs but this is what he wants.
Can I use grep styles to fix these things in a similar way I use a grep style to fix widows?
Thanks everyone!
Cindy in Indy
-
September 25, 2013 at 8:24 am #65510Cindy KelleyParticipant
I think I came up with a solution — I have replaced all the spaces following these words with a non-breaking space.
If someone has a better idea or can make me a script to do this that I can use when I have this client’s jobs, I will send virtual hugs your way.
-
October 13, 2013 at 3:34 pm #65747‘toputadavida PutaoaldoMember
Hi,
I’m on the side of your client! Here’s a simple grep…Create a char style ‘no break’ – select only ‘No Break’ on the Basic Char Formats tab.
Edit GREP Style for your chosen para style
Add New GREP Style, with ‘no break’ char style selected, To Text: and (?=\w+)
[space][the word][space][before one or more words]Instead of space, you could also put \s for ‘any space character’ instead of just typing [space].
You’d need to make a style for each small word you want to apply ‘no break’ to…
Too many GREPs slow down long documents, so it may not be viable for all projects.
-
October 13, 2013 at 5:45 pm #65749‘toputadavida PutaoaldoMember
Just noticed that you don’t need the + in the grep – one word look ahead is enough.
-
October 15, 2013 at 5:56 am #65797Matt MayerchakParticipant
In a regular GREP, you can combine words as an OR expression with the vertical bar. So, for example, you could use just one GREP style for [and|but|or|for]. I have not tested this but it seems like it ought to work in this case.
-
December 4, 2014 at 1:50 pm #72051Gavin AndersonParticipant
Here is a GREP for getting rid of orphans.
Apply a NO Break character style (a style where the only thing specified is that No Break is forced on) to the following:
(\w+ \w+)[[:punct:]]$
-
-
AuthorPosts
- You must be logged in to reply to this topic.