3 Replies Latest reply on Sep 21, 2011 11:39 PM by Peter Kahrel

    Hyphenation Checker

    TᴀW Adobe Community Professional & MVP

      I've been trying to understand Teus de Jong and Peter Kahrel's brilliant, quick hyphenation checker script.

      The crux of the script appears to be this line:

       

      return "- \u2013\u00AD\u05BE\r\n/".indexOf(s.slice (-1)) < 0;

       

      which evaluates to TRUE if the last character of the line is not one of the ones in the list, since by implication that would mean that presumably the last word is broken in the middle -- hence, hyphenated.

       

      Just one tiny point: InDesign will break a line after a @ sign without adding a hyphen, so the script gets a false result with a line ending in @. The answer would be just to add @ to the list, I guess.

       

      Thanks, amazing script...

      Ariel

        • 1. Re: Hyphenation Checker
          [Jongware] Most Valuable Participant

          Arïel wrote:

           

          .. Just one tiny point: InDesign will break a line after a @ sign without adding a hyphen, so the script gets a false result with a line ending in @.

           

          Gosh. So it does! Not a day goes by without some unexpected behavior from our favourite desktop software

           

          It seems Teus & Peter check each character where ID would have broken a word by itself (the code \u00AD, for example, is the manually inserted discretionary hyphen).

           

          This quickee seems to work for one-offs:

           

          alert (app.selection[0].words[-1].lines.length);

           

          but I have no idea about its performance in the long run.

          • 2. Re: Hyphenation Checker
            TᴀW Adobe Community Professional & MVP
            • 3. Re: Hyphenation Checker
              Peter Kahrel Adobe Community Professional & MVP

              Ariel -- Yes, that's right: if a line does not end in one of the characters in the list, then that line end in a broken word. Lines that do not end in a broken word have a space at the end (or a \00AD. \r, etc.). To count lines ending in @ as non-broken, indeed just add @ to the list.

               

              Jongware: You could make the script work with app.selection[0].words[-1].lines.length, and we tried that for a comparison. It's unbelievably slow in large texts.

               

              Peter