#[non_exhaustive]
pub struct ExtensionOptions {
Show 14 fields pub strikethrough: bool, pub tagfilter: bool, pub table: bool, pub autolink: bool, pub tasklist: bool, pub superscript: bool, pub header_ids: Option<String>, pub footnotes: bool, pub description_lists: bool, pub front_matter_delimiter: Option<String>, pub multiline_block_quotes: bool, pub math_dollars: bool, pub math_code: bool, pub shortcodes: bool,
}
Expand description

Options to select extensions.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§strikethrough: bool

Enables the strikethrough extension from the GFM spec.

let mut options = Options::default();
options.extension.strikethrough = true;
assert_eq!(markdown_to_html("Hello ~world~ there.\n", &options),
           "<p>Hello <del>world</del> there.</p>\n");
§tagfilter: bool

Enables the tagfilter extension from the GFM spec.

let mut options = Options::default();
options.extension.tagfilter = true;
options.render.unsafe_ = true;
assert_eq!(markdown_to_html("Hello <xmp>.\n\n<xmp>", &options),
           "<p>Hello &lt;xmp>.</p>\n&lt;xmp>\n");
§table: bool

Enables the table extension from the GFM spec.

let mut options = Options::default();
options.extension.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>\n</tbody>\n</table>\n");
§autolink: bool

Enables the autolink extension from the GFM spec.

let mut options = Options::default();
options.extension.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");
§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 = Options::default();
options.extension.tasklist = true;
options.render.unsafe_ = true;
assert_eq!(markdown_to_html("* [x] Done\n* [ ] Not done\n", &options),
           "<ul>\n<li><input type=\"checkbox\" checked=\"\" disabled=\"\" /> Done</li>\n\
           <li><input type=\"checkbox\" disabled=\"\" /> Not done</li>\n</ul>\n");
§superscript: bool

Enables the superscript Comrak extension.

let mut options = Options::default();
options.extension.superscript = true;
assert_eq!(markdown_to_html("e = mc^2^.\n", &options),
           "<p>e = mc<sup>2</sup>.</p>\n");
§header_ids: Option<String>

Enables the header IDs Comrak extension.

let mut options = Options::default();
options.extension.header_ids = Some("user-content-".to_string());
assert_eq!(markdown_to_html("# README\n", &options),
           "<h1><a href=\"#readme\" aria-hidden=\"true\" class=\"anchor\" id=\"user-content-readme\"></a>README</h1>\n");
§footnotes: bool

Enables the footnotes extension per cmark-gfm.

For usage, see src/tests.rs. The extension is modelled after Kramdown.

let mut options = Options::default();
options.extension.footnotes = true;
assert_eq!(markdown_to_html("Hi[^x].\n\n[^x]: A greeting.\n", &options),
           "<p>Hi<sup class=\"footnote-ref\"><a href=\"#fn-x\" id=\"fnref-x\" data-footnote-ref>1</a></sup>.</p>\n<section class=\"footnotes\" data-footnotes>\n<ol>\n<li id=\"fn-x\">\n<p>A greeting. <a href=\"#fnref-x\" class=\"footnote-backref\" data-footnote-backref data-footnote-backref-idx=\"1\" aria-label=\"Back to reference 1\">↩</a></p>\n</li>\n</ol>\n</section>\n");
§description_lists: bool

Enables the description lists extension.

Each term must be defined in one paragraph, followed by a blank line, and then by the details. Details begins with a colon.

Not (yet) compatible with render.sourcepos.

First term

: Details for the **first term**

Second term

: Details for the **second term**

    More details in second paragraph.
let mut options = Options::default();
options.extension.description_lists = true;
assert_eq!(markdown_to_html("Term\n\n: Definition", &options),
           "<dl><dt>Term</dt>\n<dd>\n<p>Definition</p>\n</dd>\n</dl>\n");
§front_matter_delimiter: Option<String>

Enables the front matter extension.

Front matter, which begins with the delimiter string at the beginning of the file and ends at the end of the next line that contains only the delimiter, is passed through unchanged in markdown output and omitted from HTML output.

---
layout: post
title: Formatting Markdown with Comrak
---

# Shorter Title

etc.
let mut options = Options::default();
options.extension.front_matter_delimiter = Some("---".to_owned());
assert_eq!(
    markdown_to_html("---\nlayout: post\n---\nText\n", &options),
    markdown_to_html("Text\n", &Options::default()));
use comrak::parse_document;
let mut options = Options::default();
options.extension.front_matter_delimiter = Some("---".to_owned());
let arena = Arena::new();
let input ="---\nlayout: post\n---\nText\n";
let root = parse_document(&arena, input, &options);
let mut buf = Vec::new();
format_commonmark(&root, &options, &mut buf);
assert_eq!(&String::from_utf8(buf).unwrap(), input);
§multiline_block_quotes: bool

Enables the multiline block quote extension.

Place >>> before and after text to make it into a block quote.

Paragraph one

>>>
Paragraph two

- one
- two
>>>
let mut options = Options::default();
options.extension.multiline_block_quotes = true;
assert_eq!(markdown_to_html(">>>\nparagraph\n>>>", &options),
           "<blockquote>\n<p>paragraph</p>\n</blockquote>\n");
§math_dollars: bool

Enables math using dollar syntax.

Inline math $1 + 2$ and display math $$x + y$$

$$
x^2
$$
let mut options = Options::default();
options.extension.math_dollars = true;
assert_eq!(markdown_to_html("$1 + 2$ and $$x = y$$", &options),
           "<p><span data-math-style=\"inline\">1 + 2</span> and <span data-math-style=\"display\">x = y</span></p>\n");
assert_eq!(markdown_to_html("$$\nx^2\n$$\n", &options),
           "<p><span data-math-style=\"display\">\nx^2\n</span></p>\n");
§math_code: bool

Enables math using code syntax.

Inline math $`1 + 2`$

```math
x^2
```
let mut options = Options::default();
options.extension.math_code = true;
assert_eq!(markdown_to_html("$`1 + 2`$", &options),
           "<p><code data-math-style=\"inline\">1 + 2</code></p>\n");
assert_eq!(markdown_to_html("```math\nx^2\n```\n", &options),
           "<pre><code class=\"language-math\" data-math-style=\"display\">x^2\n</code></pre>\n");
§shortcodes: bool
Available on crate feature shortcodes only.

Phrases wrapped inside of ‘:’ blocks will be replaced with emojis.

let mut options = Options::default();
assert_eq!(markdown_to_html("Happy Friday! :smile:", &options),
           "<p>Happy Friday! :smile:</p>\n");

options.extension.shortcodes = true;
assert_eq!(markdown_to_html("Happy Friday! :smile:", &options),
           "<p>Happy Friday! 😄</p>\n");

Trait Implementations§

source§

impl<'arbitrary> Arbitrary<'arbitrary> for ExtensionOptions

source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
source§

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
source§

impl Clone for ExtensionOptions

source§

fn clone(&self) -> ExtensionOptions

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ExtensionOptions

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ExtensionOptions

source§

fn default() -> ExtensionOptions

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.