bi-03 step 02 — Observe, then build the tree builder

Goal

Establish the browser as the oracle, then write a tree builder that agrees with it.

Tasks

  1. Capture the oracle. Open each fixture from file:// in Chrome, paste src/show.js into the console, and save the output to src/observed/<case>.txt. Keep exact whitespace.

  2. Score your predictions honestly: exact / structurally right, details wrong / wrong.

  3. Write src/foster.js, exporting buildTree(tokens). Under ~80 lines, no dependencies. Implement only: a stack of open elements, the inBody and inTable insertion modes, an appropriateInsertionPlace(fosterParenting) function, and the <input type=hidden> exception.

  4. Run the harness.

    node run.mjs a       # your output
    node check.mjs       # diff against the browser
    

    Cases a, b, d must pass exactly. Case c is the stretch goal.

  5. If you attempt case c, do not fix the diff blindly. Read it: it is telling you precisely what the in-table-text character sub-mode is for.

Done when

  • All four observed files captured
  • Predictions scored
  • node check.mjs passes cases a, b, d
  • You can explain why case A's world text lands inside the div and not before the table