fix(comark): absorb markdown under incomplete HTML openers - #390
fix(comark): absorb markdown under incomplete HTML openers#390farnabaz wants to merge 9 commits into
Conversation
Leave single-line incomplete open tags (e.g. `<ai-thinking>\n**bold**`) as opener-only html_block tokens so the following markdown can be absorbed as children, matching the blank-line incomplete case.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
comark
@comark/angular
@comark/ansi
@comark/html
@comark/nuxt
@comark/react
@comark/svelte
@comark/vue
commit: |
📦 Bundle size snapshot is out of dateThe published size of one or more packages changed, so the inline snapshot in Please review the diff below. If the change is expected, accept the new snapshot:
Only maintainers with write access can trigger the update. You can also comment Bundle size diff FAIL test/bundle.test.ts > package bundle size > published size of each package
Error: Snapshot `package bundle size > published size of each package 1` mismatched
- Expected
+ Received
@@ -4,7 +4,7 @@
"@comark/html": "18.9k (58 files)",
"@comark/nuxt": "11.8k (58 files)",
"@comark/react": "43.6k (74 files)",
"@comark/svelte": "43.9k (82 files)",
"@comark/vue": "60.5k (78 files)",
- "comark": "440k (156 files)",
+ "comark": "450k (156 files)",
}
❯ test/bundle.test.ts:61:20
59| }
60|
61| expect(report).toMatchInlineSnapshot(`
| ^
62| {
63| "@comark/angular": "60.6k (70 files)",
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯ |
A `$` at end of line (or with only trailing whitespace) is not an incomplete inline-math opener, so auto-close leaves it alone instead of appending `$`.
Incomplete HTML openers with a later matching closer now absorb intervening tokens (including nested same-tag blocks) as children, so cases like details-in-details build a proper tree instead of sibling empties.
Markdown stringify no longer glues `</summary>Nested content`. HTML wrappers with a lone markdown paragraph among HTML siblings still auto-unwrap that paragraph; multi-block bodies keep their `<p>` structure.
◈ PR Lens
Architecture 5 components touched across 2 lanes. Inside the changed components — 2 viewsComponent view — HTML Tokenization & AST Construction HTML block rule tokenization, recursive token-to-AST nesting for matched and streaming tags, and paragraph auto-unwrapping. Component view — HTML AST Serialization HTML stringifier handler logic managing multiline block tag formatting and separator spacing. Data flow
The other flows — 1 sequence
Drill down
|
What
Incomplete block HTML open tags (e.g. streaming
<ai-thinking>…with no closer) now wrap following markdown as children with$: { html: 1, block: 0 }, including the single-newline case where CommonMark would otherwise swallow the body into one rawhtml_block.Why
During AI/streaming output, custom tags often arrive without a closing tag yet. The previous CommonMark-faithful path left the opener empty and the body as siblings, so renderers could not keep the unfinished element around its content. Blank-line-terminated incomplete openers were fixed first; the blank-line-less case still needed the block rule to stop at the opener line so the token processor can absorb the rest.