Skip to content

fix: let embedded content keep its own table and code styling - #5048

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-5025
Nov 2, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-5025

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

data-style="own" on a subtree leaves native table sizing, code-block scrolling and scrollbar clearance, and syntax highlighting to its author. A full-width table keeps its native grid, pre-highlighted code keeps its spans and colors, and pre::after adds no spacer. Comments still anchor inside the subtree. Put the attribute on main with --no-theme for a page whose design is wholly its own; theme selection and inherited styles remain independent of this boundary.

The CSS exclusions add no specificity, and the syntax pass checks the boundary before tokenization and again when asynchronous tokens arrive. The authoring reference and feature gallery show the new surface.

Verified 16 focused browser tests, including table layout in Chromium, Firefox and WebKit, preserved token markup and comment anchors, normal syntax highlighting, and a no-theme page compared with its standalone rendering in light and dark media. The table and token regressions fail before the fix. All 737 runtime tests, the browser build and pre-commit checks passed.

The same authored example on the base and candidate runtimes:

Before After
Table narrowed and code recolored Full-width table and authored code colors
Visual and startup comparisons

leaf-dev stills main --state own-styling --state native-code --state table-scrolled-phone captures the changed embedded content and leaves the ordinary scrolling-table state unchanged. The computed-style differences on the gallery are confined to the embedded subtree.

The corpus probe compared base c669efeab06d16cff6ecc513f8b234e920ff15df with this change. Before the page first presents server state, requests went from 282 to 280 and loaded bytes from 12,100,196 to 12,086,303; code requests went from 143 to 142 and code bytes from 7,025,056 to 7,015,720. The exclusions belong in first-paint CSS and before tokenization so the page's authored layout and spans survive startup. Both arms reported the same quoted-alerts playground initialization error, so this profile is startup evidence rather than a clean corpus render check.

Reproduce the profile with uv run leaf-dev probe corpus --base c669efeab06d16cff6ecc513f8b234e920ff15df.

Closes #5025 — automated triage

Add data-style="own" as an authored boundary for native table and code geometry and syntax highlighting. Keep the selected theme and widget component styling separate from the boundary. Cover preserved token markup, comment anchors, ordinary table layout and no-theme static-page fidelity.

Closes #5025
@leaf-agent
leaf-agent merged commit 933c4c4 into main Nov 2, 2026
5 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-5025 branch November 2, 2026 02:00
max-sixty added a commit that referenced this pull request Nov 2, 2026
#5048 landed `data-style="own"` while this branch was open. The merge
keeps it working: its exclusions now stand on the scroll-model rules in the
reading face, and `colouredAs` checks it beside the face and the
text-only rule. On a page that takes no theme the attribute now changes
nothing, so page-authoring.md offers it for content embedded in a page that
takes a theme.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
max-sixty added a commit that referenced this pull request Nov 2, 2026
#5048 added `data-style="own"` to keep a subtree out of Leaf's table and
code restyling. With the reading face now carrying that restyling, the
attribute did nothing on a page that takes no theme, and on a themed page
it removed only part of what the face input does: the face's table font,
margins and muted headings still reached the subtree. One capability gets
one API (root `AGENTS.md`, "Fix the underlying issue"), so the attribute
goes: its selector exclusions in `reading.css`, its check in `syntax.js`,
its feature-gallery section and stills state, and the plain fixture that
carried it (`deck.html` holds the same pattern with no attribute).

Content with its own design inside a themed page sits in a box that sets
`--lf-reading-face: initial`, the value Leaf's own `:host` rule uses to
take the face away. `package-themes.md` now documents that value beside
`1`, and `page-authoring.md` points to it in one sentence. #5048's test
becomes a test of the face input: a box off the face keeps a native
`width: 100%` table, its own token spans and colours, no `pre` spacer and
an uncoloured plain block, and a comment still anchors on a word inside
it. Run with the face left on (`1`), the test fails on the table's
`display`.

