1 Reply Latest reply on Jan 21, 2012 7:10 AM by richardh6

    Help with script to apply next style

    hmdonald

      Hello,

       

      I'm new to javascripting, but think it could really save my sanity.  I have many large documents that I'm importing into InDesign.  I'd like to automate style application so it's not such and enormous mind numbing task.

       

      Here's the gist of what I want to do for the entire document:

       

      IF text equals "***"

      {

      apply paragraph style "scene_change"

      apply on the next paragraph, style "first_paragraph"

      }

       

      ELSE IF paragraph style equals "heading" OR "spacebreak"

      {

      apply on the next paragraph, style "first_paragraph"

      }

       

      ELSE IF paragraph style equals "first_paragraph"

      {

      apply on the next paragraph, style "body"

      }

       

      I tried using the next style option, but it doesn't apply to present text.

       

      Could someone help me create this code?  Thanks so much!

        • 1. Re: Help with script to apply next style
          richardh6 Level 1

          If I were you I would separate this into two tasks.

           

          1. Go through and find all text that is "***", and change the style of its paragraphs to "scene_change".

           

          2. Go through all the paragraphs, one by one, from the beginning to the end (don't go from the end to the beginning, which is often a good idea but not in this case because you'll want to be able to identify newly-styled "first_paragraph" paragraphs and change the following ones into "body"), and do this:

           

          a. if paragraph style is "heading", "spacebreak" or "scene_change", then apply "first_paragraph" style on the next paragraph.

          b. if paragraph style is "first_paragraph", then apply "body" style on the next paragraph.