Struct comrak::ComrakExtensionOptions [−][src]
Options to select extensions.
Fields
strikethrough: bool
Enables the strikethrough extension from the GFM spec.
let mut options = ComrakOptions::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 = ComrakOptions::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");
table: bool
Enables the table extension from the GFM spec.
let mut options = ComrakOptions::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 = ComrakOptions::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 = ComrakOptions::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\" disabled=\"\" checked=\"\" /> Done</li>\n\ <li><input type=\"checkbox\" disabled=\"\" /> Not done</li>\n</ul>\n");
superscript: bool
Enables the superscript Comrak extension.
let mut options = ComrakOptions::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 = ComrakOptions::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 = ComrakOptions::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=\"#fn1\" id=\"fnref1\">1</a></sup>.</p>\n<section class=\"footnotes\">\n<ol>\n<li id=\"fn1\">\n<p>A greeting. <a href=\"#fnref1\" class=\"footnote-backref\">↩</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.
First term
: Details for the **first term**
Second term
: Details for the **second term**
More details in second paragraph.
let mut options = ComrakOptions::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 = ComrakOptions::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", &ComrakOptions::default()));
use comrak::parse_document; let mut options = ComrakOptions::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);
Trait Implementations
impl Clone for ComrakExtensionOptions
[src]
fn clone(&self) -> ComrakExtensionOptions
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ComrakExtensionOptions
[src]
impl Default for ComrakExtensionOptions
[src]
fn default() -> ComrakExtensionOptions
[src]
Auto Trait Implementations
impl RefUnwindSafe for ComrakExtensionOptions
impl Send for ComrakExtensionOptions
impl Sync for ComrakExtensionOptions
impl Unpin for ComrakExtensionOptions
impl UnwindSafe for ComrakExtensionOptions
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,