A probe of the same page with a seeded comment (`leaf-dev probe --log`)
read the table at 680px of 688, the page's token kept at rgb(160, 20, 80)
with no Leaf spans, no `::after` on the block, and the comment's mark
on the token. The code block outside the box stayed coloured with its
clearance.

The attribute landed hours before this change, and no page depends on it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
max-sixty added a commit that referenced this pull request Nov 2, 2026
… colours (#5049)

Part of #5025, which #5048 closed with `data-style="own"` while this
branch was open.

A page that takes no theme, such as a reveal.js deck the user brings,
kept three of Leaf's restylings:

- every table became a block that scrolls its columns, so a table the
page sized to `width: 100%` shrank its rows to their content inside a
full-width border;
- every code block took an 8px float under its last line;
- every `pre > code` with a `language-…` class was recoloured, which
deleted the page's own token spans.

None of the three needs a subtree opt-out. Each was a reading-face rule
that reached every page, so this moves each into the face. A page that
takes no theme then keeps its own tables and code with no attribute.

It also removes `data-style="own"`, which #5048 added hours earlier (see
the section on removing it, below). Content with its own design inside a
themed page uses the face input instead.

## What changed

**The scroll model is now part of the reading face**
(`browser/styles/components/reading.css`). Before, it reached every
page. The model covers four rules: a table or code block scrolls inside
itself, the 8px clearance under it, an identifier breaks anywhere, and
paper wraps code. The reading theme turns the face on for the whole
page. Leaf's own surfaces (transcripts, rendered Markdown, the chrome,
lf-code) turn it on for themselves. So every themed page and every Leaf
surface keeps the model. A page without the face keeps the browser's
table and pre. Where one of those runs past the window, `page check
--render` refuses the page and names the element (`page-scrolls`,
`clipped-out`). That check is already in the agent's path (AGENTS.md,
"Leaf's role").

No CSS keeps a table scrollable without making it a block. A block box
detaches the author's width, border and ground from the table grid
inside it. So the scroll model can't stay on a page like this without
breaking its tables.

**`highlightBlocks` (`browser/runtime/syntax.js`) colours a block only
when it holds only text and wears the face.**
- A block that holds elements was marked up by its author, so Leaf
leaves it alone on every page. Leaf's own spans from an earlier pass
still count as text, so a revision that changes the block's language
still recolours it.
- The token palette is drawn for the face's code ground. On a page
without the face it came out as light-scheme ink on the page's own dark
ground (see the before shot).
- A block that isn't in the document yet has no face to read, so it is
coloured. That keeps a message coloured when Leaf draws it before
placing it.

**The breakout rule for a table in a Layout** (`browser/layouts.css`) is
split in two. Its scroll container, its column-wide minimum and its
inline-block caption assumed the face's block table, so they now apply
only under the face. On a native table the caption rule would have
pulled the caption out of its caption box. Its max-content width, start
alignment and `contain: none` apply with or without the face. Otherwise
a `data-width="wide"` table on a no-theme page took the breakout's
`inline-size: 100%`, which spread two one-word columns over a 908px
track. With the fix the table measures 120px, in Chromium and Firefox. A
new render test covers it, using `serve(theme=False)`.

The shipped references now say that the scrolling of wide tables and
code blocks, identifiers breaking inside cells, and code colouring hold
only under the face: `package-themes.md`, `module-reading.md`,
`page-authoring.md` ("Markup" and "Style the page"), `page-layout.md`,
and the core registry's `table` entry. A page without the face is sent
to a box of its own that scrolls sideways (`overflow-x: auto` with
`class="scroll"`). The `past-column` finding offers that box too, beside
`data-width`, because `data-width` doesn't help a native table that is
wider than a narrow window.

## Evidence

The issue's repro was a no-theme page holding a `width: 100%` table, a
YAML block the page highlighted itself, and a plain YAML block. I read
it through `leaf-dev probe` against a page served by `bin/leaf server
start`:

