I can't get my brain around what is probably a very simple problem: I want a paragraph style that applies boldfacing to any character up to an including the first colon in a paragraph. If I used a nested style "through 1 :" the whole graf is bold if there is no colon. So that's out.
A grep style ".+: " seems to work in most cases, but if there's a second colon, the boldfacing is extended to that point. What I think I want is a grep style that works "zero or 1 times" but I cannot figure out how to use the ? to make that happen.
A-ha. Now that is not possible with GREP styles -- they are part of a paragraph style, and strictly limited to text inside each paragraph. No peeking out of it either way. Single-line and multi-line modifiers do not work, and neither does fiddling with \r anywhere inside a GREP style.
You have to create another paragraph style containing this GREP only, and apply it to your first paragraph.
@Jongware – I think Robert wants to limit the GREP style to the first line of a paragraph.
But unfortunately GREP in InDesign does not know about line endings.
In scripting we could do something like what he wants, but comes with some obstacles, because the GREP will apply a character style, that will probably change the line ending. A very dynamic situation…
Example 1
Basic situation:
This is my text here comes the colon: and
here another one: that Robert don't like
to take into account using the GREP style.
Formatted after the GREP style is applied:
This is my text here comes the colon: and
here another one: that Robert don't like
to take into account using the GREP style.
As I understand it, in case that the first colon will leave line one, only the first line should be formatted like this:
(Case 1)
This is my text here comes the first
colon: and here another one: that
Robert don't like to take into account
using the GREP style.
Or should it be, that the style should only be applied, if it's in the first line?
(Case 2):
This is my text here comes the first
colon: and here another one: that
Robert don't like to take into account
using the GREP style.
But what, if the colon in the basic case is at the end of line 1 and will be shifted to line 2 after formatting?
What should happen then?
That is simply not possible to format automatically (dynamically) using GREP styles in InDesign.
Uwe
Uwe, I don't see that at all in the original post. He seemed quite clear to me that he wanted to apply the style up the first colon, no matter where, and not beyond, and that the style should only be applied IF there is a colon, ruling out a regular nested style. The only reference I see to anything like the first line is the beginning of paragraph mark.
suppose you approach it the other way. Apply the line style to the first line and then apply a GREP style to UNdo it after the first colon with a lookbehind? Not quite sure how to make that work so the line style is removed if there is no colon... Perhaps a second GREP style that looks for the string at the beginning and checks for a colon, but I'm not sure how to prevent that from being applied if the colon is found.
North America
Europe, Middle East and Africa
Asia Pacific