logo

HTML Filtering

Examples / HTML Filtering

HTML Filtering

Control which HTML tags are allowed in your markdown content using allowHtmlOnly and buildUnsupportedHTML.

Allow All HTML

All HTML tags are rendered as-is. This includes potentially dangerous tags like <script> and <iframe>.

Output

Unrestricted

HTML Filtering Demo

This paragraph has bold and italic markdown formatting.

This is inside a div element.

HTML strong tag and HTML em tag.

Click to expand Hidden content inside details/summary tags.
alert('blocked')

Code Reference

Allow All HTML


<SvelteMarkdown source={markdown} />

Allow Only Safe

import { allowHtmlOnly } from '@humanspeak/svelte-markdown'

const html = allowHtmlOnly(['strong', 'em', 'div', 'span',
    'details', 'summary', 'sup', 'sub', 'cite', 'a'])

<SvelteMarkdown source={markdown} renderers={{ html }} />

Block All HTML

import { buildUnsupportedHTML } from '@humanspeak/svelte-markdown'

const html = buildUnsupportedHTML()

<SvelteMarkdown source={markdown} renderers={{ html }} />