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

Excluding from a GREP style

Return to Member Forum

  • Author
    Posts
    • #93703

      I am applying GREP styles via the paragraph styles to text in my document. Some text appears in parentheses, but in certain cases, I want to apply the style only to the parentheses, not to the text contained in them. I’ve tried numerous ways to exclude the contents, but I can’t seem to get anything to work.

      Similarly, I also want to sometimes exclude something from the GREP style. For example, I want the style to apply to the whole paragraph except any + symbol in the paragraph (because it needs its own style).

      Thanks in advance for any help and advice you can give!

      P.S. I’m new to posting in the forum…I wanted to apply italics to some of the words in my post, but the BB and HTML tags don’t seem to work…any ideas how to apply formatting to these forum posts? Thanks!

    • #93708

      If you want help, give real samples!

      (^/)

    • #93716
      David Blatner
      Keymaster

      Tom, basic html tags like em and strong should work… no?

      My concern with your request is the word “sometimes” and the phrase “in certain cases.” GREP is a set of rules that always applies. But if you want a character style applied to all your parentheses, you can just type \( for one GREP style, and then do another GREP style right after it applying the same character style to \)

      That just means “apply it to the left paren and then the right paren.” You need the backslash before the parenthesis because the ( is a reserved character, and the backslash “escapes” it.

    • #93718

      Hi David,
      That’s what I’ve called a “back door”!
      Don’t search it! I’ve Invented the concept! =D
      You use a “global” grep style but sometimes you don’t want it to be applied!
      So, you include into it a “back door”!

      (^/)

    • #93891

      Thanks, gentlemen, for your responses! Sorry I’ve been away for a while ?? busy time of year!

      You’re right, real examples would be most helpful. Obi?Tom, I’m afraid I don’t understand your advice…apologies.

      David, by “sometimes” and “in certain cases”, I mean that not every paragraph has need for the exceptions (i.e. not every paragraph has a + in it). But the example below will help clarify that. Let me apologize already for the long example; it’s a very complicated project, but one I face multiple times each year (often one or more times per month). I’m just hoping to include whatever information might be useful to help find a fix. In the example that follows, real?text examples are preceded by >> , and comments follow after a } . The rest is explanation. Fasten your seat belts, it’s going to be a bumpy ride!

      The Example:
      1. The Document. The document is long(ish), around 20 pages, but containing nearly 500 paragraphs. It has a slew of object, table, cell, paragraph, and character styles applying to the various parts of the document: title, subtitle, heading 1, heading 2, page numbers, running headers, body text, etc. The document is also trilingual, containing text in Latin, Dutch, and English, which alternate, but inconsistently (i.e. not every other line, but more or less by section, yet the English is throughout and the Latin is peppered in specific places).

      2. The Context. The “body text” contains three sub?styles: “rubric” (10pt, Roman, red), “priest” (14pt, bold, black), and “people” (13pt, Roman, black). Because these paragraphs also alternate inconsistently, and sometimes overlap (see start of section 3, below), I have to either manually apply three different paragraph styles to each paragraph throughout the 500-paragraph document, or use a GREP to apply them automatically as character styles.

      I took the latter approach, achieved by setting the body text to “rubric” (it occurs most frequently), and then tagging the “priest” paragraphs with # and the “people” paragraphs with @. I subsequently used GREP to apply a “hidden” character style to the # and @ (i.e. minuscule font size and kerning, no color…):
      >> (?<=#).+   } applies “priest” style
      >> (?<=@).+   } applies “people” style
      >> #|@     } applies “hidden” style

      Moreover, I have to manually apply language character styles to each paragraph that’s not in English, so any other style which needs to apply to that paragraph has to be done by GREP. (From what I’ve figured out so far, it’s not possible to manually apply multiple character styles to the same text, but maybe I’m wrong.) You can already start to see the problem: with 500 paragraphs, it takes a long time to apply just language character styles to everything.

      3. The First Problem.
       A. Periodically, within “priest” or “people”, there are little bits that need to have “rubric” applied:
      >> The Priest, extending his hands, says:     } this whole line is rubric style
      >> De Heer zij met u. (of: De Heer zal bij u zijn.)    } “De Heer zij met u.” is priest, “(of:” is
      >>             rubric, “De Heer zal bij u zijn.” is
      >>             priest, “)” is rubric
      >> The people reply: En met uw geest. (of: De Heer zal u bewarren.)  } “The people reply:” is rubric, “En met uw
      >>             geest” is people, “(of:” is rubric, “De
      >>             Heer zal u bewarren.” is people, “)” is
      >>             rubric.

      Take the last line for example: this pattern repeats somewhat predictably. So I could already start by applying rubric to the paragraph, and use GREP style:
      >> (?<=.+:).+   } I know the problem of using the . wildcard
      >>       in a look behind, but I’m not sure what
      >>       alternatives there are; anyway, it serves
      >>       here as a quick example.

      This GREP would then apply “people” to the rest of the entire line, which is fine if it’s just “The people say: Amen.”, but doesn’t work when there is another option.

      In order to clarify what I want to do, I will “invent” a GREP notation for “exclude/except”, which I will indicate by enclosing the exclusion/exception in <angle brackets>. So, applying my exclusion rule to the preceding example:
      >> (?<=.+:).+<((of:<.+>))|((or:<.+>))>

      Thus it would read: ‘look for any string of one or more characters followed by a colon and any white space; after it, apply the style to any character which appears, except for the strings “(of:)” and “(or:)”; but any characters contained after the colon and before the close?parenthesis within the sets “(of:)” and “(or:)” are excluded from the exclusion, thus the style is applied also to these strings.’

       B. And here’s the catch. Sometimes, particularly in the “priest” paragraphs, there are “legitimate” parentheses, i.e. parentheses that are part of the text, and not an indication of an instruction. For example, in a passage from the Gospel, which would have the style “priest” applied to it, there might be the text:
      >> Thomas, called Didymus (which means “twin”), …

      In this case, the ( ) need to remain in the “priest” style, and not have “rubric” applied. So I can’t just make a GREP to apply “rubric” indiscriminately to all parentheses. I need to make the GREP more specific.

       C. Worse yet, there are some occasions where the parentheses need the “rubric” style, but don’t contain the indicator “of:” or “or:” (“of”, by the way, is Dutch for “or”). Fortunately, there are only two general scenarios where this occurs, and I think they’d both be easy to solve.

        (i.) In one scenario, the priest is speaking to or about a person who may be a male or a female, or singular or plural, so the text might say:
      >> Walk always as a child (as children) of the light …

      or
      >> Send your Holy Spirit upon him (her/them)
      >> to be his (her/their) helper and guide.

        (ii.) The other scenario is that the parenthetical is its own paragraph:
      >> by your protecting help.
      >> (Through Christ our Lord. Amen.)

      So, these examples are predictable enough that a GREP could easily just contain a set of possibilities of what might be contained in or around the parentheses, which could be set either as a look behind/ahead or an exclusion.

      I know…it’s complex. But hold on to your hats, there’s the second problem…

      4. The Second Problem. Within the priest’s part, there is sometimes found a + symbol, indicating the Priest makes the Sign of the Cross, for example:
      >> And may almighty God bless you,
      >> the Father, and the Son, + and the Holy Spirit.

      Now, all of the surrounding text is bold. But the typeface (called “liturgy”) for the + does not have boldface. I have a separate character style (called “liturgy”) which sets the appropriate typeface with Roman font, and in the paragraph style, I have the two GREP styles:
      >> (?<=#).+   } applies “priest”
      >> \+     } applies “liturgy”

      However, ID still tries to apply the font “liturgy bold” to the +, and I get preflight errors, and warnings of missing fonts when I open the document. I have tried to manually change it, I have tried to reorder the GREP styles for precedence, all to no avail. (Note: when I apply “rubric”, which has Roman font, it successfully overrides the bold font of the “priest” style; but when I apply “liturgy”, it does not override the bold font, although it does override the typeface.) So, using the exclusion/exception principle from above, I would want the GREP to look like this:
      >> (?<=#).+<\+>
      >> \+

      So the first GREP style applies “priest” to everything in a paragraph preceded by #, but does not apply “priest” to any + symbol in that paragraph. Instead, it applies “liturgy” to the + symbol.

      5. The Conclusion. Thanks for bearing with me in this long example. (You can see why I didn’t put an example in the question to begin with!) I realize it’s quite complex. Of course, there’s an obvious work?around: just create a different paragraph style for “Priest?NL”, “Priest?EN”, “Priest?LT”, and the same for “People?…” But with a long, 500?paragraph document, it takes a good 3-4 days of solid work to get the whole thing laid out appropriately.

      Without expanding into too many irrelevant details, I’ll just mention that the document also includes other “special” fonts and respective styles, such as Gregorian chant font notation, which requires not only inputting the notation, but also aligning the lyrics (but that’s for a different thread); I can only have page turns in specific places, like when the priest isn’t holding something; I have tables that provide language options for things the Priest says quietly, so he can use the language most comfortable to him; etc. etc. etc. So it’s a very complex and involved document already.

      Thus, any automation greatly improves my productivity and decreases the amount of time I have to spend preparing the document.

      Fear not, of course, these complications do not deter me in the slightest from InDesign. I’ve been using ID for 3 years now, and I absolutely love it. I love learning about it, and I am continually trying to hone my skills. I’m not a graphic designer; I’m just a graduate student in canon law volunteering at the local English?speaking parish (that’s right, I don’t get paid for doing this, either), but it’s become one of my favorite hobbies.

      I thank you once again for your very kind help and for your patience reading through the long examples. I hope they provide the needed context to help you experts help me, an amateur. You’re the best! Thanks!

      • #93894

        P.S. I managed to get some of the spacing fixed…didn’t realize it would delete all the extra spaces, so I had to put in em spaces. Which clarified the other issue, indeed, David, it seems the forum uses HTML 4.0. :)
        I also noticed that it didn’t like the no-break hyphens my keyboard automatically inserts, and replaced them all with ?’s. So…if it seems there’s a ? in a strange place, it probably should be a -. Unfortunately, after the second edit, the forum won’t let me go back in to change that.

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