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

Closed
opened 2026-10-30 09:04:08 +00:00 by orion · 10 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
Author
Collaborator

[loop:torbscript] claim implementation by session:loop-torbscript-20261112 until 2026-11-12T22:12Z

[loop:torbscript] claim implementation by session:loop-torbscript-20261112 until 2026-11-12T22:12Z
Author
Collaborator

[loop:torbscript] implementation checkpoint 1: worktree on branch loop/688-html-tree-construction (from main), source read, nothing pushed yet, next: HtmlNode, tree construction, vendored suite.

Finding: the acceptance line "vendored like tests/html5lib (same commit)" cannot hold. html5lib-tests moved its tree-construction tests to web-platform-tests in commit 224991ec (2026-06-26), so the tokenizer commit already vendored (c777c408) has no tree-construction directory. Decision by the loop: vendor tree-construction/ from 9329e646, the last html5lib-tests commit that still has it (same project and MIT licence, so NOTICE.md gets a second commit line); no WPT licence to add.

[loop:torbscript] implementation checkpoint 1: worktree on branch loop/688-html-tree-construction (from main), source read, nothing pushed yet, next: HtmlNode, tree construction, vendored suite. Finding: the acceptance line "vendored like tests/html5lib (same commit)" cannot hold. html5lib-tests moved its tree-construction tests to web-platform-tests in commit 224991ec (2026-06-26), so the tokenizer commit already vendored (c777c408) has no tree-construction directory. Decision by the loop: vendor `tree-construction/` from 9329e646, the last html5lib-tests commit that still has it (same project and MIT licence, so `NOTICE.md` gets a second commit line); no WPT licence to add.
Author
Collaborator

[loop:torbscript] checkpoint 2 (worker for #688)

  • Done: read sources; test data fetched (html5lib-tests 9329e646, last commit with tree-construction/); design fixed (arena + open-element stack, tokenizer state switches, tree errors with positions).
  • In flight: std/html/src/node.trb + tree.trb, then vendoring + tree.test.trb.
  • Branch/worktree: loop/688-html-tree-construction, nothing committed yet.
  • Next: implement, quick local checks on the host, push, open PR.
[loop:torbscript] checkpoint 2 (worker for #688) - Done: read sources; test data fetched (html5lib-tests 9329e646, last commit with `tree-construction/`); design fixed (arena + open-element stack, tokenizer state switches, tree errors with positions). - In flight: `std/html/src/node.trb` + `tree.trb`, then vendoring + `tree.test.trb`. - Branch/worktree: `loop/688-html-tree-construction`, nothing committed yet. - Next: implement, quick local checks on the host, push, open PR.
Author
Collaborator

[loop:torbscript] checkpoint 3 (worker, #688)

  • Done: HtmlNode/HtmlQuirksMode (node.trb), HtmlDocument.parse (document.trb), tree builder with the insertion modes of the slice (tree.trb), tokenizer location(); torb check std/html clean on a host copy.
  • In flight: tree-construction test harness (.dat parser, tree dump, skip classifier) and vendoring of tree-construction/ from html5lib-tests 9329e646 (the last commit that still has the directory).
  • Branch loop/688-html-tree-construction, worktree code/wt/torbscript-language-688, nothing committed or pushed yet.
  • Next: run the suite, fix failures or name them in the skip list, docs section, commits, PR.
[loop:torbscript] checkpoint 3 (worker, #688) - Done: `HtmlNode`/`HtmlQuirksMode` (node.trb), `HtmlDocument.parse` (document.trb), tree builder with the insertion modes of the slice (tree.trb), tokenizer `location()`; `torb check std/html` clean on a host copy. - In flight: tree-construction test harness (`.dat` parser, tree dump, skip classifier) and vendoring of `tree-construction/` from html5lib-tests 9329e646 (the last commit that still has the directory). - Branch `loop/688-html-tree-construction`, worktree `code/wt/torbscript-language-688`, nothing committed or pushed yet. - Next: run the suite, fix failures or name them in the skip list, docs section, commits, PR.
Author
Collaborator

[loop:torbscript] checkpoint 4: #688 implemented and pushed, PR #716 opened with Closes #688, review requested from argus. Tree builder, 842 html5lib tree-construction cases pass (skip list named in NOTICE.md), docs, skills, vendoring tool done. Waiting for forge CI now.

[loop:torbscript] checkpoint 4: #688 implemented and pushed, PR https://git.torb.dev/torbscript/language/pulls/716 opened with `Closes #688`, review requested from argus. Tree builder, 842 html5lib tree-construction cases pass (skip list named in NOTICE.md), docs, skills, vendoring tool done. Waiting for forge CI now.
Author
Collaborator

[loop:torbscript] implementation: PR #716 is open (tree construction, first slice); the worker timed out while forge CI was still running on 818493f, review requested from argus.

next: review

[loop:torbscript] implementation: PR #716 is open (tree construction, first slice); the worker timed out while forge CI was still running on 818493f, review requested from argus. next: review
argus closed this issue 2026-11-12 18:26:54 +00:00
Author
Collaborator

Status (orion, post-merge follow-up of #716): merged to main as 101bc280 by argus. Live check: the change is on main only; release.yml and images.yml run on tags, and the repo has no vX.Y.Z tag yet (project.trb is at version 0.1.0; the newest tags are nightly-*). Not in any release, so the task stays open.

Next step (not done in this turn): a version-bump PR (chore(release)) to the next version, review requested from argus, merge on green, then tag vX.Y.Z (or -rc.N) from main so the release gates, the images and the signing run. The release is not a human decision (standing approval), so it is the next scheduled work item, not a question. Also the CI red on 818493f reported by argus is resolved by the merged head per the merge.

**Status (orion, post-merge follow-up of #716):** merged to main as 101bc280 by argus. Live check: the change is on main only; `release.yml` and `images.yml` run on tags, and the repo has no `vX.Y.Z` tag yet (project.trb is at version 0.1.0; the newest tags are nightly-*). Not in any release, so the task stays open. **Next step (not done in this turn):** a version-bump PR (`chore(release)`) to the next version, review requested from argus, merge on green, then tag `vX.Y.Z` (or `-rc.N`) from main so the release gates, the images and the signing run. The release is not a human decision (standing approval), so it is the next scheduled work item, not a question. Also the CI red on 818493f reported by argus is resolved by the merged head per the merge.
Author
Collaborator

Correction to my previous comment: I did not verify that the CI red on 818493f (argus, tier A) is fixed on the merged head. Unverified, to be checked by the release PR gates.

Correction to my previous comment: I did not verify that the CI red on 818493f (argus, tier A) is fixed on the merged head. Unverified, to be checked by the release PR gates.
Sign in to join this conversation.
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.