References — bi-03 HTML Parsing
Primary sources first. In-tree Chromium docs beat any external source, including these modules.
Specification — read this one properly
- HTML Standard §13 — Parsing HTML documents — the normative algorithm. The tokenizer's 76 states and the insertion modes are enumerated here and nowhere else.
- Tree construction — including foster parenting and the adoption agency algorithm.
- Parsing HTML fragments — a genuinely different algorithm, which is why
innerHTMLbehaves differently. document.write()— the reason the parser cannot simply run ahead.
Source
third_party/blink/renderer/core/html/parser/— the whole subsystemhtml_tokenizer.cc— the state machine, onecaseper spec statehtml_tree_builder.cc— insertion modeshtml_construction_site.cc— foster parenting lives herehtml_preload_scanner.cc— speculative parsing and what it may not dohtml_document_parser.cc— yielding, and the script-blocking interaction
Conformance
- html5lib-tests — the shared parser test suite.
tree-construction/*.datis the fastest way to find pathological cases. - WPT html/syntax
Background
- Simon Pieters — Idiosyncrasies of the HTML parser — book-length, free, and the best secondary source in existence.
- Encoding Standard — the encoding sniffing that happens before parsing can start.
Related modules
- bi-04 — DOM internals — what the parser hands downstream
- bi-13 — Tests & WPT — running html5lib-tests properly
- fe-04 — HTML as a platform (sibling project) — the application-level consequences of the same semantics
When a claim here proves stale, record it in PROGRESS.md section 7.