Skip to content

fix(html): parse inline SVG with XML declarations (#3005)#3109

Open
leno23 wants to merge 1 commit into
rust-lang:masterfrom
leno23:fix/svg-xml-decl-parse-3005
Open

fix(html): parse inline SVG with XML declarations (#3005)#3109
leno23 wants to merge 1 commit into
rust-lang:masterfrom
leno23:fix/svg-xml-decl-parse-3005

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

Fixes spurious Saw ? in state TagOpen warnings when books include inline SVG (e.g. from mdbook-d2) that contains XML processing instructions or nested markup.

  • Strip <?xml ...?> (and other <?...?>) before HTML tokenization — invalid in HTML but common in SVG output
  • Tokenize <svg> bodies as raw text (same approach as <style> / <script>), preserving nested tags without html5ever parse errors

Fixes #3005

Test plan

  • cargo test -p mdbook-html parse_html
  • cargo test -p mdbook-html
  • CI

Made with Cursor

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label May 17, 2026
Strip `<?xml ...?>` processing instructions before tokenizing HTML, and
treat `<svg>` content as raw text like `<style>` so nested markup and
PIs do not trigger html5ever parse warnings.

Fixes rust-lang#3005

Co-authored-by: Cursor <cursoragent@cursor.com>
@leno23 leno23 force-pushed the fix/svg-xml-decl-parse-3005 branch from e2e978d to 0d576bd Compare May 17, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: waiting on a review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Saw ? in state TagOpen

2 participants