Security
The HTML renderer:
- Escapes text content.
- Treats raw HTML in Markdown as escaped text by default.
- Preserves raw HTML only when compatibility mode is enabled, while escaping GFM-disallowed tag starters.
- Allows only safe generated HTML tag and attribute names.
- Ignores event attributes such as
onclick. - Rejects unsafe URLs such as
javascript:anddata:. - Keeps the text of an unsafe link and marks it with
data-markvia-unsafe-url="true".
Compatibility mode is available only for the HTML renderer:
import { createHTMLRenderer } from '@markvia/html'
const renderer = createHTMLRenderer({ allowRawHtml: true })const html = runtime.render(source, renderer)React and Vue do not expose a raw HTML opt-in and always output raw HTML as safe text. Even in HTML compatibility mode, GFM-disallowed iframe, script, style, textarea, title, and xmp tag starters are not passed through.
Safe HTML output
<script>alert(1)</script>
<p data-markvia-node-id="mv-paragraph-1cw6uly"><a data-markvia-node-id="mv-link-1cd8feu" data-markvia-unsafe-url="true">run</a></p><script>alert(1)</script>Custom renderers
Section titled “Custom renderers”If an application needs a different security policy, process Markvia output before passing it to the DOM or a template system, while keeping the URL validation boundary intact. Never pass unvalidated user input directly to Astro’s set:html.