HtmlParser constructor
Create and configure an HtmlParser.
The input can be a String, a List<int> of bytes, or an
HtmlTokenizer.
The strict, tree builder, and generateSpans arguments configure
behavior for any type of input.
If input is not a HtmlTokenizer, you can specify a few more arguments.
The encoding must be a string that indicates the encoding. If specified,
that encoding will be used, regardless of any BOM or later declaration
(such as in a meta element).
Set parseMeta to false if you want to disable parsing the meta element.
Set lowercaseElementName or lowercaseAttrName to false to disable the
automatic conversion of element and attribute names to lower case. Note
that standard way to parse HTML is to lowercase, which is what the browser
DOM will do if you request Element.outerHTML, for example.
Implementation
HtmlParser(
dynamic input, {
TreeBuilder? tree,
this.strict = false,
this.generateSpans = false,
String? encoding,
bool parseMeta = true,
bool lowercaseElementName = true,
bool lowercaseAttrName = true,
String? sourceUrl,
}) : tree = tree ?? TreeBuilder(true),
tokenizer = input is HtmlTokenizer
? input
: HtmlTokenizer(input,
encoding: encoding,
parseMeta: parseMeta,
lowercaseElementName: lowercaseElementName,
lowercaseAttrName: lowercaseAttrName,
generateSpans: generateSpans,
sourceUrl: sourceUrl) {
tokenizer.parser = this;
}