Skip to content

HTMLParser

The HTMLParser interface provides the ability to parse an HTML string according to specified rules.

Example:

js
import { HTMLParser } from 'lakelib';

const parser = new HTMLParser('<div><p>foo</p><p>bar</p></div>');
console.log(parser.getHTML());

Constructor

Creates a new HTMLParser instance.

Instance methods

getHTML()

Returns the parsed HTML as a string.

  • Parameters:

    None.

  • Return value:

    An HTML string.

Example:

js
const parser = new HTMLParser('<p>foo</p>');
const html = parser.getHTML();

getFragment()

Returns the parsed content as a DocumentFragment object.

Example:

js
const parser = new HTMLParser('<p>foo</p>');
const fragment = parser.getFragment();

Released under the MIT License.