• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Hyphenation Checker

People's Champ ,
Sep 21, 2011 Sep 21, 2011

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

653

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2011 Sep 21, 2011

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 21, 2011 Sep 21, 2011

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2011 Sep 21, 2011

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines