Skip to content

Refuse a message the HTML parser repairs for the repair alone, before drawing it - #6312

Merged
max-sixty merged 1 commit into
mainfrom
commonmark-message-html
Nov 18, 2026
Merged

max-sixty merged 1 commit into
mainfrom
commonmark-message-html

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

An agent's message whose widget opens on the same line as its content, such as <lf-code id="x"><pre>…</pre></lf-code>, is refused for what CommonMark does to it, and only that. CommonMark reads a custom tag sharing its line as inline HTML, so Markdown draws a paragraph around it and the <pre> closes that paragraph along with the widget. Before, the agent got a browser stack trace (<lf-code> has no data body) from the draw check, which runs before the markup gate. Now the draw check leaves markup the HTML parser repairs to the gate, and the gate's fragment stage reports a repair's findings alone, as its later stages already do. The refusal reads:

the HTML in the comment doesn't validate. Its Markdown draws this HTML, where the findings count lines:
   1  <p>Here:</p>
   2  <p><lf-code id="snippet"><pre><code class="language-python">print(1)</code></pre></lf-code></p>
Findings:
  - unclosed tags: <lf-code> (line 2)

Max asked what the standard handling is for widgets written on one line (open item #8 from #6247). It's what Leaf's readers already do: a parser can't tell whether a custom element is block or inline, so CommonMark starts a block of HTML at one only when its tag is alone on its line (jgm in commonmark/commonmark-spec#758 and commonmark/commonmark-spec#239; commonmark/commonmark-spec#770, which would make hyphenated tags block-level, is still open). GitHub and markdown-it follow that. VitePress departs from it by treating every tag missing from a list of inline tags as block-level. Since #6256 a question is a <section role="group"> or <fieldset>, which CommonMark reads as a block even on one line, so this rule now matters only for a data widget written on one line.

Ran the model and process tests around message markup, and the journey test for a widget that fails to draw.

This was written by Claude Code on behalf of max-sixty

… drawing it

A widget whose opening tag shares its line with its content, such as
`<lf-code id="x"><pre>…</pre></lf-code>`, is inline HTML by CommonMark's
rules, so Markdown draws a paragraph around it and the `<pre>` closes that
paragraph along with the widget. The agent then got a browser stack trace
("<lf-code> has no data body") from the draw check, which ran before the
markup gate; with the draw skipped, the gate added a `data-body` finding about
the widget the repair emptied.

Now the draw check leaves markup the parser repairs to the markup gate, and
the gate's fragment stage reports a repair's findings alone, as its stages
already do for every later check. The refusal shows the HTML Markdown drew,
`<p><lf-code …><pre>`, and "unclosed tags: <lf-code>".

CommonMark starts a block of HTML at a custom tag only when the tag is alone on
its line, since a parser can't tell whether a custom element is block or
inline (jgm in commonmark/commonmark-spec#758 and #239; #770, which would
make hyphenated tags block-level, is open). GitHub and markdown-it follow it,
as Leaf's readers do. Questions are a `<section role="group">` or
`<fieldset>` since #6256, which CommonMark reads as a block on one line.
@max-sixty
max-sixty merged commit 993baa3 into main Nov 18, 2026
5 checks passed
@max-sixty
max-sixty deleted the commonmark-message-html branch November 18, 2026 04:14
max-sixty added a commit that referenced this pull request Nov 18, 2026
…e panel's stop (#6353)

A click on empty space or words in an open tab panel focused the panel,
because its `tabindex=0` makes it click-focusable. `c` then commented on
the whole tab ("Comment on tab · #6312 …"), and no ring showed it. Now
the press lands where it would without the panel's stop: on the nearest
other focusable box around the panel, or nowhere. So `c` gives "Comment
on the page", as it does on a plain page. Tabbing onto the panel still
puts the user on it.

Worth weighing:

- DOM focus stays on the panel until the release, because Chromium ends
a drag's selection when focus moves mid-drag. Until then, `focused()`,
holds and the focus paint read where the press will land.
- A tap's focus arrives at its click, so it passes a task later;
otherwise Chromium drops the caret.
- WebKit drops a collapsed caret on blur, so the caret is put back.
- The stop that reach.js lends an overflowing box keeps its press focus,
because a click on a diff's or a code block's scrollport is what puts
the user in that widget's keys. So a click on a wide table still makes
`c` comment on the table, at widths where the table overflows.

Max asked for this on a Leaf page. Codex and a fresh Claude Code agent
each reviewed it.

Tests:
- New `focus.test.mjs` cases cover each route.
- 418 focused browser tests pass.
- `leaf-dev probe`, base against head: Chromium, Firefox and WebKit,
plus Chromium touch.

> _This was written by Claude Code on behalf of max-sixty_
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.

2 participants