pub struct ParseOptionsBuilder<'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> ParseOptionsBuilder<'c, S>
impl<'c, S: State> ParseOptionsBuilder<'c, S>
Sourcepub fn build(self) -> ParseOptions<'c>where
S: IsComplete,
pub fn build(self) -> ParseOptions<'c>where
S: IsComplete,
Finish building and return the requested object
Sourcepub fn smart(self, value: bool) -> ParseOptionsBuilder<'c, SetSmart<S>>where
S::Smart: IsUnset,
pub fn smart(self, value: bool) -> ParseOptionsBuilder<'c, SetSmart<S>>where
S::Smart: IsUnset,
Optional (Some / Option setters). Default: false.
Punctuation (quotes, full-stops and hyphens) are converted into ‘smart’ punctuation.
let mut options = Options::default();
assert_eq!(markdown_to_html("'Hello,' \"world\" ...", &options),
"<p>'Hello,' "world" ...</p>\n");
options.parse.smart = true;
assert_eq!(markdown_to_html("'Hello,' \"world\" ...", &options),
"<p>‘Hello,’ “world” …</p>\n");Sourcepub fn maybe_smart(
self,
value: Option<bool>,
) -> ParseOptionsBuilder<'c, SetSmart<S>>where
S::Smart: IsUnset,
pub fn maybe_smart(
self,
value: Option<bool>,
) -> ParseOptionsBuilder<'c, SetSmart<S>>where
S::Smart: IsUnset,
Optional (Some / Option setters). Default: false.
Punctuation (quotes, full-stops and hyphens) are converted into ‘smart’ punctuation.
let mut options = Options::default();
assert_eq!(markdown_to_html("'Hello,' \"world\" ...", &options),
"<p>'Hello,' "world" ...</p>\n");
options.parse.smart = true;
assert_eq!(markdown_to_html("'Hello,' \"world\" ...", &options),
"<p>‘Hello,’ “world” …</p>\n");Sourcepub fn default_info_string(
self,
value: String,
) -> ParseOptionsBuilder<'c, SetDefaultInfoString<S>>where
S::DefaultInfoString: IsUnset,
pub fn default_info_string(
self,
value: String,
) -> ParseOptionsBuilder<'c, SetDefaultInfoString<S>>where
S::DefaultInfoString: IsUnset,
Optional (Some / Option setters).
The default info string for fenced code blocks.
let mut options = Options::default();
assert_eq!(markdown_to_html("```\nfn hello();\n```\n", &options),
"<pre><code>fn hello();\n</code></pre>\n");
options.parse.default_info_string = Some("rust".into());
assert_eq!(markdown_to_html("```\nfn hello();\n```\n", &options),
"<pre><code class=\"language-rust\">fn hello();\n</code></pre>\n");Sourcepub fn maybe_default_info_string(
self,
value: Option<String>,
) -> ParseOptionsBuilder<'c, SetDefaultInfoString<S>>where
S::DefaultInfoString: IsUnset,
pub fn maybe_default_info_string(
self,
value: Option<String>,
) -> ParseOptionsBuilder<'c, SetDefaultInfoString<S>>where
S::DefaultInfoString: IsUnset,
Optional (Some / Option setters).
The default info string for fenced code blocks.
let mut options = Options::default();
assert_eq!(markdown_to_html("```\nfn hello();\n```\n", &options),
"<pre><code>fn hello();\n</code></pre>\n");
options.parse.default_info_string = Some("rust".into());
assert_eq!(markdown_to_html("```\nfn hello();\n```\n", &options),
"<pre><code class=\"language-rust\">fn hello();\n</code></pre>\n");Sourcepub fn relaxed_tasklist_matching(
self,
value: bool,
) -> ParseOptionsBuilder<'c, SetRelaxedTasklistMatching<S>>where
S::RelaxedTasklistMatching: IsUnset,
pub fn relaxed_tasklist_matching(
self,
value: bool,
) -> ParseOptionsBuilder<'c, SetRelaxedTasklistMatching<S>>where
S::RelaxedTasklistMatching: IsUnset,
Sourcepub fn maybe_relaxed_tasklist_matching(
self,
value: Option<bool>,
) -> ParseOptionsBuilder<'c, SetRelaxedTasklistMatching<S>>where
S::RelaxedTasklistMatching: IsUnset,
pub fn maybe_relaxed_tasklist_matching(
self,
value: Option<bool>,
) -> ParseOptionsBuilder<'c, SetRelaxedTasklistMatching<S>>where
S::RelaxedTasklistMatching: IsUnset,
Sourcepub fn relaxed_autolinks(
self,
value: bool,
) -> ParseOptionsBuilder<'c, SetRelaxedAutolinks<S>>where
S::RelaxedAutolinks: IsUnset,
pub fn relaxed_autolinks(
self,
value: bool,
) -> ParseOptionsBuilder<'c, SetRelaxedAutolinks<S>>where
S::RelaxedAutolinks: IsUnset,
Optional (Some / Option setters). Default: false.
Relax parsing of autolinks, allow links to be detected inside brackets
and allow all url schemes. It is intended to allow a very specific type of autolink
detection, such as [this http://and.com that] or {http://foo.com}, on a best can basis.
let mut options = Options::default();
options.extension.autolink = true;
assert_eq!(markdown_to_html("[https://foo.com]", &options),
"<p>[https://foo.com]</p>\n");
options.parse.relaxed_autolinks = true;
assert_eq!(markdown_to_html("[https://foo.com]", &options),
"<p>[<a href=\"https://foo.com\">https://foo.com</a>]</p>\n");Sourcepub fn maybe_relaxed_autolinks(
self,
value: Option<bool>,
) -> ParseOptionsBuilder<'c, SetRelaxedAutolinks<S>>where
S::RelaxedAutolinks: IsUnset,
pub fn maybe_relaxed_autolinks(
self,
value: Option<bool>,
) -> ParseOptionsBuilder<'c, SetRelaxedAutolinks<S>>where
S::RelaxedAutolinks: IsUnset,
Optional (Some / Option setters). Default: false.
Relax parsing of autolinks, allow links to be detected inside brackets
and allow all url schemes. It is intended to allow a very specific type of autolink
detection, such as [this http://and.com that] or {http://foo.com}, on a best can basis.
let mut options = Options::default();
options.extension.autolink = true;
assert_eq!(markdown_to_html("[https://foo.com]", &options),
"<p>[https://foo.com]</p>\n");
options.parse.relaxed_autolinks = true;
assert_eq!(markdown_to_html("[https://foo.com]", &options),
"<p>[<a href=\"https://foo.com\">https://foo.com</a>]</p>\n");Sourcepub fn broken_link_callback(
self,
value: Arc<dyn BrokenLinkCallback + 'c>,
) -> ParseOptionsBuilder<'c, SetBrokenLinkCallback<S>>where
S::BrokenLinkCallback: IsUnset,
pub fn broken_link_callback(
self,
value: Arc<dyn BrokenLinkCallback + 'c>,
) -> ParseOptionsBuilder<'c, SetBrokenLinkCallback<S>>where
S::BrokenLinkCallback: IsUnset,
Optional (Some / Option setters).
In case the parser encounters any potential links that have a broken
reference (e.g [foo] when there is no [foo]: url entry at the
bottom) the provided callback will be called with the reference name,
both in normalized form and unmodified, and the returned pair will be
used as the link destination and title if not None.
let cb = |link_ref: BrokenLinkReference| match link_ref.normalized {
"foo" => Some(ResolvedReference {
url: "https://www.rust-lang.org/".to_string(),
title: "The Rust Language".to_string(),
}),
_ => None,
};
let mut options = Options::default();
options.parse.broken_link_callback = Some(Arc::new(cb));
let output = markdown_to_html(
"# Cool input!\nWow look at this cool [link][foo]. A [broken link] renders as text.",
&options,
);
assert_eq!(output,
"<h1>Cool input!</h1>\n<p>Wow look at this cool \
<a href=\"https://www.rust-lang.org/\" title=\"The Rust Language\">link</a>. \
A [broken link] renders as text.</p>\n");Sourcepub fn maybe_broken_link_callback(
self,
value: Option<Arc<dyn BrokenLinkCallback + 'c>>,
) -> ParseOptionsBuilder<'c, SetBrokenLinkCallback<S>>where
S::BrokenLinkCallback: IsUnset,
pub fn maybe_broken_link_callback(
self,
value: Option<Arc<dyn BrokenLinkCallback + 'c>>,
) -> ParseOptionsBuilder<'c, SetBrokenLinkCallback<S>>where
S::BrokenLinkCallback: IsUnset,
Optional (Some / Option setters).
In case the parser encounters any potential links that have a broken
reference (e.g [foo] when there is no [foo]: url entry at the
bottom) the provided callback will be called with the reference name,
both in normalized form and unmodified, and the returned pair will be
used as the link destination and title if not None.
let cb = |link_ref: BrokenLinkReference| match link_ref.normalized {
"foo" => Some(ResolvedReference {
url: "https://www.rust-lang.org/".to_string(),
title: "The Rust Language".to_string(),
}),
_ => None,
};
let mut options = Options::default();
options.parse.broken_link_callback = Some(Arc::new(cb));
let output = markdown_to_html(
"# Cool input!\nWow look at this cool [link][foo]. A [broken link] renders as text.",
&options,
);
assert_eq!(output,
"<h1>Cool input!</h1>\n<p>Wow look at this cool \
<a href=\"https://www.rust-lang.org/\" title=\"The Rust Language\">link</a>. \
A [broken link] renders as text.</p>\n");