| | before | after |
| --- | --- | --- |
| table display / row width | `block` / 117px of 720 | `table` / 718px |
| page's own token spans kept / Leaf's spans | 0 / 4 | 4 / 0 |
| plain block recoloured | yes | no |
| pre height (content and padding: 72px) | 80px | 72px |

`tests/browser/test_plain_pages.py` now also compares the size of every
box the author wrote inside `body`. All three restylings had left every
property the author declared computing the same, so the old comparison
missed them. A new fixture, `tests/fixtures/plain/deck.html`, holds the
issue's pattern.

Against the base CSS and runtime, the test fails on:
- `deck`: colours, added spans and sizes;
- `article`: its own `width: 100%` table is drawn 291px wide instead of
687;
- `dashboard`.

With this change, all three pass.

## What this changes for plain pages

The dashboard fixture has a six-column table that is wider than a window
under 760px. Leaf used to scroll it inside itself. Now the gate refuses
the page at those widths, as it refuses any page that scrolls sideways,
because the live root clips sideways overflow. The fixture's pin moves
from the `scroll-clearance` obstacle to a new one, `sideways-clip`. A
page author meets the same refusal on a wide table and answers it in the
page's own CSS.

The size comparison also found two older departures, pinned as
`class-vocabulary`. An author's `dl.facts` takes the facts list's grid,
and an author's `.choice` takes a choice target's aim floor, because
Leaf owns both class names on every page. This PR doesn't change either.

## Removing `data-style="own"`

#5048 landed this attribute through automated triage while this branch
was open. After the root fix above, it no longer earns a second API for
one capability (root `AGENTS.md`, "Fix the underlying issue"):
- On a page that takes no theme, it changes nothing, because nothing it
excludes reaches that page any more.
- On a themed page, it removes only part of what the face input does. A
probe of the repro under the reading theme with `data-style="own"` on
`main` still read the face's 18px table margin, its sans table font and
its muted 13px headings.
- `--lf-reading-face: initial` on a box takes the whole face from the
markup inside it. It works on a wrapper only: each face rule reads the
element's parent, so the box that sets it still wears the face. Set on a
table itself, the table stays a block with the face's margin and font.
`package-themes.md` says to put it on a wrapper. `initial` is the value
Leaf's own `:host` rule uses to take the face away. `package-themes.md`
("Personal themes") now documents it beside `1`.

The attribute had been on `main` for hours and no page uses it. This
branch deletes its selector exclusions in `reading.css`, its check in
`syntax.js`, its feature-gallery section and stills state, and its plain
fixture; `deck.html` holds the same pattern with no attribute. #5048's
test becomes
`test_a_box_off_the_reading_face_keeps_its_own_tables_code_and_comments`.
#5048 tested the attribute on a section, a table and a pre. The new test
covers the wrapping section only, the one placement where the face input
works. The paragraph #5048 added to `page-authoring.md` becomes one
sentence pointing at the face input. I kept that sentence because the
theme-inputs table in `packages.md` lists only `--lf-reading-face: 1`,
so an author embedding a design wouldn't learn how to turn the face off.

Before deleting it, I proved the replacement on a themed page with a
`--lf-reading-face: initial` section and a comment seeded inside it
(`leaf-dev probe --log`). The `width: 100%` table stayed native at 680px
of 688. The page's token kept rgb(160, 20, 80) with no Leaf spans. The
block had no `::after` and a plain block stayed uncoloured. The
comment's mark landed on the token. The code block outside the section
stayed coloured, with its clearance. The converted test fails when the
section sets `1` instead (`display` reads `block`).

## Calls Max may reverse

