mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
Fixes #11710. ## Problem The tui `Markdown` component printed `<!-- ... -->` comments verbatim. marked lexes them as `html` tokens and both the block and inline `html` cases pushed `token.raw` as text, so comments leaked into every Markdown surface (Extension Updates, What's New, `/changelog`, messages). ``` ## [1.0.0] <!-- release-notes:start --> Fixed a bug. See <!-- todo: link --> the docs. ``` rendered both comments. ## Fix - After lexing (next to `trimPartialClosingFences`, before tokens are cached), remove block `html` tokens that contain only comments, recursing into lists and blockquotes. If the removed comment sat between two blank lines, or at the start/end, one blank line is dropped too, so no extra gap remains. - Block HTML with other content keeps rendering as text, with comments stripped (`<!-- x --> text` renders `text`). - Inline comments are skipped; if text before ended with a space, the next text's leading space is dropped (`See <!-- c --> the docs.` renders `See the docs.`). - An unclosed block comment runs to the end of the block (CommonMark), so streamed comments stay hidden. - Other HTML still renders as text (`with <tag> markers`). Parsing stays in marked; the change only filters tokens marked already produced. Cost: one pass over top-level tokens per lex (cached), a regex on `html` tokens only. ## Tests `packages/tui/test/markdown.test.ts`, "HTML comments": compares rendering with comments against the same Markdown without them (issue repro, blank-line handling, multi-line/unclosed, blockquotes and lists, other HTML kept). This PR is AI-generated. |
||
|---|---|---|
| .. | ||
| agent | ||
| ai | ||
| chord | ||
| codemode | ||
| coding-agent | ||
| durable | ||
| env | ||
| evals | ||
| mcp | ||
| schema | ||
| telemetry | ||
| tui | ||