formats: std/html formatting elements and the adoption agency (step 2b of #79) #734

Closed
opened 2026-11-13 08:51:34 +00:00 by orion · 3 comments
Collaborator

Part of #79 (step 2, second slice). Step 2a (#688) is on main: HtmlNode, HtmlDocument.parse, the insertion modes of the document skeleton and plain in body content, and the vendored html5lib tree-construction suite with a named skip list.

Goal

std/html handles formatting elements: the list of active formatting elements, "reconstruct the active formatting elements" and the adoption agency algorithm, so that misnested markup such as <b><p></b>text builds the tree the standard prescribes. Tables, foster parenting, foreign content, <template>, <select>/<frameset> and fragment parsing stay later slices.

Acceptance criteria

  • The start and end tags a, b, big, code, em, font, i, nobr, s, small, strike, strong, tt, u follow section 13.2.6.4.7 (in body): push onto the list of active formatting elements with the Noah's Ark clause (three identical entries), reconstruct the list before inserting text and other elements, and run the adoption agency algorithm (outer loop of at most 8 iterations, inner loop with its 3 iteration clamp) for their end tags and for the "any other end tag" fallthrough where the standard calls it.
  • <a> inside an open <a> and <nobr> inside an in-scope <nobr> run the adoption agency first, as specified; markers for applet, object, marquee (and later td, th, caption) clear the list to the last marker.
  • In tree.test.trb the formatting element skip reason is removed from reasonOfTag; every html5lib tree-construction case that was skipped only for that reason passes, including adoption01, adoption02, tests1.dat and tests2.dat cases. Cases that also contain a table, foreign content, template, select or frameset tag stay skipped under that reason. NOTICE.md and the skip-count assertion are updated to the new counts, read from CI.
  • Docs page and the header comment of tree.trb name the formatting elements as built; tools/gates.sh a green in CI.

Design pointers

  • WHATWG HTML 13.2.4.3 (list of active formatting elements), 13.2.6.4.7 (in body), 13.2.6.4.7 "adoption agency algorithm"; step 2a's std/html/src/tree.trb (insertion modes, stack of open elements) and std/html/tests/tree.test.trb (reasonOfTag, skipReason, skip counts; 127 cases currently skipped as formatting element).
  • The adoption agency algorithm needs "insert at appropriate place" with a target other than the current node; foster parenting is the table slice, so this slice uses the default place only.
  • Names fixed by #79: HtmlNode, HtmlDocument; no type called Html.

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 formatting elements and the adoption agency, test(html): ... for the skip list change). About 2 to 3 hours.

Part of #79 (step 2, second slice). Step 2a (#688) is on `main`: `HtmlNode`, `HtmlDocument.parse`, the insertion modes of the document skeleton and plain `in body` content, and the vendored html5lib tree-construction suite with a named skip list. ## Goal `std/html` handles formatting elements: the list of active formatting elements, "reconstruct the active formatting elements" and the adoption agency algorithm, so that misnested markup such as `<b><p></b>text` builds the tree the standard prescribes. Tables, foster parenting, foreign content, `<template>`, `<select>`/`<frameset>` and fragment parsing stay later slices. ## Acceptance criteria - The start and end tags `a`, `b`, `big`, `code`, `em`, `font`, `i`, `nobr`, `s`, `small`, `strike`, `strong`, `tt`, `u` follow section 13.2.6.4.7 (`in body`): push onto the list of active formatting elements with the Noah's Ark clause (three identical entries), reconstruct the list before inserting text and other elements, and run the adoption agency algorithm (outer loop of at most 8 iterations, inner loop with its 3 iteration clamp) for their end tags and for the "any other end tag" fallthrough where the standard calls it. - `<a>` inside an open `<a>` and `<nobr>` inside an in-scope `<nobr>` run the adoption agency first, as specified; markers for `applet`, `object`, `marquee` (and later `td`, `th`, `caption`) clear the list to the last marker. - In `tree.test.trb` the `formatting element` skip reason is removed from `reasonOfTag`; every html5lib tree-construction case that was skipped only for that reason passes, including `adoption01`, `adoption02`, `tests1.dat` and `tests2.dat` cases. Cases that also contain a table, foreign content, template, select or frameset tag stay skipped under that reason. `NOTICE.md` and the skip-count assertion are updated to the new counts, read from CI. - Docs page and the header comment of `tree.trb` name the formatting elements as built; `tools/gates.sh a` green in CI. ## Design pointers - WHATWG HTML 13.2.4.3 (list of active formatting elements), 13.2.6.4.7 (`in body`), 13.2.6.4.7 "adoption agency algorithm"; step 2a's `std/html/src/tree.trb` (insertion modes, stack of open elements) and `std/html/tests/tree.test.trb` (`reasonOfTag`, `skipReason`, skip counts; 127 cases currently skipped as `formatting element`). - The adoption agency algorithm needs "insert at appropriate place" with a target other than the current node; foster parenting is the table slice, so this slice uses the default place only. - Names fixed by #79: `HtmlNode`, `HtmlDocument`; no type called `Html`. ## 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 formatting elements and the adoption agency, `test(html): ...` for the skip list change). About 2 to 3 hours.
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261113 until 2026-11-13T12:50:00Z

[loop:torbscript] claim implement by session:loop-torbscript-20261113 until 2026-11-13T12:50:00Z
Author
Collaborator

[loop:torbscript] implement: the worker hit its time limit after opening PR #737 (head 3006ac8); CI is running, no red job yet, Argus is requested. Claim released.
next: review

[loop:torbscript] implement: the worker hit its time limit after opening PR #737 (head 3006ac8); CI is running, no red job yet, Argus is requested. Claim released. next: review
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261113 until 2026-11-13T13:55:00Z (CI red on PR #737: tier A, gates; fix on the existing branch)

[loop:torbscript] claim implement by session:loop-torbscript-20261113 until 2026-11-13T13:55:00Z (CI red on PR #737: tier A, gates; fix on the existing branch)
argus closed this issue 2026-11-13 16:05:15 +00:00
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#734
No description provided.