Copy link to clipboard
Copied
To visually control the quantity of hyphenated words in a page, seems appropriated to mark them ( like using some script, similar to that created by H. Jong, where beautifully all hyphenated words are coloured with a red ink?)
The markup to identify them, as the tilde ^~ does not capture them?
Copy link to clipboard
Copied
Your question is not clear to me. What are you asking for? Please try to give an example.
Copy link to clipboard
Copied
Automatic hyphens are dynamic and not glyphs that can be selected (unlike hyphens you type). As far as I know there's nothing you can do to highlight them.
Are the hyphenation controls available in the Hyphenation Settings dialog not sufficient to control the number of hyphens on your pages?
Copy link to clipboard
Copied
I am [almost] sure Jong's script does that...
Also Indiscript has a similar one to mark hyphenated words, including location!
Thank you.
Jong:
try {
app.activeDocument.colors.add({name:"Warning", space:ColorSpace.RGB, colorValue:[255,0,0]});
} catch(_) { }
warningColor = app.activeDocument.swatches.item("Warning");
t = app.selection[0].parentStory.textContainers;
p = 0;
err = 0;
while (p < t.length)
{
if (t
.lines.length)
{
if (t
.lines[0].words.length && t
.lines[0].words[-1].lines.length > 1)
t
.lines[0].fillColor = "Warning", err++;
if (t
.lines[-1].words.length && t
.lines[-1].words[-1].lines.length > 1)
t
.lines[-1].fillColor = "Warning", err++;
}
p++;
}
alert ("Done, marked "+err+" occurrences");
Copy link to clipboard
Copied
Let's see what happens when you run that script...
It changes the color of the entire line in which the hyphen occurs. That's quite different from highlighting just the hyphen itself. You might be able to highlight just the hyphenated words, too, but as I said, I don't think it's possible to isolate the hyphen itself since it isn't a "real" glyph, but I could be wrong.
Presumably, too, you also want this highlight to be dynamic, and to be non-printing? Again, I don't think that's something that can be done in the current iterations of ID. You might want to file a feature request to add hyphens to the list of things that can be highlighted in the composition section of the prefs.
Copy link to clipboard
Copied
Peter,
in Jong-Indiscript-Marc's scripts the idea is check the composition.
Here, the same. Detect automatic hyphens. (highlight, mark, see...)
The scripts already mentioned changes the colour in order to detect them.
Later this «warning» colour is converted to black and voilá!
But those scripts konw how to detect an automatic hyphen, something not visible for the straight user.
How to ?:
You might be able to highlight just the hyphenated
Copy link to clipboard
Copied
I don't claim to understand exactly what that script does, but I don't think it is really detecting hyphens, per se. It looks to me like it's checking word counts and using a discrepency to deduce that there is a word that appears in two different lines at the same time, and thus it must be hyphenated.
And of course this is not a dynamic highlight. Once you run the script, that text is highlighted until you remove the highlight, even if you edit and remove the hyphen (which may create a new, un-highlted hyphen elsewhere). This does not strike me as a useful method. A GREP style that could identify an automatic hyphen would be useful, but I don't think that's possible.
Copy link to clipboard
Copied
Hello,
I am trying this script in new InDesign CC 2019 text and it does nothing, gives back 0 results.
What syntax may have changed, please?
Thanks in advance.
Copy link to clipboard
Copied
This discussion seems better to fit in the InDesign Scripting forum. I'm moving it there.
Copy link to clipboard
Copied
Thanks Steve.
Copy link to clipboard
Copied
Hi Federico,
just tested the code from reply 3 with my German InDesign CC 2019 on Windows 10.
Selected a text frame and ran the script. It's still working as expected. Also tested with CC 2018.1. No issues found.
Did you select a text frame before running the script?
Does the story of the text frame contain any hyphenated text?
Regards,
Uwe