0 Replies Latest reply on Jun 5, 2015 4:00 PM by joshualangman

    Needed: script or GREP search to standardize dash spacing

    joshualangman

      Hi InDesign community!

       

      When typesetting novels, I frequently need to go through and manually standardize the spacing of em dashes within the text. Wondering to what extent this can be automated either with a script or with a GREP find/replace. I want either a script or GREP search that can be run on the entire document and produce the following results:

       

      ———

       

      If an em-dash occurs in the middle of sentence, between two words, add a normal word space on both sides of the dash.

      (Example: I like cake — it’s delicious.)

       

      If an em-dash is preceded by an opening quotation mark, or followed by a closing quotation mark, do NOT put a space between the dash and the quote mark. (Applies to both single and double quotes.)

      (Example: “What the —”)

       

      If an em-dash is preceded by a closing quotation mark, or followed by an opening quotation mark, DO put a space between the dash and the quote mark. (Applies to both single and double quotes.)

      (Example: “How” — she paused for emphasis — “did you find me?”)

       

      Put a space between an em-dash and any other adjacent punctuation mark.

      (Example: I saw the cake — did you see it? — before the party.)

       

      If the word prior to the em-dash is the last word in the paragraph, then the space before the dash must be a nonbreaking space.

       

      If the word prior to the em-dash is the last word before a closing quotation mark, then the space before the dash must be a nonbreaking space.

       

      If the em-dash is immediately preceded by an opening quotation mark, then the space after the dash must be a nonbreaking space.

       

      The script must account for the fact that some dashes may already be spaced correctly, or partially correctly, and some may not. (Though it’s highly unlikely that nonbreaking spaces will already be present in the text.)

       

      ———

       

      Many thanks in advance to anyone who wishes to help me put something together.

       

      Thanks,

       

      Josh