minimal-html-parser
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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>&quot;Hello\n\nthere&quot;</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:

  • Node
  • Element
    • tagName
    • atttributes
    • childNodes
  • CharacterData
    • textContent
    • innerText
  • Text (inherits CharacterData)
  • Comment (inherits CharacterData)
  • DocType (inherits CharacterData)

Readme

Keywords

none

Package Sidebar

Install

npm i minimal-html-parser

Weekly Downloads

2

Version

1.0.2

License

ISC

Unpacked Size

28.7 kB

Total Files

14

Last publish

Collaborators

  • staeke