Hyphenopoly

Hyphenation for node and Polyfill for client-side hyphenation.

View the Project on GitHub mnater/Hyphenopoly

Hyphenation errors

Automatic hyphenation can not be error-free! Because …

In any case, automatic hyphenation needs proofreading and may need some intervention.

Proofread

Use a visible hyphen character to display all hyphen opportunities:

Hyphenopoly.config({
    require: [...],
    setup: {
        selectors: {
            ".hyphenate": {
                hyphen: ""
            }
        }
    }
});

See also Setup#hyphen

Fix hyphenation

There are three levels of fixing possibilities:

  1. Directly in the text
  2. Defining hyphenation exceptions for Hyphenopoly
  3. Improve patterns

Fix hyphenation in the text

Words containing a soft hyphen (­) will not be hyphenated by Hyphenopoly.js. Therefore, you can simply add soft hyphens manually to ‘overwrite’ automatic hyphenation.

pro:

contra:

Define hyphenation exceptions.

Hyphenopoly.js has an API for hyphenation exceptions:

Hyphenopoly.config({
    require: {...},
    setup: {
        exceptions: {
            "en-us": "desert, dic-tion-ary, dic-tion-aries, blog-o-sphere" //language-specific exceptions
        },
        selectors: {...}
    }
});

In the example above, Hyphenopoly.js will never hyphenate the word “desert” and will hyphenate the words “dictionary”, “dictionaries” and “blogosphere” at the positions marked with a hyphen-minus. Exceptions are case-sensitive. The example above will not work for capitalized words (e.g. “Desert”).

pro:

contra:

Help to improve the patterns

Go to http://www.hyphenation.org/ and help to improve the patterns.

pro:

contra:

As an intermediate step to improved patterns, Hyphenopoly has the ability to include exceptions in the wasm-file. Feel free to open an issue if you have a good list of exceptions for a language.