Skip navigation
vazrick2
Currently Being Moderated

GREP Question:  Style em spaces that precede only certain triggers within a paragraph

Jan 8, 2013 10:54 PM

Tags: #color #cs5.5 #layout #styles #grep

Hello,

 

Up front:

I do not know GREP well enough to begin to tackle this.  And as usual, I'm in a pinch!

Also, if you're the visual type, just look at the second to the last paragraph at the bottom, and that may be enough to help you devise the GREP style.  Otherwise, bear with me, I have to think this through...

 

I have a list that spans pages of events.  The events are formatted as follows:

Box City EventNameSpecific Month EndPara (this is a single paragraph in a story of a hundred such paragraphs)

 

On paper, each event will need to be preceded with a filled specific-colored box ().  I would like this box to be made from a strikethrough applied to an em space using grep, since that is very easy to create using a character style and only requres one setting (the thickness of the strikethrough).

 

There is a legend at the bottom of the page, detailing about 14 types of events.  Some of the different types of events will require the same colored box.  But in all I have 7 different colors of boxes in the legend.

 

I'm looking to create...

 

  • 7 character styles, one for each color (consider this done already)
  • 1 paragraph style (essentially done, but missing the GREP)
  • 7 GREP styles (or more as necessary) specifically to apply only to the em space that precede specific sets of text strings
    • If I need, or if it is simpler to create 14 GREP styles within the paragraph style, that's fine.  But I understand we may be able to do something like this... (Target phrase 1 | Target phrase 2 | Target phrase 3) in between parenthesis to identify multiple possible triggers within the same rule. 
    • I'm fine whether it's 7 or 14 rules in there, I just want to be able to update them over the course of time as necessary - but it won't be for another season at least if I do.

 

I don't know GREP well enough to piece together what I need.  Vaguely familiar with look aheads and look behinds.  I do understand it may be easier if the em space is in between other characters, so in my example below I've inserted hairspaces.  But ultimately I want the em space to be flush or nearly flush to the left of the frame.

 

For my example below:

 

  • I only want to apply character styles to em dashes based on the strings in bold.
  • The strings of text that will trigger the GREP will vary in number of words and may or may not contain a dash.
  • I want to ignore Citynames regardless of number of words... Chicago vs. San Francisco vs. Vancouver, BC for example.
  • I want to ignore MonthofYear which appears after the second tab.
  • The tabs will have set stops as a regular part of the paragraph style.  I'm including them in my example below in case it helps to visualize possible anchors to use in GREP.
  • I want the style to be easy enough to modify, for example if I want to simply add an (EEEE New Eventname) to the list of possible options within a rule that triggers a specific character style.  See below should make it clearer.

 

So here's what I'm thinking...

Within the Paragraph Style, the first two examples of GREP Styles should be able to respond to the following criteria:

 

Rule 1:  If the paragraph contains any of the following, then apply Char Style 1 to the em dashes in those paragraphs. Use a unique GREP expression for each phrase below where each uses Char Style 1 or use a single GREP expression to capture all three possible triggers:

  • ABC BB Invitational
  • ABC Xxxxxxxxxxxxxx
  • ABC MM-Xxxxxxxxxxxxxxx

 

Rule 2: If the paragraph contains any of the following, then apply Char Style 2 … and so on

  • Global ABC Xxxxxxxxxxxxxxx
  • Global WXYZ Xxxxxxxxxxxxxxx

 

I cannot count on “ABC” or “Global” being the trigger for the style, if you know what I mean.  I need the entire phrase (ABC BB Invitational) to be the trigger… if it exist in its entirety, then apply the style to the preceding em dash in that paragraph.  This way if there are any mispellings or if we launch a new event type which ends up flowing in to my document I will know it.

 

hairspace  emspace  tabspace CitynameOneWord ABC BB Invitational tabspace MonthofYear

hairspace  emspace  tabspace  Cityname TwoWrds ABC BB Invitational tabspace MonthofYear

hairspace  emspace  tabspace  Cityname MultiWrds ABC BB Invitational tabspace MonthofYear

hairspace  emspace  tabspace  Cityname TwoWrds ABC MM-Xxxxxxxxxxxxxx tabspace MonthofYear

hairspace  emspace  tabspace  Cityname MultiWrds ABC Xxxxxxxxxxxxxx tabspace MonthofYear

hairspace  emspace  tabspace  Cityname TwoWrds Global ABC Xxxxxxxxxxxxxxx tabspace MonthofYear

hairspace  emspace  tabspace  CitynameOneWord Global WXYZ Xxxxxxxxxxxxxxx tabspace MonthofYear

hairspace  emspace  tabspace  CitynameOneWord Global Special Xxxxxxxxxxxxxxx tabspace MonthofYear

hairspace emspace tabspace  CitynameOneWord Globl Special WRONG SPELLING  tabspace MonthofYear


I hope this makes sense and isn't too unnecessarily redundant.  Time for bed.  Fingers crossed someone will post at least one GREP string, so I have some magic code for tomorrow morning!  Ideally, it would be great if you would include a brief explanation of waht the string is doing, but minimally, please do use one of my text stings above, so I know what to mess with and what not to.  ;-)

 

<says prayer>

 

Thanks!

Rick

 
Replies
  • Currently Being Moderated
    Jan 9, 2013 6:42 AM   in reply to vazrick2

    Well, for a moment I thought I had an idea of how to do this with GREP styles, but I realized it wouldn't work, and I'm not sure it's possible unless you are able to make a separate style for every possible string between the em space and the trigger text. You want to use the lookahead because you want to find that text, but you don't want to select it or apply the style to it, but a lookahead can't handle the kind of variability on string length that you need to work based on just the bolded text at the end.

     

    It would actually be easier to use paragraph styles based on the bolded text that include a nested character style, I think. That could be handled by find change, but I think the best thing is probably to move this over to scripting.

     

    Rather than just move the discussion, though, I'm going to ask you to cross post so there are two threads on the chance that someone else who doens't visit scripting might have another idea for you here.

     

    Here's a link to scripting: InDesign Scripting

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points