Making a Custom Composition Highlighter to Find Invisible Characters
Trog, in a tweet, wrote:
is there a way to add custom composition highlights ex. soft & hard return invis. characters?
Interesting question! Highlights are usually used to find special or problematic formatting. We’ve talked about InDesign’s composition highlights feature several times (such as this overview, and this clever tip from Mr. Rankin). But this is an interesting question: why not use highlights to quickly see special invisible characters?!
My first thought was, sure, you could make a special highlight character style and then apply it using GREP Styles to characters such as the new line (Shift-Return/Enter) character. Unfortunately, this doesn’t work because those characters are technically zero width — so the highlighting just disappears.
However, then I thought of a workaround: You could apply the highlighting to the character before the carriage return or new line character.
For example, here’s the original text:
It’s hard to tell from this what is a new line (shift-enter) and what is a carriage return (enter). So let’s make a couple of highlighter character styles like this one:
and then let’s apply those character styles to the character just before the invisible characters with two GREP styles inside the paragraph style definition:
Those codes are kind of strange, aren’t they? The first one .(?=\n)
means “any character that immediately precedes a shift-return” (some folks call this a soft return, others a hard line break). The second one is the same, but for a hard carriage return.
Here’s the result:
Of course, you’ll also notice that I have turned on Type > Show Invisible Characters in the image above so that you can see that the pink is applied to shift-returns and blue shows up at the hard carriage return.
Although the Show Invisible Characters already shows you what’s what, this kind of highlighting can be far easier to see, especially at a glance.
The only problem with this kind of highlighting is that it’s annoying to have to turn it off when you want to print or export a PDF. Sandee Cohen showed a clever workaround to this problem at the recent PePcon: The Print + ePublishing Conference.
Hi David,
clever solution. This could be helpful, if we try to find hard returns and want to delete them by hand for epub-output.
However: The grepstyle must applied to every single paragraph. To do that, we could use the GREP-Editor from Peter Kahrel.
Two additional thoughts:
1. There is no need for a lookahead. “.\n” will work also.
2. To deactivate the grepstyle for printing we could use “*” >> “*.\n”
And a additional idea:
We could use a condition instead of grestyles and apply the condition with a grep “\n.
“.
Benefit 1: The condition is applied only through the hard returns
Benefit 2: There is no need for deleting or deactivating things, since conditions does not print.
Kai: Great points! Yes, doing it as a condition would be very good idea, but you would have to run the Find/Change each time the file was edited.