Skip to content

parse German text to add soft-hyphens in HTML or Unicode

License

Notifications You must be signed in to change notification settings

blurrryy/hyphe-lib-ger

Repository files navigation

hyphe-lib-ger.js

npm version Build Status

Add soft-hyphens to German text

CHANGELOG

About

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

Install

In your terminal use

npm i --save hyphe-lib-ger

In your JavaScript file use

const hyphe = require("hyphe-lib-ger");

Usage

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)

Options

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

Example

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”
*/

Example

A working example with this lib and Angular6 is seen here