HTML parser and various utilities.
npm install @dbushell/hyperlessHTML parser and various utilities.
parseHTMLParse an HTML document or fragment into a traversable node tree.
``javascript`
import {parseHTML} from '@dbushell/hyperless';
const root = parseHTML('Hello, World!
');
Node API subject to change.
Parse an HTML attribute string into a case-insensitive deduplicated key/value map.
`javascript`
import {parseAttributes} from '@dbushell/hyperless';
const map = parseAttributes('a="1" b="2" c d="d" D="d" e=e');
HTML entity encoding is handled automatically by default.
Remove HTML and return text content with a few niceties.
` Ceci n’est pas une paragraphe.javascript`
import {stripTags} from '@dbushell/hyperless';
// Pass a chunk of HTML
const text = stripTags('
Text in
andare wrapped in quotation marks.`$3
Generate a text excerpt from HTML content.
javascript`
import {excerpt} from '@dbushell/hyperless';
// Pass a chunk of HTML
const text = excerpt(html);maxLengthOutput is context aware trimmed to the nearest sentence, or word, to fit the maximum length as close as possible.
An optional
can be passed as the second argument (default:300` characters).*
MIT License | Copyright © 2024 David Bushell