HtmlParserOptions Class
Options of the HtmlDocumentParser.
public sealed class HtmlParserOptionsConstructors
| Name | Description |
|---|---|
| HtmlParserOptions() |
HtmlParserOptions()
HtmlDocumentParser.cspublic HtmlParserOptions()No documentation is available.
Properties
| Name | Description |
|---|---|
| AllowDeclarativeShadowRoots | Gets or sets whether <template shadowrootmode> creates declarative shadow roots. The default is true. |
| CustomElementRegistry | Gets or sets the custom element registry of the parsed document, which defines the custom elements the parser creates (see CustomElementRegistry). The default is null: the document has no registry, and custom elements are not defined. The documents loaded in a browsing context (see BrowsingContext.Navigate) get the global registry of their window instead. |
| DefaultEncoding | Gets or sets the encoding used when it cannot be determined from the content. The default is windows-1252. |
| EncodingDetector | Gets or sets the detector of the encoding of the documents parsed from bytes that do not declare their encoding: no byte order mark, no HtmlParserOptions.TransportEncoding, no meta element, and no container document that gives its encoding. The default is EncodingDetector.Default, which guesses the legacy encodings from the content (and UTF-8 when HtmlParserOptions.Url is not set or is a file: URL). Null disables the detection: these documents get the HtmlParserOptions.DefaultEncoding, as the ones whose encoding is not detected. The detector is not used when the HtmlParserOptions.DefaultEncoding is UTF-16BE/LE (the detected encodings are ASCII-compatible). |
| MaxElementCount | Gets or sets the maximum number of elements the parser creates, or null for no limit (the default, as in the browsers). When the parser would create more elements, it throws an HtmlParserLimitExceededException. The number of elements is not bounded by the length of the markup: the parser recreates the open formatting elements (b, i, a, …) in each new block, so a few kilobytes of markup can create millions of elements. Set a limit when the markup comes from an untrusted source. |
| ParseErrorHandler | Gets or sets the callback invoked for each parse error. Tracking positions has no cost when this is null. |
| ScriptingEnabled | Gets or sets whether scripting is enabled for the parsed documents: this changes how <noscript> is parsed. The default is false (as for documents created by DOMParser). The scripts never run in the parsed documents: they only run in the documents loaded by BrowsingContext.Navigate in a browsing context that has a BrowsingContextOptions.ScriptEngine. |
| TransportEncoding | Gets or sets the encoding label provided by the transport layer (e.g. the charset of the Content-Type header). |
| Url | Gets or sets the URL of the document (used to resolve relative URLs). The default is about:blank. |
AllowDeclarativeShadowRoots
HtmlDocumentParser.csCustomElementRegistry
HtmlDocumentParser.csGets or sets the custom element registry of the parsed document, which defines the custom elements the parser creates (see CustomElementRegistry). The default is null: the document has no registry, and custom elements are not defined. The documents loaded in a browsing context (see BrowsingContext.Navigate) get the global registry of their window instead.
public CustomElementRegistry? CustomElementRegistry { get; init; }Property value
DefaultEncoding
HtmlDocumentParser.csEncodingDetector
HtmlDocumentParser.csGets or sets the detector of the encoding of the documents parsed from bytes that do not declare their encoding: no byte order mark, no HtmlParserOptions.TransportEncoding, no meta element, and no container document that gives its encoding. The default is EncodingDetector.Default, which guesses the legacy encodings from the content (and UTF-8 when HtmlParserOptions.Url is not set or is a file: URL). Null disables the detection: these documents get the HtmlParserOptions.DefaultEncoding, as the ones whose encoding is not detected. The detector is not used when the HtmlParserOptions.DefaultEncoding is UTF-16BE/LE (the detected encodings are ASCII-compatible).
public EncodingDetector? EncodingDetector { get; init; }Property value
MaxElementCount
HtmlDocumentParser.csGets or sets the maximum number of elements the parser creates, or null for no limit (the default, as in the browsers). When the parser would create more elements, it throws an HtmlParserLimitExceededException. The number of elements is not bounded by the length of the markup: the parser recreates the open formatting elements (b, i, a, …) in each new block, so a few kilobytes of markup can create millions of elements. Set a limit when the markup comes from an untrusted source.
public int? MaxElementCount { get; init; }Property value
ParseErrorHandler
HtmlDocumentParser.csGets or sets the callback invoked for each parse error. Tracking positions has no cost when this is null.
public Action<HtmlParseError>? ParseErrorHandler { get; init; }Property value
ScriptingEnabled
HtmlDocumentParser.csGets or sets whether scripting is enabled for the parsed documents: this changes how <noscript> is parsed. The default is false (as for documents created by DOMParser). The scripts never run in the parsed documents: they only run in the documents loaded by BrowsingContext.Navigate in a browsing context that has a BrowsingContextOptions.ScriptEngine.
public bool ScriptingEnabled { get; init; }