tag-soup
Version:
The fastest pure JS SAX/DOM XML/HTML parser.
30 lines (29 loc) • 1.1 kB
TypeScript
import { IParser, IParserOptions, ISaxHandler } from './parser-types';
/**
* Creates a pre-configured HTML SAX parser.
*
* @param handler The parsing handler.
* @param options Options that override the defaults.
*/
export declare function createHtmlSaxParser(handler: ISaxHandler, options?: IParserOptions): IParser<void>;
/**
* The default HTML parser options:
* - CDATA sections and processing instructions are treated as comments;
* - Self-closing tags are treated as a start tags;
* - Tags like `p`, `li`, `td` and others follow implicit end rules, so `<p>foo<p>bar` is parsed as
* `<p>foo</p><p>bar</p>`;
* - Tag and attribute names are converted to lower case;
* - Legacy HTML entities are decoded in text and attribute values. To decode all known HTML entities use:
*
* ```ts
* import {decodeHtml} from 'speedy-entities/lib/full';
*
* createHtmlSaxParser({
* decodeText: decodeHtml,
* decodeAttribute: decodeHtml,
* });
* ```
*
* @see {@link https://github.com/smikhalevski/speedy-entities decodeHtml}
*/
export declare const htmlParserOptions: IParserOptions;