Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
This is a 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
});
Check a demo
npm install hyphen
or
yarn add hyphen
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`
hyphenate("Options", { debug: true, hyphenChar: "%" });
// Op%tions
debug
A Boolean
indicating, if script should output debug info to console. Default is false
.
hyphenChar
A String
sets a value of the soft hyphen character. Default value is \u00AD
.
hyphen/af
- Afrikaanshyphen/as
- Assamesehyphen/be
- Belarusianhyphen/bg
- Bulgarianhyphen/bn
- Bengalihyphen/ca
- Catalanhyphen/cop
- Coptichyphen/cs
- Czechhyphen/cu
- Church Slavonichyphen/cy
- Welshhyphen/da
- Danishhyphen/de-1901
- German, traditional spellinghyphen/de-1996
- German, reformed spellinghyphen/de-CH-1901
- German, traditional Swiss spellinghyphen/de
- Alias for de-1996hyphen/el-monoton
- Modern Greek, monotonic spellinghyphen/el-polyton
- Modern Greek, polytonic spellinghyphen/el
- Alias for el-monotonhyphen/en-gb
- English, British spellinghyphen/en-us
- English, American spellinghyphen/en
- Alias for en-ushyphen/es
- Spanishhyphen/et
- Estonianhyphen/ethi
- Alias for mul-ethihyphen/eu
- Basquehyphen/fi
- Finnishhyphen/fr
- Frenchhyphen/fur
- Friulanhyphen/ga
- Irishhyphen/gl
- Galicianhyphen/grc
- Ancient Greekhyphen/gu
- Gujaratihyphen/hi
- Hindihyphen/hr
- Croatianhyphen/hsb
- Upper Sorbianhyphen/hu
- Hungarianhyphen/hy
- Armenianhyphen/ia
- Interlinguahyphen/id
- Bahasa Indonesia, Indonesianhyphen/is
- Icelandichyphen/it
- Italianhyphen/ka
- Georgianhyphen/kmr
- Kurmanji, Northern Kurdishhyphen/kn
- Kannadahyphen/la-x-classic
- Classical Latinhyphen/la-x-liturgic
- Liturgical Latinhyphen/la
- Latinhyphen/lt
- Lithuanianhyphen/lv
- Latvianhyphen/ml
- Malayalamhyphen/mn-cyrl-x-lmc
- Mongolian, Cyrillic script, alternative patternshyphen/mn-cyrl
- Mongolian, Cyrillic scripthyphen/mn
- Alias for mn-cyrlhyphen/mr
- Marathihyphen/mul-ethi
- Multiple languages using the Ethiopic scriptshyphen/nb
- Norwegian Bokmål, bokmål, norsk bokmålhyphen/nl
- Dutchhyphen/nn
- Norwegian Nynorsk, nynorskhyphen/no
- Norwegian, norskhyphen/oc
- Occitanhyphen/or
- Odia, Oriyahyphen/pa
- Panjabi, Punjabihyphen/pi
- Pālihyphen/pl
- Polishhyphen/pms
- Piedmontesehyphen/pt
- Portuguesehyphen/rm
- Romanshhyphen/ro
- Romanianhyphen/ru
- Russianhyphen/sa
- Sanskrithyphen/sh-cyrl
- Serbocroatian, Cyrillic scripthyphen/sh-latn
- Serbocroatian, Latin scripthyphen/sh
- Alias for sh-cyrlhyphen/sk
- Slovakhyphen/sl
- Slovenianhyphen/sr-cyrl
- Serbian, Cyrillic scripthyphen/sr
- Alias for sr-cyrlhyphen/sv
- Swedishhyphen/ta
- Tamilhyphen/te
- Teluguhyphen/th
- Thaihyphen/tk
- Turkmenhyphen/tr
- Turkishhyphen/uk
- Ukrainianhyphen/zh-latn-pinyin
- Mandarin Chinese, pinyin transliterationhyphen/zh
- Alias for zh-latn-pinyinimport 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 compatibility with dependers code base
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.
Check other great hyphenation libraries:
ISC
FAQs
Text hyphenation in Javascript.
The npm package hyphen receives a total of 522,178 weekly downloads. As such, hyphen popularity was classified as popular.
We found that hyphen demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.