html: tree construction for documents, first slice: HtmlNode, HtmlDocument.parse (step 2a of #79) #688

Open
opened 2026-10-30 09:04:08 +00:00 by orion · 2 comments
Collaborator

Part of #79 (step 2, first slice). Step 1 (#439) is on main: HtmlTokenizer, HtmlToken, HtmlParseError.

Goal

std/html reads a document into a tree. This slice is the tree type and the construction for the document skeleton and plain content; the adoption agency algorithm, tables and foster parenting follow as the next slice(s) of step 2 (just in time, once this lands). Tree construction in full is more than one PR, so only this first slice is filed.

Acceptance criteria

  • HtmlNode (document, doctype, element with name and attributes, text, comment; children in order) and HtmlDocument.parse(text) answering the tree, the quirks mode and the HtmlParseError list (tokenizer and tree errors). Reading never fails, no Result (design record of #79).
  • The insertion modes initial, before html, before head, in head, after head, in body (without formatting elements and tables), text, after body, after after body; implied html, head, body; quirks mode from the doctype; the tokenizer switches for <script>, <style>, <textarea>, <title>, <plaintext> and similar raw-text elements. scripting stays off (<noscript> is markup).
  • The html5lib-tests tree-construction suite, vendored like tests/html5lib (same commit, NOTICE.md updated), runs in std/html/tests; every case this slice covers passes, the rest sit in a named skip list with the reason (formatting, table, foreign content, template, fragment) that the next slices shrink.
  • A docs page section and lib.trb exports for the new names; tools/gates.sh a green in CI.

Design pointers

  • WHATWG HTML section 13.2.6 (tree construction); layout models std/xml (node.trb, parser.trb) and the existing std/html tokenizer (tokenizer.trb, state.trb).
  • Names fixed by #79: HtmlNode, HtmlDocument, no type called Html (that is #93's).
  • Input is a String; no encoding detection.

Seed

No. Only std/html changes; the compiler imports no std/html name. If a compiler change turns out to be needed, split it into its own commit and stop: a seed touch means a teaching commit and a migration commit, and the seed refresh is the owner's step.

Size

One PR, one or two Conventional Commits (feat(html): ... for the tree, test(html): ... for the vendored suite).

Part of #79 (step 2, first slice). Step 1 (#439) is on `main`: `HtmlTokenizer`, `HtmlToken`, `HtmlParseError`. ## Goal `std/html` reads a document into a tree. This slice is the tree type and the construction for the document skeleton and plain content; the adoption agency algorithm, tables and foster parenting follow as the next slice(s) of step 2 (just in time, once this lands). Tree construction in full is more than one PR, so only this first slice is filed. ## Acceptance criteria - `HtmlNode` (document, doctype, element with name and attributes, text, comment; children in order) and `HtmlDocument.parse(text)` answering the tree, the quirks mode and the `HtmlParseError` list (tokenizer and tree errors). Reading never fails, no `Result` (design record of #79). - The insertion modes `initial`, `before html`, `before head`, `in head`, `after head`, `in body` (without formatting elements and tables), `text`, `after body`, `after after body`; implied `html`, `head`, `body`; quirks mode from the doctype; the tokenizer switches for `<script>`, `<style>`, `<textarea>`, `<title>`, `<plaintext>` and similar raw-text elements. `scripting` stays off (`<noscript>` is markup). - The html5lib-tests `tree-construction` suite, vendored like `tests/html5lib` (same commit, `NOTICE.md` updated), runs in `std/html/tests`; every case this slice covers passes, the rest sit in a named skip list with the reason (formatting, table, foreign content, template, fragment) that the next slices shrink. - A docs page section and `lib.trb` exports for the new names; `tools/gates.sh a` green in CI. ## Design pointers - WHATWG HTML section 13.2.6 (tree construction); layout models `std/xml` (`node.trb`, `parser.trb`) and the existing `std/html` tokenizer (`tokenizer.trb`, `state.trb`). - Names fixed by #79: `HtmlNode`, `HtmlDocument`, no type called `Html` (that is #93's). - Input is a `String`; no encoding detection. ## Seed No. Only `std/html` changes; the compiler imports no `std/html` name. If a compiler change turns out to be needed, split it into its own commit and stop: a seed touch means a teaching commit and a migration commit, and the seed refresh is the owner's step. ## Size One PR, one or two Conventional Commits (`feat(html): ...` for the tree, `test(html): ...` for the vendored suite).
Author
Collaborator

[loop:torbscript] claim implementation by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-31T01:31Z

[loop:torbscript] claim implementation by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-31T01:31Z
Author
Collaborator

[loop:torbscript] release implementation by session:loop-torbscript-20261030 @anthropic:tkoehn: the worker run ended without a result (the worker runtime refused its oversized output log); no branch, commit or PR was pushed, so nothing is left to pick up. The item is still ready; the next worker starts from main and keeps its command output small.
next: implementation

[loop:torbscript] release implementation by session:loop-torbscript-20261030 @anthropic:tkoehn: the worker run ended without a result (the worker runtime refused its oversized output log); no branch, commit or PR was pushed, so nothing is left to pick up. The item is still `ready`; the next worker starts from main and keeps its command output small. next: implementation
Sign in to join this conversation.
No labels
loop
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#688
No description provided.