Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

GREP: Changing style after colon

Return to Member Forum

  • Author
    Posts
    • #14338432
      Kenny Norris
      Participant

      Been banging my head against InDesign for a while now trying to change the style of text after a colon.

      The problem is that I’ve got lists similar to the following

      OneWord
      Two Words: and extra text
      OneWord: with text here too
      Two Words
      Hyphanated-Words: with text

      All I want is to get that text after the colon changed, but not every ‘Word’ has a colon following it (if it had I would’ve solved this mystery by now). Any help, please!

      (Otherwise back to manual handling of text.)

    • #14338447

      Is it not possible to change the paragraph style applied to these paragraphs so that you only need to change the text that precedes the colon (instead of the text that follows)? For example, you want a Bold lead-in to text that’s set in Regular/Book. That’s the more common case. But that’s not a complete solution ;-) Just makes it a little less complicated.

      If you need to apply a character style to text *after* a colon, the first Nested style has to apply the character style [None] through 1 colon. This means “skip this part”. Then add another Nested style after that one that applies your desired character style to the rest of the paragraph. For example, [italic] through [and then for a stop character add something that doesn’t appear in the text, like a Section Marker, the last item in the dropdown list). ID will apply that character style until the end of the paragraph.

      Okay so now the problem is what to do with those paragraphs that lack a colon. In the past the only way I’ve solved this is to manually enter some sort of non-printing,0-space-adding character in the paragraphs that lack a colon.

      In this situation where you’re skipping the first bit of text, you’ll need to go through the text and in those paragraphs lacking a colon, replace a space character after the word/s in questions with something like a non-breaking space (Type > Insert White Space). That takes up the same amount of room as a space. In your Nested Style set up, in the first one set to apply “None” up to a colon, you’d click to the right of the colon and enter ~S which is code for Non-breaking space.

      So: two steps. Comb through the text and manually apply a marker to paragraphs that need one. And then add that marker to the Nested Style.

      To make it less complicated, you could adjust your paragraph style as I described in the beginning. If you did that, you’d just need one Nested Style that applies your “make this part look different” Character Style up to or through a colon. Then go through the text and add a “End Nested Style Here” (Type > Insert Special Character > Other) in those locations … they’d be easy to spot because InDesign will have applied the Character Style to the entire paragraph, since it didn’t find a colon.

      Does this help at all?

    • #14338581
      Kenny Norris
      Participant

      I think it does help, thanks, Anne.

      The more I’m using, and digging into, ID the more I’m reminded that this is a serious bit of kit.

    • #14338646

      Just a simplistic Grep Style:

      :\K.+$

      or, if you could have a soft-return in your paras:

      :\K(.|)+$

      (^)/ The Jedi

    • #14338708

      Ah! Michel that works. But wouldn’t a Nested Style work too? (Skip up to the first colon, Bold style to end of paragraph).

      Kenny, I think I misunderstood your question. I thought that the one- and two- word paragraph examples you gave had text following them, and the problem was how to tell InDesign where to start applying the different-looking text if there was no colon.

    • #14338727

      3 nested styles:

      [None] up to :
      [None] up to 1 characters
      Bold through End Nested Style Character

      (^/)

    • #14338733
      Kenny Norris
      Participant

      Michel and Anne-Marie, sorry I’ve been watching this convo from a distance but I’m thankful for your comments. :-) Not surprisingly for a powerhouse I’m at times daunted by the sheer things I can do within InDesign, but at the same time I’m having fun learning and making my documents easier to use and better (IMO) looking.

      Michel, I used your GREP sample the other day and it worked pefectly smoothly.

    • #14338764
      Geoffrey West
      Participant

      Hi guys. This one caught my eye. I applied the top GREP style from Michael’s first response and that worked great. I set the style to “None” in the GREP style section. I also added a nested style, per Anne-Marie. I did “bold through 1 :” in my Nested Styles section.

      So now anything after the colon is regular/book, and anything before (including lines without a colon) are now bold.

      Is that a good workflow, you think?

      (Wish I could upload pics…)

    • #14338777

      Hi Geoffrey, yes, either one is a good workflow if it works! ;-)

      Best practice is to keep automation as quick and simple as possible. GREP Styles can be processor-intensive, especially if there are a bunch of them in one p style and that style is used heavily throughout. So if you can do the job with a Nested Style, then that’s a better option (not so processor-intensive). Save GREP Styles for when the automation can’t done with a Nested Style.

      Michel would you agree? Or no. Curious as to your thoughts.

    • #14338880

      No sense for me!

      The question is about what enrichment “before/after :”!

      That means what choice an user has to make first defining the para style as “regular” or “bold” font style!

      E.g., (s)he will use a “^.+?:” Grep style to bold text before in a “regular” para style! …
      Which clearly means: (s)he will only want to bold if “:”!

      About the use or not of Grep styles, I think the true matter boils down to the Grep trivial knowledge.

      (^/)

Viewing 9 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads