Hyphenation for node and Polyfill for client-side hyphenation.
Automatic hyphenation can not be error-free! Because …
desert (arid land) -> des‧ert
desert (to leave) -> de‧sert
In some patterns, this is solved by not hyphenating ambiguous words at all.
blogosphere -> blog·o·sphere (Merriam webster)
// bl‧o‧gos‧phere (en-us patterns)
// blo‧go‧sphere (en-gb patterns)
dictionary -> dic‧tion‧ary (Wiktionary)
// dic·tio·nary (Merriam-Webster)
… the patterns differ in quality. Some are very new and reflect the current state of the language, others are older. Some are based on a very large list of words, others are crafted by hand (which is not necessarily bad).
en-us
patterns will not be able to correctly hyphenate a word that contains a character outside of the range [a-z]
(Hyphenopoly doesn’t even try to hyphenate in this case, but rather leaves the word unchanged).In any case, automatic hyphenation needs proofreading and may need some intervention.
Use a visible hyphen character to display all hyphen opportunities:
Hyphenopoly.config({
require: [...],
setup: {
selectors: {
".hyphenate": {
hyphen: "•"
}
}
}
});
See also Setup#hyphen
There are three levels of fixing possibilities:
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:
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:
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.