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

Use GREP to apply Paragraph Style X when text is between Paragraph Style Y and Z

Return to Member Forum

  • Author
    Posts
    • #77164
      Anonymous
      Inactive

      I am converting several cookbooks from Word to epub, and I am bringing all of the data into InDesign. I want to apply bullets to all of the ingredients lists (which the authors did not do beforehand).

      So I have created a paragraph style for “Ingredients”. This is then followed by the ingredient list, and I created a paragraph style for it called “Ingredient List”. Immediately after the ingredient list is the “Instructions” set of text.

      How can I tell it to find all of the text between Paragraph Style “Ingredients” and Paragraph Style “Instructions” and make it Paragraph Style “Ingredient List”?

      TIA.

    • #77168
      David Blatner
      Keymaster

      Sorry, there’s no easy way to do that built in to InDesign. I generally recommend assigning paragraph styles and doing clean up in Word before placing into InDesign.

    • #77170
      Anonymous
      Inactive

      Thank you for your fast response. I appreciate all you do to make this site so awesome. And at least now I what I can’t do and can now go focus on what I can do, lol. I love the GREP utility.

    • #77179
      Ariel Walden
      Member
    • #77231
      Anonymous
      Inactive

      Thanks, Ariel.

      Would this work for multiple paragraphs between paragraph styles? Like for the cookbooks, I will have the following (^b stands for standard carriage return)

      Ingredients (^b) (Paragraph Style applied)

      ingredient 1(^b)
      ingredient 2(^b)
      ingredient 3(^b)

      Directions(^b) (Paragraph Style applied)

      So I would need my “ingredient list” paragraph style applied to all three lines between “ingredients” and “directions”.

      Thanks

    • #77312
      Masood Ahmad
      Participant

      Is there any specific pattern of the Ingredients List? It might help to understand the text and discover something for you.

    • #83362
      Anonymous
      Inactive

      There is never a pattern, since some recipes call for 10 ingredients and some call for 5. The only pattern is that the word “Ingredients” comes before the Ingredient list starts and then “Directions”.

      Ingredients (paragraph style X)

      Ing. #1
      Ing. #2
      Ing. #3

      Directions (paragraph style)

    • #83416
      Peter Kahrel
      Participant

      A GREP expression can match things in one style only: you can’t specify different styles for a search. But if your ingredients lists are always preceded by the word ‘Ingredients’ and followed by the word ‘Directions’, then you can use this GREP to apply your ingredients style:

      Find what: (?s)(?<=Ingredients\r).+?(?=\rDirections)
      Change to: <Leave empty>
      Change format: <ingredients style>

      (?s) // Consider the text as a single line so that . matches \r
      (?<=Ingredients\r) // Match Ingredients and the following return
      .+? // Math up to . . .
      (?=\rDirections) // a return followed by Directions

      This expression matches any paragraphs between Ingredients and Directions. The \r characters (paragraph breaks) must be part of the lookaround to avoid applying the ingredients paragraph style to the Ingredients and Directions headings.

      Peter

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