hyphen-minified v1.6.8

hyphen
Forked version: Creates minified versions of the files used in the npm package
This is a text hyphenation library, based on Franklin M. Liang's hyphenation algorithm. In core of the algorithm lies a set of hyphenation patterns. They are extracted from hand-hyphenated dictionaries. Patterns for this library were taken from ctan.org and ported to Javascript.
import { hyphenate } from "hyphen/en";
hyphenate("A certain king had a beautiful garden").then(result => {
// A cer[-]tain king had a beau[-]ti[-]ful garden
// [-] is soft hyphen
});Install
npm install hyphenor
yarn add hyphenUsage
import {
hyphenate,
hyphenateHTML,
hyphenateHTMLSync,
hyphenateSync
} from "hyphen/en";
hyphenate("Plain text - hyphenate everything").then(result => {
// Plain text - hy[-]phen[-]ate every[-]thing
});
hyphenateHTML("<blockquote>HTML tags are NOT hyphenated</blockquote>").then(
result => {
// <blockquote>HTML tags are NOT hy[-]phen[-]at[-]ed</blockquote>
}
);
hyphenateHTMLSync("<blockquote>Sync version of `hyphenateHTML`</blockquote>");
// <blockquote>Sync ver[-]sion of `hy[-]phen[-]ate[-]HTML`</blockquote>
hyphenateSync("Sync version of `hyphenate`");
// Sync ver[-]sion of `hy[-]phen[-]ate`Options
hyphenate("Options", { debug: true, hyphenChar: "%", minWordLength: 5 });
// Op%tionsdebug
A
Booleanindicating, if script should output debug info to console. Default isfalse.hyphenChar
A
Stringsets a value of the soft hyphen character. Default value is\u00AD.minWordLength
A
Numbersets the minimum length of the word, intended for hyphenation. Default value is5.
Import available languages
hyphen/afAfrikaanshyphen/asAssamesehyphen/beBelarusianhyphen/bgBulgarianhyphen/bnBengalihyphen/caCatalanhyphen/copCoptichyphen/csCzechhyphen/cuChurch Slavonichyphen/cyWelshhyphen/daDanishhyphen/de-1901German, traditional spellinghyphen/de-1996German, reformed spellinghyphen/de-CH-1901German, traditional Swiss spellinghyphen/dealiaseshyphen/de-1996hyphen/el-monotonModern Greek, monotonic spellinghyphen/el-polytonModern Greek, polytonic spellinghyphen/elaliaseshyphen/el-monotonhyphen/en-gbEnglish, British spellinghyphen/en-usEnglish, American spellinghyphen/enaliaseshyphen/en-ushyphen/esSpanishhyphen/etEstonianhyphen/ethialiaseshyphen/mul-ethihyphen/euBasquehyphen/fiFinnishhyphen/frFrenchhyphen/furFriulanhyphen/gaIrishhyphen/glGalicianhyphen/grcAncient Greekhyphen/guGujaratihyphen/hiHindihyphen/hrCroatianhyphen/hsbUpper Sorbianhyphen/huHungarianhyphen/hyArmenianhyphen/iaInterlinguahyphen/idBahasa Indonesia, Indonesianhyphen/isIcelandichyphen/itItalianhyphen/kaGeorgianhyphen/kmrKurmanji, Northern Kurdishhyphen/knKannadahyphen/la-x-classicClassical Latinhyphen/la-x-liturgicLiturgical Latinhyphen/laLatinhyphen/ltLithuanianhyphen/lvLatvianhyphen/mlMalayalamhyphen/mn-cyrl-x-lmcMongolian, Cyrillic script, alternative patternshyphen/mn-cyrlMongolian, Cyrillic scripthyphen/mnaliaseshyphen/mn-cyrlhyphen/mrMarathihyphen/mul-ethiMultiple languages using the Ethiopic scriptshyphen/nbNorwegian Bokmål, bokmål, norsk bokmålhyphen/nlDutchhyphen/nnNorwegian Nynorsk, nynorskhyphen/noNorwegian, norskhyphen/ocOccitanhyphen/orOdia, Oriyahyphen/paPanjabi, Punjabihyphen/piPālihyphen/plPolishhyphen/pmsPiedmontesehyphen/ptPortuguesehyphen/rmRomanshhyphen/roRomanianhyphen/ruRussianhyphen/saSanskrithyphen/sh-cyrlSerbocroatian, Cyrillic scripthyphen/sh-latnSerbocroatian, Latin scripthyphen/shaliaseshyphen/sh-cyrlhyphen/skSlovakhyphen/slSlovenianhyphen/sr-cyrlSerbian, Cyrillic scripthyphen/sraliaseshyphen/sr-cyrlhyphen/svSwedishhyphen/taTamilhyphen/teTeluguhyphen/thThaihyphen/tkTurkmenhyphen/trTurkishhyphen/ukUkrainianhyphen/zh-latn-pinyinMandarin Chinese, pinyin transliterationhyphen/zhaliaseshyphen/zh-latn-pinyin
Factory function
import createHyphenator from "hyphen";
import patterns from "hyphen/patterns/en-us";
const hyphenate = createHyphenator(patterns, { async: true });
const hyphenateHTML = createHyphenator(patterns, { async: true, html: true });
const hyphenateHTMLSync = createHyphenator(patterns, { html: true });
const hyphenateSync = createHyphenator(patterns);Note: This original factory function surves mostly for the backwards compatibility reasons.
Text hyphenation in CSS
The CSS hyphens property is intended to add hyphenation support to modern browsers without Javascript:
p {
hyphens: auto;
}It is part of the CSS Text Level 3 specification. The browser compatibility list can be found on the related MDN page.
Alternatives
Check other great hyphenation libraries:
- Hyphenator.js does client-side hyphenation of HTML-Documents.
- Hypher A fast and small hyphenation engine.