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

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-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");

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");

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");

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 &lt;xmp>.</p>\n&lt;xmp>\n");

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");

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");

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");

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]

Returns the "default value" for a type. Read more

impl Debug for ComrakOptions
[src]

Formats the value using the given formatter.

impl Clone for ComrakOptions
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Copy for ComrakOptions
[src]