Using the packages hypher and hyphenation.de to parse a normal, German text adding soft-hyphens to allow soft-hyphens in older browsers and Google Chrome.
New: Use typographizer-js to produce better looking typography
In your terminal use
npm i --save hyphe-lib-ger
In your JavaScript file use
const hyphe = require("hyphe-lib-ger");
hyphe(Text, { Options }).then(text => {
console.log(text); // Output the formatted text
});
Text: String A String with the text to parse
Options: Object The possible options (not required)
typographize: Boolean (default: false)
- parse the text with typograhize-js first
ignoreLineBreaks: Boolean (default: false)
- ignore line breaks completely?
escapeToHTML: Boolean (default: true)
- escape all non-word characters to their HTML charcode alternative
const hyphe = require("hyphe-lib-ger");
hyphe(
`Lass mich dir kurz vorstellen, was hier eigentlich möglich ist: "Hallo, mein Name ist Daniel"`
).then(res => {
console.log(res);
});
/*
Will return:
Lass mich dir kurz vor­stel­len, was hier ei­gent­lich mög­lich ist: “Hal­lo, mein Na­me ist Da­ni­el”
*/
A working example with this lib and Angular6 is seen here