Expand description
MusKitty HTML Parser
Implements the WHATWG HTML parsing algorithm.
§Architecture
The parser follows the standard two-stage model (§13.2.1):
- Tokenization ([
tokenizer]) — consumes a stream of code points and emits tokens. - Tree construction (
parser) — consumes tokens and builds the DOM.
§References
- WHATWG HTML Living Standard: https://html.spec.whatwg.org/multipage/parsing.html
- WPT test suite: https://github.com/web-platform-tests/wpt/tree/master/html/syntax/parsing
Modules§
- error
- Parse error types for the HTML parser.
- parser
- Tree construction stage (§13.2.6).
- serialize
- HTML fragment serialization (WHATWG §13.6.4 / §13.6.5).
Structs§
- Parse
Output - 解析结果:包含 Document 与累积的解析错误。
Constants§
- MAX_
INPUT_ BYTES - 默认输入大小上限:64 MiB(参考 Chromium 的输入保护策略)。
- MAX_
OPEN_ ELEMENTS - 默认 open elements 栈深度上限:512(参考 Chromium
kMaxHTMLParserDOMDepth、 WebKitmaxDOMTreeDepth = 500)。
Functions§
- parse
- Parse an HTML string into a Document node.
- parse_
fragment - Parse an HTML fragment (§13.4.2) and return the resulting
DocumentFragment. - parse_
with_ limits - 解析 HTML 字符串,自定义输入大小与栈深度限制。