Struct comrak::ComrakOptions
[−]
[src]
pub struct ComrakOptions { pub hardbreaks: bool, pub github_pre_lang: bool, pub width: usize, pub ext_strikethrough: bool, pub ext_tagfilter: bool, pub ext_table: bool, pub ext_autolink: bool, pub ext_tasklist: bool, pub ext_superscript: bool, }
Options for both parser and formatter functions.
Fields
hardbreaks: bool
Soft line breaks in the input translate into hard line breaks in the output.
let mut options = ComrakOptions::default(); assert_eq!(markdown_to_html("Hello.\nWorld.\n", &options), "<p>Hello.\nWorld.</p>\n"); options.hardbreaks = true; assert_eq!(markdown_to_html("Hello.\nWorld.\n", &options), "<p>Hello.<br />\nWorld.</p>\n");
github_pre_lang: bool
GitHub-style <pre lang="xyz">
is used for fenced code blocks with info tags.
let mut options = ComrakOptions::default(); assert_eq!(markdown_to_html("``` rust\nfn hello();\n```\n", &options), "<pre><code class=\"language-rust\">fn hello();\n</code></pre>\n"); options.github_pre_lang = true; assert_eq!(markdown_to_html("``` rust\nfn hello();\n```\n", &options), "<pre lang=\"rust\"><code>fn hello();\n</code></pre>\n");
width: usize
The wrap column when outputting CommonMark.
let mut options = ComrakOptions::default(); let node = parse_document(&arena, "hello hello hello hello hello hello", &options); assert_eq!(format_commonmark(node, &options), "hello hello hello hello hello hello\n"); options.width = 20; assert_eq!(format_commonmark(node, &options), "hello hello hello\nhello hello hello\n");
ext_strikethrough: bool
Enables the strikethrough extension from the GFM spec.
let mut options = ComrakOptions::default(); options.ext_strikethrough = true; assert_eq!(markdown_to_html("Hello ~world~ there.\n", &options), "<p>Hello <del>world</del> there.</p>\n");
ext_tagfilter: bool
Enables the tagfilter extension from the GFM spec.
let mut options = ComrakOptions::default(); options.ext_tagfilter = true; assert_eq!(markdown_to_html("Hello <xmp>.\n\n<xmp>", &options), "<p>Hello <xmp>.</p>\n<xmp>\n");
ext_table: bool
Enables the table extension from the GFM spec.
let mut options = ComrakOptions::default(); options.ext_table = true; assert_eq!(markdown_to_html("| a | b |\n|---|---|\n| c | d |\n", &options), "<table>\n<thead>\n<tr>\n<th>a</th>\n<th>b</th>\n</tr>\n</thead>\n\ <tbody>\n<tr>\n<td>c</td>\n<td>d</td>\n</tr></tbody></table>\n");
ext_autolink: bool
Enables the autolink extension from the GFM spec.
let mut options = ComrakOptions::default(); options.ext_autolink = true; assert_eq!(markdown_to_html("Hello www.github.com.\n", &options), "<p>Hello <a href=\"http://www.github.com\">www.github.com</a>.</p>\n");
ext_tasklist: bool
Enables the task list items extension from the GFM spec.
Note that the spec does not define the precise output, so only the bare essentials are rendered.
let mut options = ComrakOptions::default(); options.ext_tasklist = true; assert_eq!(markdown_to_html("* [x] Done\n* [ ] Not done\n", &options), "<ul>\n<li><input type=\"checkbox\" disabled=\"\" checked=\"\" /> Done</li>\n\ <li><input type=\"checkbox\" disabled=\"\" /> Not done</li>\n</ul>\n");
ext_superscript: bool
Enables the superscript Comrak extension.
let mut options = ComrakOptions::default(); options.ext_superscript = true; assert_eq!(markdown_to_html("e = mc^2^.\n", &options), "<p>e = mc<sup>2</sup>.</p>\n");
Trait Implementations
impl Default for ComrakOptions
[src]
fn default() -> ComrakOptions
Returns the "default value" for a type. Read more
impl Debug for ComrakOptions
[src]
impl Clone for ComrakOptions
[src]
fn clone(&self) -> ComrakOptions
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more