markdown

v0.1.1
0 PublicApp

Provides the <wippy-markdown> custom element for rendering GitHub-Flavored Markdown to sanitized HTML. Uses markdown-it for parsing and sanitize-html for output safety. Conservative default allowlist; widening is a security decision. Part of wippy-swiss.

Apache-2.0 14 downloads
Updated 15 days ago Repository
web-componentsmarkdownsanitize-html

Run

wippy run wippy-swiss/markdown

wippy-swiss/markdown — <wippy-markdown>

Renders GitHub-Flavored Markdown to safe HTML using markdown-it and sanitize-html. The default allowlist is conservative and safe for arbitrary input.

Supported: headings, bold/italic, links, images, ordered/unordered lists (nested), tables with alignment, fenced code blocks with language hints, inline code, blockquotes, strikethrough, autolinks, horizontal rules.

Not supported by default: GFM task lists (- [x]), footnotes (require extra markdown-it plugins not bundled here).

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | content | string | "" | Markdown source text (GFM). | | allowed-tags | string[] | [] | Override the sanitizer tag allowlist. Empty = built-in defaults. Security: only widen for trusted input. | | allowed-attributes | string | "" | JSON-stringified {tag: [attr, ...]} map for sanitize-html. Empty = defaults. |

Example

<wippy-markdown content="# Hello world
This is **bold**, *italic*, and a [link](https://example.com)." />

<wippy-markdown content="## Feature list
- Fast rendering
- Safe by default
- Theme-aware" />

<wippy-markdown content="| Name  | Role    |
|:------|--------:|
| Alice | Admin   |
| Bob   | Viewer  |" />

Dependency declaration

- name: wc-markdown
  kind: ns.dependency
  component: wippy-swiss/markdown
  version: ">=v0.1.0"
  parameters:
    - name: server
      value: app:gateway