Module comrak
CommonMark and GitHub Flavored Markdown parser.
comrak is a 100% CommonMark-compatible Markdown parser
that also supports GitHub Flavored Markdown (GFM) extensions.
It can render Markdown to HTML, CommonMark, or manipulate the AST directly.
The main entry point is markdown_to_html for simple conversions,
or parse_document for AST manipulation.
Options are configured via Options which controls
extensions like tables, strikethrough, and autolinks.
Examples
Basic Markdown to HTML conversion:
use ;
let markdown = "# Hello\n\nThis is **bold** and *italic*.";
let html = markdown_to_html;
assert!;
assert!;
assert!;
Enabling GitHub Flavored Markdown extensions:
use ;
let mut options = default;
options.extension.strikethrough = true;
options.extension.table = true;
options.extension.autolink = true;
let markdown = "~~deleted~~ and https://example.com";
let html = markdown_to_html;
assert!;
assert!;
Modules
- adapters Adapter traits for plugins.
- arena_tree Included from https://github.com/SimonSapin/rust-forest/blob/5783c8be8680b84c0438638bdee07d4e4aca40ac/arena-tree/lib.rs. MIT license (per Cargo.toml).
- html The HTML renderer for the CommonMark AST, as well as helper functions.
- nodes The CommonMark AST.
- plugins Plugins for enhancing the default implementation of comrak can be defined in this module.
Functions
- markdown_to_commonmark Render Markdown back to CommonMark.
- markdown_to_commonmark_xml Render Markdown to CommonMark XML. See https://github.com/commonmark/commonmark-spec/blob/master/CommonMark.dtd.
- markdown_to_commonmark_xml_with_plugins Render Markdown to CommonMark XML using plugins. See https://github.com/commonmark/commonmark-spec/blob/master/CommonMark.dtd.
- markdown_to_html Render Markdown to HTML.
- markdown_to_html_with_plugins Render Markdown to HTML using plugins.
- version Return the version of the crate.
Type Aliases
-
ComrakExtensionOptions
Legacy naming of
ExtensionOptions -
ComrakOptions
Legacy naming of
Options -
ComrakParseOptions
Legacy naming of
ParseOptions -
ComrakPlugins
Legacy naming of
Plugins -
ComrakRenderOptions
Legacy naming of
RenderOptions -
ComrakRenderPlugins
Legacy naming of
RenderPlugins