markdown
CommonMark subset to HTML: ATX headings (GitHub ids), paragraphs,
fenced code, block quotes (GitHub callouts), nested lists, GFM tables,
thematic breaks, <div> / <section> HTML blocks, footnote markers,
and the inline forms (code, emphasis, strikethrough, links, images,
autolinks, entities, escapes, hard breaks).
Structs
HeadingSource
pub struct HeadingA heading of the document, in order.
1 to 6.
The
idattribute (GitHub's anchor,-1,-2.. on repeats).Plain text (tags dropped).
DocSource
pub struct DocA rendered document.
Text of the first level-1 heading, or
"".
OptionsSource
pub struct OptionsHow to render. Every field has a default: Options { link: .. }.
Maps a link / image destination as written to the emitted
href/src(escaped by the renderer). Default: as written.HTML for the body of a fenced code block, from the info string's first word (
""if none) and the raw code;noneescapes the code as is. Goes inside<pre><code class="language-..">. Default: alwaysnone.
Sourcepub callout: fn(str) -> str = |kind| if kind == "note" { "Note" } else if kind == "tip" { "Tip" } else if kind == "important" { "Important" } else if kind == "warning" { "Warning" } else if kind == "caution" { "Caution" } else { kind }§Title of a
> [!KIND]callout from the lowercased kind (escaped by the renderer). Default:Note,Tip,Important,Warning,Caution, else the kind.
Functions
renderSource
pub fn render(src: str, opts: Options | none = none) -> Doc Markdown from a trusted source as HTML: <div> / <section> blocks
pass through.
render_untrustedSource
pub fn render_untrusted(src: str, opts: Options | none = none) -> Doc Markdown from anywhere (READMEs) as HTML: HTML blocks are text, and a
link or image whose (mapped) destination has a scheme other than
http, https or mailto points to #.
escSource
pub fn esc(s: str) -> str strip_tagsSource
pub fn strip_tags(html: str) -> str Text of an HTML fragment: tags dropped, the basic entities decoded.
slugSource
pub fn slug(text: str) -> str GitHub's heading anchor: lowercase, keep letters / digits / - / _,
spaces become -.