Skip to content

Latest commit

 

History

History

hyphen

Lunaris Hyphen

NPM Version NPM Downloads CI Status

A hyphenation library based on LibreOffice dictionaries, inspired by pyphen.

Tip

See also:

Features

  • Browser & Node.js support
  • Multi-language support
  • TypeScript support

Installation

npm install @lunarisapp/hyphen

Usage

import { TextHyphen } from '@lunarisapp/hyphen';

const textHyphen = new TextHyphen({
    lang: 'en_US',  // optional, en_US by default
    left: 2,        // optional, 2 by default
    right: 2,       // optional, 2 by default
});

// Gets the textHyphenation points for a word.
// Result: [2, 6]
textHyphen.positions('hyphenation');

// Wraps a word with hyphens at the given positions.
// Result: 'hy-phenation'
textHyphen.wrap('hy-phenation', 3);

// Gets the hyphenation variants for a word.
// Result: [['hy', 'phenation'], ['hyphen', 'ation']]
textHyphen.variants('hyphenation');

// Inserts hyphens in all possible positions.
// Result: 'hy-phen-ation'
textHyphen.inserted('hyphenation');