RenderOptions
import { RenderOptions } from "jsr:@ende/markdown";interface
interface RenderOptionsOptions for render().
Example: Usage
import type { RenderOptions } from "@ende/markdown/types";
import { assertEquals } from "@ende/assert";
const options: RenderOptions = { headingIds: false, html: "escape" };
assertEquals(options.html, "escape");
Properties
headingIds
headingIds?: booleanWrite each heading's Heading.id as its id attribute. Turn
it off for output that matches the CommonMark spec exactly.
Default: true
rewriteLink
rewriteLink?: (url: string, node: Link | Image) => stringChanges the URL of every link and image, including autolinks, but not the links between footnote references and footnotes. The result is escaped for the attribute.
highlight
highlight?: (code: string, lang: string | null) => string | undefinedHighlights the code of a code block. It gets the code without its final
line ending, and the block's language (null if it has none). A string
is inserted as it is, so it must be HTML with the code escaped, inside
<pre><code class="language-…">; undefined renders the code as usual.
html
html?: "allow" | "escape" | "strip"What to do with raw HTML, both HTML blocks and inline HTML:
"allow"writes it as it is, as the CommonMark spec does."escape"writes it as text, so the markup shows. An HTML block becomes a paragraph of that text (without<p>tags in a tight list, like other paragraphs)."strip"leaves it out. A paragraph with nothing left but whitespace is left out too; other containers, such as list items and block quotes, stay.
"escape" and "strip" only cover raw HTML; they don't sanitize link
URLs such as javascript: ones.
Default: "allow"