@guesttalk/markdown
The optional Markdown renderer for @guesttalk/core. It turns comment
bodies into sanitized HTML using marked +
sanitize-html.
@guesttalk/core has zero runtime dependencies. This package is where the
Markdown dependencies live, so you only install them if you actually render
Markdown.
Install
bun add @guesttalk/core @guesttalk/markdown
marked + sanitize-html come in automatically as dependencies of this package.
Use
import { createGuestTalk } from "@guesttalk/core/server"
import { createMarkdownRenderer } from "@guesttalk/markdown"
export const guesttalk = createGuestTalk({
storage,
renderContent: createMarkdownRenderer(),
})
Without renderContent, @guesttalk/core renders comments as safe, escaped
plain text (no dependencies). Pass createMarkdownRenderer() to opt into the
Markdown subset instead.
Options
createMarkdownRenderer(options) accepts:
| Option | Default | Meaning |
|---|---|---|
allowLinks |
true |
Render [label](url) links (limited to http(s) and mailto), with safe rel/target. |
allowImages |
false |
false strips images; true allows any http(s) / data:image/*; "uploaded" allows only srcs listed in the comment's metadata.uploads. |
maxLength |
10000 |
Defensive truncation cap for the images-off path. |
The supported Markdown subset: **bold**, *italic*, `code`, fenced and
indented code blocks, > blockquotes, ordered/unordered lists, headings,
tables, --- rules, links, and (when enabled) images. Raw HTML is sanitized.
See the configuration guide for the full picture, including custom renderers.
License
MIT