pub struct ExtensionOptionsBuilder<'c, S: State = Empty> { /* private fields */ }Expand description
Use builder syntax to set the inputs and finish with build().
Implementations§
Source§impl<'c, S: State> ExtensionOptionsBuilder<'c, S>
impl<'c, S: State> ExtensionOptionsBuilder<'c, S>
Sourcepub fn build(self) -> ExtensionOptions<'c>where
S: IsComplete,
pub fn build(self) -> ExtensionOptions<'c>where
S: IsComplete,
Finish building and return the requested object
Sourcepub fn strikethrough(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetStrikethrough<S>>where
S::Strikethrough: IsUnset,
pub fn strikethrough(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetStrikethrough<S>>where
S::Strikethrough: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn maybe_strikethrough(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetStrikethrough<S>>where
S::Strikethrough: IsUnset,
pub fn maybe_strikethrough(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetStrikethrough<S>>where
S::Strikethrough: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn tagfilter(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetTagfilter<S>>where
S::Tagfilter: IsUnset,
pub fn tagfilter(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetTagfilter<S>>where
S::Tagfilter: IsUnset,
Optional (Some / Option setters). Default: false.
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 <xmp>.</p>\n<xmp>\n");Sourcepub fn maybe_tagfilter(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetTagfilter<S>>where
S::Tagfilter: IsUnset,
pub fn maybe_tagfilter(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetTagfilter<S>>where
S::Tagfilter: IsUnset,
Optional (Some / Option setters). Default: false.
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 <xmp>.</p>\n<xmp>\n");Sourcepub fn table(self, value: bool) -> ExtensionOptionsBuilder<'c, SetTable<S>>where
S::Table: IsUnset,
pub fn table(self, value: bool) -> ExtensionOptionsBuilder<'c, SetTable<S>>where
S::Table: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn maybe_table(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetTable<S>>where
S::Table: IsUnset,
pub fn maybe_table(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetTable<S>>where
S::Table: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn autolink(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetAutolink<S>>where
S::Autolink: IsUnset,
pub fn autolink(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetAutolink<S>>where
S::Autolink: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn maybe_autolink(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetAutolink<S>>where
S::Autolink: IsUnset,
pub fn maybe_autolink(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetAutolink<S>>where
S::Autolink: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn tasklist(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetTasklist<S>>where
S::Tasklist: IsUnset,
pub fn tasklist(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetTasklist<S>>where
S::Tasklist: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn maybe_tasklist(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetTasklist<S>>where
S::Tasklist: IsUnset,
pub fn maybe_tasklist(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetTasklist<S>>where
S::Tasklist: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn superscript(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetSuperscript<S>>where
S::Superscript: IsUnset,
pub fn superscript(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetSuperscript<S>>where
S::Superscript: IsUnset,
Sourcepub fn maybe_superscript(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetSuperscript<S>>where
S::Superscript: IsUnset,
pub fn maybe_superscript(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetSuperscript<S>>where
S::Superscript: IsUnset,
Sourcepub fn header_ids(
self,
value: String,
) -> ExtensionOptionsBuilder<'c, SetHeaderIds<S>>where
S::HeaderIds: IsUnset,
pub fn header_ids(
self,
value: String,
) -> ExtensionOptionsBuilder<'c, SetHeaderIds<S>>where
S::HeaderIds: IsUnset,
Optional (Some / Option setters).
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");Sourcepub fn maybe_header_ids(
self,
value: Option<String>,
) -> ExtensionOptionsBuilder<'c, SetHeaderIds<S>>where
S::HeaderIds: IsUnset,
pub fn maybe_header_ids(
self,
value: Option<String>,
) -> ExtensionOptionsBuilder<'c, SetHeaderIds<S>>where
S::HeaderIds: IsUnset,
Optional (Some / Option setters).
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");Sourcepub fn footnotes(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetFootnotes<S>>where
S::Footnotes: IsUnset,
pub fn footnotes(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetFootnotes<S>>where
S::Footnotes: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn maybe_footnotes(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetFootnotes<S>>where
S::Footnotes: IsUnset,
pub fn maybe_footnotes(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetFootnotes<S>>where
S::Footnotes: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn description_lists(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetDescriptionLists<S>>where
S::DescriptionLists: IsUnset,
pub fn description_lists(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetDescriptionLists<S>>where
S::DescriptionLists: IsUnset,
Optional (Some / Option setters). Default: false.
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>\n<dt>Term</dt>\n<dd>\n<p>Definition</p>\n</dd>\n</dl>\n");Sourcepub fn maybe_description_lists(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetDescriptionLists<S>>where
S::DescriptionLists: IsUnset,
pub fn maybe_description_lists(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetDescriptionLists<S>>where
S::DescriptionLists: IsUnset,
Optional (Some / Option setters). Default: false.
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>\n<dt>Term</dt>\n<dd>\n<p>Definition</p>\n</dd>\n</dl>\n");Sourcepub fn front_matter_delimiter(
self,
value: String,
) -> ExtensionOptionsBuilder<'c, SetFrontMatterDelimiter<S>>where
S::FrontMatterDelimiter: IsUnset,
pub fn front_matter_delimiter(
self,
value: String,
) -> ExtensionOptionsBuilder<'c, SetFrontMatterDelimiter<S>>where
S::FrontMatterDelimiter: IsUnset,
Optional (Some / Option setters).
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);Sourcepub fn maybe_front_matter_delimiter(
self,
value: Option<String>,
) -> ExtensionOptionsBuilder<'c, SetFrontMatterDelimiter<S>>where
S::FrontMatterDelimiter: IsUnset,
pub fn maybe_front_matter_delimiter(
self,
value: Option<String>,
) -> ExtensionOptionsBuilder<'c, SetFrontMatterDelimiter<S>>where
S::FrontMatterDelimiter: IsUnset,
Optional (Some / Option setters).
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);Sourcepub fn multiline_block_quotes(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetMultilineBlockQuotes<S>>where
S::MultilineBlockQuotes: IsUnset,
pub fn multiline_block_quotes(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetMultilineBlockQuotes<S>>where
S::MultilineBlockQuotes: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn maybe_multiline_block_quotes(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetMultilineBlockQuotes<S>>where
S::MultilineBlockQuotes: IsUnset,
pub fn maybe_multiline_block_quotes(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetMultilineBlockQuotes<S>>where
S::MultilineBlockQuotes: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn math_dollars(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetMathDollars<S>>where
S::MathDollars: IsUnset,
pub fn math_dollars(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetMathDollars<S>>where
S::MathDollars: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn maybe_math_dollars(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetMathDollars<S>>where
S::MathDollars: IsUnset,
pub fn maybe_math_dollars(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetMathDollars<S>>where
S::MathDollars: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn math_code(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetMathCode<S>>where
S::MathCode: IsUnset,
pub fn math_code(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetMathCode<S>>where
S::MathCode: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn maybe_math_code(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetMathCode<S>>where
S::MathCode: IsUnset,
pub fn maybe_math_code(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetMathCode<S>>where
S::MathCode: IsUnset,
Optional (Some / Option setters). Default: false.
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");Sourcepub fn wikilinks_title_after_pipe(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetWikilinksTitleAfterPipe<S>>where
S::WikilinksTitleAfterPipe: IsUnset,
pub fn wikilinks_title_after_pipe(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetWikilinksTitleAfterPipe<S>>where
S::WikilinksTitleAfterPipe: IsUnset,
Optional (Some / Option setters). Default: false.
Enables wikilinks using title after pipe syntax
[[url|link label]]When both this option and wikilinks_title_before_pipe are enabled, this option takes
precedence.
let mut options = Options::default();
options.extension.wikilinks_title_after_pipe = true;
assert_eq!(markdown_to_html("[[url|link label]]", &options),
"<p><a href=\"url\" data-wikilink=\"true\">link label</a></p>\n");Sourcepub fn maybe_wikilinks_title_after_pipe(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetWikilinksTitleAfterPipe<S>>where
S::WikilinksTitleAfterPipe: IsUnset,
pub fn maybe_wikilinks_title_after_pipe(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetWikilinksTitleAfterPipe<S>>where
S::WikilinksTitleAfterPipe: IsUnset,
Optional (Some / Option setters). Default: false.
Enables wikilinks using title after pipe syntax
[[url|link label]]When both this option and wikilinks_title_before_pipe are enabled, this option takes
precedence.
let mut options = Options::default();
options.extension.wikilinks_title_after_pipe = true;
assert_eq!(markdown_to_html("[[url|link label]]", &options),
"<p><a href=\"url\" data-wikilink=\"true\">link label</a></p>\n");Sourcepub fn wikilinks_title_before_pipe(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetWikilinksTitleBeforePipe<S>>where
S::WikilinksTitleBeforePipe: IsUnset,
pub fn wikilinks_title_before_pipe(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetWikilinksTitleBeforePipe<S>>where
S::WikilinksTitleBeforePipe: IsUnset,
Optional (Some / Option setters). Default: false.
Enables wikilinks using title before pipe syntax
[[link label|url]]When both this option and wikilinks_title_after_pipe are enabled,
wikilinks_title_after_pipe takes precedence.
let mut options = Options::default();
options.extension.wikilinks_title_before_pipe = true;
assert_eq!(markdown_to_html("[[link label|url]]", &options),
"<p><a href=\"url\" data-wikilink=\"true\">link label</a></p>\n");Sourcepub fn maybe_wikilinks_title_before_pipe(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetWikilinksTitleBeforePipe<S>>where
S::WikilinksTitleBeforePipe: IsUnset,
pub fn maybe_wikilinks_title_before_pipe(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetWikilinksTitleBeforePipe<S>>where
S::WikilinksTitleBeforePipe: IsUnset,
Optional (Some / Option setters). Default: false.
Enables wikilinks using title before pipe syntax
[[link label|url]]When both this option and wikilinks_title_after_pipe are enabled,
wikilinks_title_after_pipe takes precedence.
let mut options = Options::default();
options.extension.wikilinks_title_before_pipe = true;
assert_eq!(markdown_to_html("[[link label|url]]", &options),
"<p><a href=\"url\" data-wikilink=\"true\">link label</a></p>\n");Sourcepub fn underline(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetUnderline<S>>where
S::Underline: IsUnset,
pub fn underline(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetUnderline<S>>where
S::Underline: IsUnset,
Sourcepub fn maybe_underline(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetUnderline<S>>where
S::Underline: IsUnset,
pub fn maybe_underline(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetUnderline<S>>where
S::Underline: IsUnset,
Sourcepub fn subscript(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetSubscript<S>>where
S::Subscript: IsUnset,
pub fn subscript(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetSubscript<S>>where
S::Subscript: IsUnset,
Optional (Some / Option setters). Default: false.
Enables subscript text using single tildes.
If the strikethrough option is also enabled, this overrides the single tilde case to output subscript text.
H~2~Olet mut options = Options::default();
options.extension.subscript = true;
assert_eq!(markdown_to_html("H~2~O", &options),
"<p>H<sub>2</sub>O</p>\n");Sourcepub fn maybe_subscript(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetSubscript<S>>where
S::Subscript: IsUnset,
pub fn maybe_subscript(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetSubscript<S>>where
S::Subscript: IsUnset,
Optional (Some / Option setters). Default: false.
Enables subscript text using single tildes.
If the strikethrough option is also enabled, this overrides the single tilde case to output subscript text.
H~2~Olet mut options = Options::default();
options.extension.subscript = true;
assert_eq!(markdown_to_html("H~2~O", &options),
"<p>H<sub>2</sub>O</p>\n");Sourcepub fn spoiler(self, value: bool) -> ExtensionOptionsBuilder<'c, SetSpoiler<S>>where
S::Spoiler: IsUnset,
pub fn spoiler(self, value: bool) -> ExtensionOptionsBuilder<'c, SetSpoiler<S>>where
S::Spoiler: IsUnset,
Optional (Some / Option setters). Default: false.
Enables spoilers using double vertical bars
Darth Vader is ||Luke's father||let mut options = Options::default();
options.extension.spoiler = true;
assert_eq!(markdown_to_html("Darth Vader is ||Luke's father||", &options),
"<p>Darth Vader is <span class=\"spoiler\">Luke's father</span></p>\n");Sourcepub fn maybe_spoiler(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetSpoiler<S>>where
S::Spoiler: IsUnset,
pub fn maybe_spoiler(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetSpoiler<S>>where
S::Spoiler: IsUnset,
Optional (Some / Option setters). Default: false.
Enables spoilers using double vertical bars
Darth Vader is ||Luke's father||let mut options = Options::default();
options.extension.spoiler = true;
assert_eq!(markdown_to_html("Darth Vader is ||Luke's father||", &options),
"<p>Darth Vader is <span class=\"spoiler\">Luke's father</span></p>\n");Sourcepub fn greentext(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetGreentext<S>>where
S::Greentext: IsUnset,
pub fn greentext(
self,
value: bool,
) -> ExtensionOptionsBuilder<'c, SetGreentext<S>>where
S::Greentext: IsUnset,
Optional (Some / Option setters). Default: false.
Requires at least one space after a > character to generate a blockquote,
and restarts blockquote nesting across unique lines of input
>implying implications
> one
> > two
> threelet mut options = Options::default();
options.extension.greentext = true;
assert_eq!(markdown_to_html(">implying implications", &options),
"<p>>implying implications</p>\n");
assert_eq!(markdown_to_html("> one\n> > two\n> three", &options),
concat!(
"<blockquote>\n",
"<p>one</p>\n",
"<blockquote>\n<p>two</p>\n</blockquote>\n",
"<p>three</p>\n",
"</blockquote>\n"));Sourcepub fn maybe_greentext(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetGreentext<S>>where
S::Greentext: IsUnset,
pub fn maybe_greentext(
self,
value: Option<bool>,
) -> ExtensionOptionsBuilder<'c, SetGreentext<S>>where
S::Greentext: IsUnset,
Optional (Some / Option setters). Default: false.
Requires at least one space after a > character to generate a blockquote,
and restarts blockquote nesting across unique lines of input
>implying implications
> one
> > two
> threelet mut options = Options::default();
options.extension.greentext = true;
assert_eq!(markdown_to_html(">implying implications", &options),
"<p>>implying implications</p>\n");
assert_eq!(markdown_to_html("> one\n> > two\n> three", &options),
concat!(
"<blockquote>\n",
"<p>one</p>\n",
"<blockquote>\n<p>two</p>\n</blockquote>\n",
"<p>three</p>\n",
"</blockquote>\n"));Sourcepub fn image_url_rewriter(
self,
value: Arc<dyn URLRewriter + 'c>,
) -> ExtensionOptionsBuilder<'c, SetImageUrlRewriter<S>>where
S::ImageUrlRewriter: IsUnset,
pub fn image_url_rewriter(
self,
value: Arc<dyn URLRewriter + 'c>,
) -> ExtensionOptionsBuilder<'c, SetImageUrlRewriter<S>>where
S::ImageUrlRewriter: IsUnset,
Optional (Some / Option setters).
Wraps embedded image URLs using a function or custom trait object.
let mut options = ComrakOptions::default();
options.extension.image_url_rewriter = Some(Arc::new(
|url: &str| format!("https://safe.example.com?url={}", url)
));
assert_eq!(markdown_to_html("", &options),
"<p><img src=\"https://safe.example.com?url=http://unsafe.example.com/bad.png\" alt=\"\" /></p>\n");Sourcepub fn maybe_image_url_rewriter(
self,
value: Option<Arc<dyn URLRewriter + 'c>>,
) -> ExtensionOptionsBuilder<'c, SetImageUrlRewriter<S>>where
S::ImageUrlRewriter: IsUnset,
pub fn maybe_image_url_rewriter(
self,
value: Option<Arc<dyn URLRewriter + 'c>>,
) -> ExtensionOptionsBuilder<'c, SetImageUrlRewriter<S>>where
S::ImageUrlRewriter: IsUnset,
Optional (Some / Option setters).
Wraps embedded image URLs using a function or custom trait object.
let mut options = ComrakOptions::default();
options.extension.image_url_rewriter = Some(Arc::new(
|url: &str| format!("https://safe.example.com?url={}", url)
));
assert_eq!(markdown_to_html("", &options),
"<p><img src=\"https://safe.example.com?url=http://unsafe.example.com/bad.png\" alt=\"\" /></p>\n");Sourcepub fn link_url_rewriter(
self,
value: Arc<dyn URLRewriter + 'c>,
) -> ExtensionOptionsBuilder<'c, SetLinkUrlRewriter<S>>where
S::LinkUrlRewriter: IsUnset,
pub fn link_url_rewriter(
self,
value: Arc<dyn URLRewriter + 'c>,
) -> ExtensionOptionsBuilder<'c, SetLinkUrlRewriter<S>>where
S::LinkUrlRewriter: IsUnset,
Optional (Some / Option setters).
Wraps link URLs using a function or custom trait object.
let mut options = ComrakOptions::default();
options.extension.link_url_rewriter = Some(Arc::new(
|url: &str| format!("https://safe.example.com/norefer?url={}", url)
));
assert_eq!(markdown_to_html("[my link](http://unsafe.example.com/bad)", &options),
"<p><a href=\"https://safe.example.com/norefer?url=http://unsafe.example.com/bad\">my link</a></p>\n");Sourcepub fn maybe_link_url_rewriter(
self,
value: Option<Arc<dyn URLRewriter + 'c>>,
) -> ExtensionOptionsBuilder<'c, SetLinkUrlRewriter<S>>where
S::LinkUrlRewriter: IsUnset,
pub fn maybe_link_url_rewriter(
self,
value: Option<Arc<dyn URLRewriter + 'c>>,
) -> ExtensionOptionsBuilder<'c, SetLinkUrlRewriter<S>>where
S::LinkUrlRewriter: IsUnset,
Optional (Some / Option setters).
Wraps link URLs using a function or custom trait object.
let mut options = ComrakOptions::default();
options.extension.link_url_rewriter = Some(Arc::new(
|url: &str| format!("https://safe.example.com/norefer?url={}", url)
));
assert_eq!(markdown_to_html("[my link](http://unsafe.example.com/bad)", &options),
"<p><a href=\"https://safe.example.com/norefer?url=http://unsafe.example.com/bad\">my link</a></p>\n");