The `hyphen` library provides robust text hyphenation capabilities in JavaScript, based on Franklin M. Liang's widely adopted hyphenation algorithm. It leverages pre-compiled hyphenation patterns sourced from ctan.org for various languages. Currently stable at version 1.14.1, the package is primarily feature-driven with an irregular release cadence. Key differentiators include its extensive language support via separate pattern imports (e.g., `hyphen/en`, `hyphen/de`), automatic skipping of HTML tags during hyphenation, and the provision of both asynchronous (`hyphenate`) and synchronous (`hyphenateSync`) functions to suit different application contexts. Users can configure hyphenation with options for exceptions, the soft hyphen character, and minimum word length for processing.
npm install hyphenVerified import paths — ran on the pinned version, not inferred.
Demonstrates asynchronous and synchronous hyphenation for English and German text, including custom options like exceptions and hyphenation character.
Always import and use the correct function for your desired behavior: `import { hyphenate } from 'hyphen/en'` for async, and `import { hyphenateSync } from 'hyphen/en'` for sync.Ensure you import from the correct language-specific module, e.g., `import { hyphenate } from 'hyphen/en';`.Pass an `options` object with `hyphenChar` set to your desired character, e.g., `{ hyphenChar: '-' }` or `{ hyphenChar: '·' }`.Ensure HTML input is well-formed. For very complex or untrusted HTML, consider pre-processing the text to extract plain text segments, hyphenate them, and then re-insert into the HTML structure, or use a dedicated HTML parsing library in conjunction.
Change the import path to a language-specific module, e.g., `import { hyphenate } from 'hyphen/en';`. If using CommonJS, ensure your environment supports dynamic `import()` or switch to an ESM-aware setup.Run `npm install hyphen` or `yarn add hyphen`. Ensure your bundler (Webpack, Rollup, etc.) is configured to handle ES Modules and module resolution correctly. Check for typos in the import path.
Verify the `exceptions` array contains the correct words to exclude. Adjust `minWordLength` to control the shortest words hyphenated. Ensure the correct language module (e.g., `hyphen/de` for German) is imported for the given text.
No dependency data recorded yet.