Apply Hyphenation Corrections

This one runs in conjunction with the previous one to apply to the document or to the exception dictionary and changes you make in the collected words.

This script is part of the Word Division/Hyphenation collection. See the full collection here

This script is part of the Type and Text collection. See the full collection here

I use this script to batch-correct hyphenation errors in a document and/or add words with correct break points to the exception list. My starting point is a list of all hyphenated words in a document, created by the Get Hyphens script.

The list in the screenshot below is the result of deleting all correctly hyphenated words. So I’m left with a list of words, some of which need to be corrected in the document, other should be added to the exception list. 

hyphenation apply

I make this distinction because I don’t want all words to appear in the exception list. For example, the first four and the sixth words are hyphenated with permanent hyphens, and there’s no point adding these to the exception list. There’s authenti~cally, which is wrong, and this one I would like to send to the exception list. Of the last two, difficult-to-define, like the first four, has permanent hyphens and should not be otherwise divided (and not be included in the exception list), and embourgeo~isment is wrong but I don’t want it in the list.

To tell the script what to do, mark words with wrong or undesirable hyphenation as follows. Words preceded by % will be corrected only in the document, they’re not added to the exception list; if a word is not preceded by %, it is added to the exception list (and therefore all its occurrences in the document will be corrected automatically).

In either case you need to indicate all the correct hyphenation points. You do this using the same method as used in the dictionary dialog: indicate correct hyphenation points with a swung dash (~). You can prevent a word from being broken by prefixing it with a swung dash. In the following screenshot, the above list is corrected:

hyphenation correction

In the first entry, %anti-~imperial, % shows that I don’t want to add the word in the exception list. I also indicated that the second part of the compound, imperial, should not be hyphenated by preceding it with a ~. The next three items are similar in that they are compounds whose members should not be broken.

The next item, authentically, should be included in the exception list. All correct hyphenation points are indicated by swung dashes. The one-but-last item is again a compound whose parts should not be broken. And the last word, embourgeoisment, I don’t want in the list so I prefixed it with % and marked the correct break points.

Catch

Naturally, changing the division of some words may cause their containing paragraphs to reflow and lead to other hyphenations, which could lead to other errors. However, in my experience so far this hardly ever happens, but it should be borne in mind.

Use

To use the script, make sure the corrected list is the active document and that the document to which the corrections are to be applied is open as well. Then run it.

The script tries to determine which language is set in the document (it can’t deal with multiple languages) and preselects that in a dialog in which you can select a different language. What you choose here determines which exception dictionary is used. Press Enter/Return or OK to start the script.

Apply hyphens and word division

Peter Kahrel Script Repository
Hosted as a community service, and with deep appreciation, by CreativePro.com


Scripts by Topic | Script Index
Basic Script Installation and Use
How to Modify or Configure These Scripts
Resources for Scripting and Publishing Automation
About This Repository


Repository Home Page


Contact Peter Kahrel


Note to users: You run scripts at your own risk: CreativePro and the author accept no liability for anything that may be caused by any of these scripts. Always take the necessary precautions. We encourage you to save backups and test scripts on copies of your documents.

Bookmark
Please login to bookmark Close

This article was last modified on August 22, 2026

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading comments...