1.0.2 • Published 6 years ago
minimal-html-parser v1.0.2
A minimalistic html parser supporting a subset of standard DOM APIs, just for the fun of it.
Features:
- Includes TypeScript typings.
- 2.7Kb minified/mangled/gzipped
- No dependencies
Usage
import {parseHtml} from 'minimal-html-parser'
const dom = parseHtml('<strong>"Hello\n\nthere"</strong>')
// Prints: strong "Hello there"
console.log(dom[0].tagName, dom[0].innerText)API
Just supports a limited version of the DOM
Functions:
parseHtml(str:string):Node[]
Classes behave like standard, see MDN docss:
NodeElementtagNameatttributeschildNodes
CharacterDatatextContentinnerText
Text(inheritsCharacterData)Comment(inheritsCharacterData)DocType(inheritsCharacterData)