2 Replies Latest reply on Aug 22, 2013 9:04 AM by BrendanMcBryan

    Recognizing Tables as "Not Spaces"

    BrendanMcBryan

      I've written an Indesign script the goal of which is to clean up extraneous white space in text (multiple returns to single return removes leading white space, etc.). It is essentialy a series of GREP powered Find/Change events. The script works great for the most part but I do have one problem that I cannot seem to understand how to fix and was hoping you might have some insight.

       

      Let's say I have a Paragraph(A) that is Justified Last Line Left with 1p0 Space After followed by a return and then an inline table. As Paragraph(A) has the space after property, and the Table is a new paragraph, there is space between the end of the Paragraph(A) and the table. When I run this script, it removes the paragraph return at the end of Paragraph(A) which makes the table part of Paragraph(A). As a result, there is no longer a space between Paragraph(A) and the Table and the previously last line of Paragraph(A) is now fully justified. This only seems to happen with in line tables. It seems that the script does not recognize the table as a new paragraph, but rather as "nothing" or a white space of some sort.

       

      A before and after image of the problem…


      http://i.imgur.com/mkeGtyT.jpg?1

       

      and the code…

        --REMOVE LEADEING WHITESPACE

        --Clear the find/change preferences.

                set find grep preferences to nothing

                set change grep preferences to nothing

       

        --Load Find/Change variables for Remove Leading Whitespace

                set varFind to "^ " as string

                set varChange to "" as string

                set include hidden layers of find change grep options to true

                set the find what of find grep preferences to varFind

                set the change to of change grep preferences to varChange

       

        -- Execute Multiple Space to Remove Leading Whitespace

                tell active document

                          set varFoundLeadingSpace to change grep

                end tell

        --MULTIPLE RETURN TO SINGLE RETURN

        --Clear the find/change preferences.

                set find grep preferences to nothing

                set change grep preferences to nothing

       

        --Load Find/Change variables for Multiple Return to Single Return

                set varFind to "~b~b+" as string

                set varChange to "\\r" as string

                set include hidden layers of find change grep options to true

                set the find what of find grep preferences to varFind

                set the change to of change grep preferences to varChange

       

        -- Execute Multiple Return to Single Return

                tell active document

                          set varFoundMultipleReturn to change grep

                end tell

       

        --REMOVE TRAILING WHITESPACE

        --Clear the find/change preferences.

                set find grep preferences to nothing

                set change grep preferences to nothing

       

        --Load Find/Change variables for Remove Trailing Whitespace

                set varFind to "\\s+$" as string

                set varChange to "" as string

                set include hidden layers of find change grep options to true

                set the find what of find grep preferences to varFind

                set the change to of change grep preferences to varChange

       

        -- Execute Remove Trailing Whitespace

                tell active document

                          set varFoundTrailingSpace to change grep

                end tell

       

       

      Does anyone have any suggestions as to how I can stop this from happening. I find this script to be extremely helpful, but woulde really like to not have go back and check for these problem areas in the document.