fix: parse SVG as HTML tokens instead of deferring to markdown#114
Merged
fix: parse SVG as HTML tokens instead of deferring to markdown#114
Conversation
Multi-line SVG tags were HTML-escaped because the tokenizer treated <svg>…</svg> as opaque text, which went through micromark (CommonMark doesn't recognize SVG as a type 6 HTML block tag). Remove the SVG special case so <svg> is tokenized like any other HTML tag, rendering via Preact's h() which handles SVG namespace correctly. Also preserve original tag case in tokens (SVG needs camelCase for elements like linearGradient, clipPath) while keeping case-insensitive matching in the AST builder for open/close tag pairing. Closes #113 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Release preview: merging this PR will publish v0.36.2 (patch bump from v0.36.1) |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||
SVG children rendered via renderNodes() went through markdown, which wraps content in <p> tags — breaking SVG namespace and producing zero-dimension elements. Add SvgContext to skip markdown for all descendants inside <svg>, using renderInlineNodes() instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<svg>…</svg>as opaque text deferred to markdown — multi-line SVG tags were HTML-escaped because micromark doesn't recognize SVG as a type 6 HTML block taglinearGradient,clipPath, etc.) render correctly, while keeping case-insensitive matching in the AST builderTest plan
<svg>produces correct HtmlTokens<svg>produces correct HtmlTokens<svg>nested inside<div>tokenizes correctlylinearGradient) preserve tag nameCloses #113
🤖 Generated with Claude Code