Skip to main content

<st-markdown>

Renders Markdown (GFM, single newlines become <br>) from either an inline content string or a src URL it fetches. Output is sanitized with DOMPurify. src wins over content when both are set. While a fetch is pending it shows "Loading content..."; on failure "Error loading content." and a markdown-error event (detail: { error }).

Text color is inherited from the parent so inverted containers just work.

list-style="check" replaces the bullets of unordered lists with a check mark, in the colour of --st-markdown-list-check-color (navy by default).

Code blocks are a dark navy panel (14px monospace, 20px padding, 12px corners) that scrolls sideways only when a line is wider than the block; ```json fences get syntax colours. Inline code is a chip tinted from the surrounding text colour.

Usage​

import '@sankhyatronics/sankhya-cms/markdown'; // registers <st-markdown>

Properties​

PropertyAttributeTypeDefaultDescription
contentcontentstring''Inline Markdown source. Ignored when src is set.
srcsrcstring''URL of a Markdown file to fetch.
listStylelist-style'default' | 'check''default'default keeps bullets; check shows a check mark on each unordered item.

Events​

EventDetailDescription
markdown-errorCustomEvent

See the live examples in Storybook.