- **`data-style="own"` is removed** in favour of the face input (above).
Reverting commit `344523293` restores it.
- **The scroll model leaves pages without a theme.** The other option is
a runtime that marks a table whose grid is wider than its box, with the
core making only marked tables into blocks. That keeps wide tables
reachable without any CSS from the author, but it adds a per-table
observer and a switch one frame late on first paint. I didn't build it,
because the gate already reports the case to the agent. What keeps such
a table out of reach on a no-theme page is Leaf's root rule
`html[data-lf-live] { overflow-x: hidden }` (`browser/base.css`). On a
390px window the table's last cell stays at 715px and the wheel moves
the page 0px. With the rule lifted, the wheel moves the page 582px and
the cell comes into view. Removing that rule is a separate decision, put
to Max on his page, and not part of this PR. Removing it alone would not
unblock such a page either, since the render gate still refuses a page
that scrolls sideways (`page-scrolls`).
- **Code colouring follows the face.** A page without a theme that wants
Leaf's colours sets `--lf-reading-face: 1` on a box around the code.

## Checks run

- The test `test_plain_pages`, on every fixture by `-k`: 6 passed and 3
xfailed with the new pins. Against the base CSS, `deck`, `article` and
`dashboard` failed.
- In `test_render_anchors`, `-k "marked_up or rewritten_while or aliases
or colored_without or code_copy"`: 12 passed. This includes a new test,
`test_a_block_its_author_marked_up_keeps_its_markup`.
- In `test_render_gate`, `-k` covering scrollbar clearance, scrolling
tables, the squeeze reading, the syntax probe and table widths: 14
passed.
- Thread message colouring:
`test_an_agent_message_edit_updates_the_panel_and_its_inline_thread` and
`test_a_reply_renders_the_markdown_it_was_written_in` both passed.
- `pnpm run test:runtime`: 737 passed. `pnpm run build:browser`
regenerated the kernel.
- `leaf-dev stills 2a9d00d` captured 57 states, reading 33 of the
catalogue's 34 source pages at least once, with extra table, code-block
and thread states. Neither pixels nor computed styles changed in any of
them, except for noise. The three About states differ in the diagnostic
text they print, with no style difference. `on-me` differed once, inside
a closed disclosure whose widget had upgraded in only one arm, and was
unchanged on a rerun. The 34th page's state, `thread-choice-hints`,
times out on both arms. I stopped the full 328-state run because the
machine's load stood at 60–90 and the run would have taken hours.
- The repro and a themed copy of it in Firefox through `leaf-dev probe
--browser firefox`: the same readings as Chromium. Without a theme, all
three restylings are gone. With the reading theme, the page's own
highlighted block keeps its spans, and the plain block, the table's
scrolling and the clearance are as before.
- After merging `main` and removing the attribute: the syntax tests with
the converted face-input test (13 passed), every plain fixture (6
passed, 3 xfailed), `test_page_fixtures_pass_check` on the feature
gallery, the gate and thread selections (16 passed at the first merge),
and `test:runtime` (737 passed). Before the removal, `leaf-dev stills
origin/main` showed `native-code`, `table-scrolled-phone`,
`breakout-captions` and `thread-code-copy` unchanged. The 57-state
reading above was taken before either merge.
- Review fixes (`5e656b671`): the table, face and syntax selections in
`test_render_gate` and `test_render_anchors` (18 passed), every plain
fixture (6 passed, 3 xfailed), `tests/model/test_render_gate.py` (9
passed), `pnpm run check:browser`, and `leaf-dev stills 38eacfe` on
`breakout-captions` (three states), `gallery-wide-schedule`,
`table-scrolled-phone` and `on-me`. All were unchanged except `on-me`,
which showed the same timing noise in a closed disclosure, with no
change to its table.
- After merging `main` again (#5042 and later) and scoping the
registry's identifier advice (`fef592879`): `pnpm run check:browser`
passed, and `test_render_gate`'s table, caption, breakout and clearance
selection passed, 15 tests including the new breakout test.

## Not verified

- WebKit ran the issue's repro and the wrapper case in the independent
review of the previous head. It has not run the no-theme breakout table
fix (`layouts.css`) or anything later.
- The 270 catalogue states beyond the 58 tried. They share their source
pages with states that were read, and the computed-style lists read
every element on the page.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No way to keep a page's own table and code styling

1 participant