Hey folks,
So I’ve been trying to figure out how to find instances of double hyphenations (e.g., double-hyph-enation) and other bad auto-hyphens (e.g., double/hyph-enation, double“hyph-enation, double”hyph-enation).
I pulled a script from this forum (http://bbs.macscripter.net/viewtopic.php?id=21293) and massaged it down a little bit to find the first two examples above and color them green. My code is:
tell application "Adobe InDesign CS3"
activate
set storynumber to count document 1 each story
set lineNumber to {}
repeat with m from 1 to storynumber
set end of lineNumber to count story m of document 1 each line
end repeat
tell document 1
set mySwatch to swatch "Green"
repeat with n from 1 to storynumber
tell story n
repeat with i from 1 to item n of lineNumber
if length of line i is greater than 1 then
tell line i
set lastword to last word
set firstword to first word
set lastChar to last character
set firstChar to first character
set verifBaseline to ((baseline of first character of last word) is not (baseline of last character of last word))
set verifHyphen to (characters of lastword contains "-") and (lastChar is not "-")
set verifSlash to (characters of lastword contains "/") and (lastChar is not "/")
if (verifHyphen and verifBaseline) or (verifSlash and verifBaseline) then
set selection of application "Adobe InDesign CS3" to last word
select (last word)
tell (last word) to set fill color to mySwatch
end if
end tell
end if
end repeat
end tell
end repeat
end tell
end tell
Now, I can’t figure out how to make it detect the other two examples above (the en and em dash instances). The problem is that the dashes aren’t considered part of the word, so the [characters of lastword] lines don’t work on them. Is there any way to include them somehow? Basically I need to tell it to (A) find the words that start on one line and end on another, then (B) determine if the previous or next character is an en or em dash, and then color it. But I just can’t figure out the syntax to make it do this.
Any ideas? Thanks so much! Oh and by the way, I’m pretty much nubcake at Applescript, so forgive me if this is a stupidly easy (or stupidly impossible O_O) request.