Struct Extension
pub struct Extension<'c> { pub strikethrough: bool, pub tagfilter: bool, pub table: bool, pub autolink: bool, pub tasklist: bool, pub superscript: bool, pub header_id_prefix: Option<String>, pub header_id_prefix_in_href: bool, pub footnotes: bool, pub inline_footnotes: bool, pub description_lists: bool, pub front_matter_delimiter: Option<String>, pub multiline_block_quotes: bool, pub alerts: bool, pub math_dollars: bool, pub math_latex: bool, pub math_code: bool, pub wikilinks_title_after_pipe: bool, pub wikilinks_title_before_pipe: bool, pub underline: bool, pub subscript: bool, pub spoiler: bool, pub greentext: bool, pub image_url_rewriter: Option<Arc<dyn URLRewriter + 'c>>, pub link_url_rewriter: Option<Arc<dyn URLRewriter + 'c>>, pub cjk_friendly_emphasis: bool, pub subtext: bool, pub highlight: bool, pub insert: bool, pub block_directive: bool }
Options to select extensions.
Fields
strikethrough: boolEnables the strikethrough extension from the GFM spec.
# use ; let mut options = default; options.extension.strikethrough = true; assert_eq!;tagfilter: boolEnables the tagfilter extension from the GFM spec.
# use ; let mut options = default; options.extension.tagfilter = true; options.render.r#unsafe = true; assert_eq!;table: boolEnables the table extension from the GFM spec.
# use ; let mut options = default; options.extension.table = true; assert_eq!;autolink: boolEnables the autolink extension from the GFM spec.
# use ; let mut options = default; options.extension.autolink = true; assert_eq!;tasklist: boolEnables 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.
# use ; let mut options = default; options.extension.tasklist = true; options.render.r#unsafe = true; assert_eq!;superscript: boolEnables the superscript Comrak extension.
# use ; let mut options = default; options.extension.superscript = true; assert_eq!;header_id_prefix: Option<String>Enables the header IDs Comrak extension, with the given ID prefix.
When set, each heading gains an anchor element with an
idattribute formed by prefixing the slugified heading text. This is useful for namespacing heading anchors to avoid collisions when rendered Markdown is embedded alongside other content on a page (e.g. GitHub uses the prefix"user-content-"for this purpose).# use ; let mut options = default; options.extension.header_id_prefix = Some; assert_eq!;header_id_prefix_in_href: boolWhen enabled alongside
header_id_prefix, the header ID prefix is also applied to thehrefanchor in the generated link.Has no effect if
header_id_prefixisNone.# use ; let mut options = default; options.extension.header_id_prefix = Some; options.extension.header_id_prefix_in_href = true; assert_eq!;footnotes: boolEnables the footnotes extension per
cmark-gfm.For usage, see
src/tests.rs. The extension is modelled after Kramdown.# use ; let mut options = default; options.extension.footnotes = true; assert_eq!;inline_footnotes: boolEnables the inline footnotes extension.
Allows inline footnote syntax
^[content]where the content can include inline markup. Inline footnotes are automatically converted to regular footnotes with auto-generated names and share the same numbering sequence.Requires
footnotesto be enabled as well.# use ; let mut options = default; options.extension.footnotes = true; options.extension.inline_footnotes = true; assert_eq!;description_lists: boolEnables 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.
# use ; let mut options = default; options.extension.description_lists = true; assert_eq!;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.
# use ; let mut options = default; options.extension.front_matter_delimiter = Some; assert_eq!;# use ; use parse_document; let mut options = default; options.extension.front_matter_delimiter = Some; let arena = new; let input = "---\nlayout: post\n---\nText\n"; let root = parse_document; let mut buf = Stringnew; format_commonmark; assert_eq!;multiline_block_quotes: boolEnables the multiline block quote extension.
Place
>>>before and after text to make it into a block quote.- -# use ; let mut options = default; options.extension.multiline_block_quotes = true; assert_eq!;alerts: boolEnables GitHub style alerts
# use ; let mut options = default; options.extension.alerts = true; assert_eq!;math_dollars: boolEnables math using dollar syntax.
# use ; let mut options = default; options.extension.math_dollars = true; assert_eq!; assert_eq!;math_latex: boolEnables math using LaTeX-style delimiters.
# use ; let mut options = default; options.extension.math_latex = true; assert_eq!;math_code: boolEnables math using code syntax.
# use ; let mut options = default; options.extension.math_code = true; assert_eq!; assert_eq!;wikilinks_title_after_pipe: boolEnables wikilinks using title after pipe syntax
When both this option and
wikilinks_title_before_pipeare enabled, this option takes precedence.# use ; let mut options = default; options.extension.wikilinks_title_after_pipe = true; assert_eq!;wikilinks_title_before_pipe: boolEnables wikilinks using title before pipe syntax
When both this option and
wikilinks_title_after_pipeare enabled,wikilinks_title_after_pipetakes precedence.# use ; let mut options = default; options.extension.wikilinks_title_before_pipe = true; assert_eq!;underline: boolEnables underlines using double underscores
# use ; let mut options = default; options.extension.underline = true; assert_eq!;subscript: boolEnables subscript text using single tildes.
If the strikethrough option is also enabled, this overrides the single tilde case to output subscript text.
# use ; let mut options = default; options.extension.subscript = true; assert_eq!;spoiler: boolEnables spoilers using double vertical bars
# use ; let mut options = default; options.extension.spoiler = true; assert_eq!;greentext: boolRequires at least one space after a
>character to generate a blockquote, and restarts blockquote nesting across unique lines of input# use ; let mut options = default; options.extension.greentext = true; assert_eq!; assert_eq!;image_url_rewriter: Option<Arc<dyn URLRewriter + 'c>>Wraps embedded image URLs using a function or custom trait object.
# use Arc; # use ; let mut options = default; options.extension.image_url_rewriter = Some; assert_eq!;link_url_rewriter: Option<Arc<dyn URLRewriter + 'c>>Wraps link URLs using a function or custom trait object.
# use Arc; # use ; let mut options = default; options.extension.link_url_rewriter = Some; assert_eq!;cjk_friendly_emphasis: boolRecognizes many emphasis that appear in CJK contexts but are not recognized by plain CommonMark.
# use ; let mut options = default; options.extension.cjk_friendly_emphasis = true; assert_eq!;subtext: boolEnables block scoped subscript that acts similar to a header.
# use ; let mut options = default; options.extension.subtext = true; assert_eq!;highlight: boolEnables highlighting (mark) using
==.# use ; let mut options = default; options.extension.highlight = true; assert_eq!;insert: boolEnables inserted text using
++.# use ; let mut options = default; options.extension.insert = true; assert_eq!;block_directive: boolEnables the container block directive extension.
Container block directives are container blocks that start and end with
:::. The info string after the opening:::is used as the block type.- -# use ; let mut options = default; options.extension.block_directive = true; assert_eq!;
Trait Implementations
impl<'c> Clone for Extension<'c>
fn clone(&self) -> Self
impl<'c> Debug for Extension<'c>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<'c> Default for Extension<'c>
fn default() -> Self
Auto Trait Implementations
impl<'c> Freeze for Extension<'c>
impl<'c> RefUnwindSafe for Extension<'c>
impl<'c> Send for Extension<'c>
impl<'c> Sync for Extension<'c>
impl<'c> Unpin for Extension<'c>
impl<'c> UnsafeUnpin for Extension<'c>
impl<'c> UnwindSafe for Extension<'c>
Blanket Implementations
impl<T> Any for Extension<'c>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Extension<'c>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Extension<'c>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Extension<'c>
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Extension<'c>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Extension<'c>
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Extension<'c>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Extension<'c>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Extension<'c>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>