The tokenizer is framework-agnostic — it emits an svgCodeBlock token whose
svgContent can be rendered to HTML (web) or to a native SVG component
(React Native via react-native-svg). The HTML renderer below is only used
by the web/HTML output path.
Security note: SVG content is rendered as-is. Make sure to only render
trusted SVG content or sanitize it on the target platform when rendering
user-provided content.
Creates a marked extension that renders SVG code blocks as actual SVG images.
When encountering a code block with language "svg", this extension will render it as an actual SVG element instead of showing the code.
This is useful for:
Usage in markdown:
The generated HTML structure:
The tokenizer is framework-agnostic — it emits an
svgCodeBlocktoken whosesvgContentcan be rendered to HTML (web) or to a native SVG component (React Native via react-native-svg). The HTMLrendererbelow is only used by the web/HTML output path.Security note: SVG content is rendered as-is. Make sure to only render trusted SVG content or sanitize it on the target platform when rendering user-provided content.