[−][src]Struct comrak::ComrakRenderOptions
Options for formatter functions.
Fields
hardbreaks: bool
Soft line breaks in the input translate into hard line breaks in the output.
let mut options = ComrakOptions::default(); assert_eq!(markdown_to_html("Hello.\nWorld.\n", &options), "<p>Hello.\nWorld.</p>\n"); options.render.hardbreaks = true; assert_eq!(markdown_to_html("Hello.\nWorld.\n", &options), "<p>Hello.<br />\nWorld.</p>\n");
github_pre_lang: bool
GitHub-style <pre lang="xyz">
is used for fenced code blocks with info tags.
let mut options = ComrakOptions::default(); assert_eq!(markdown_to_html("``` rust\nfn hello();\n```\n", &options), "<pre><code class=\"language-rust\">fn hello();\n</code></pre>\n"); options.render.github_pre_lang = true; assert_eq!(markdown_to_html("``` rust\nfn hello();\n```\n", &options), "<pre lang=\"rust\"><code>fn hello();\n</code></pre>\n");
width: usize
The wrap column when outputting CommonMark.
let mut options = ComrakOptions::default(); let node = parse_document(&arena, "hello hello hello hello hello hello", &options); let mut output = vec![]; format_commonmark(node, &options, &mut output).unwrap(); assert_eq!(String::from_utf8(output).unwrap(), "hello hello hello hello hello hello\n"); options.render.width = 20; let mut output = vec![]; format_commonmark(node, &options, &mut output).unwrap(); assert_eq!(String::from_utf8(output).unwrap(), "hello hello hello\nhello hello hello\n");
unsafe_: bool
Allow rendering of raw HTML and potentially dangerous links.
let mut options = ComrakOptions::default(); let input = "<script>\nalert('xyz');\n</script>\n\n\ Possibly <marquee>annoying</marquee>.\n\n\ [Dangerous](javascript:alert(document.cookie)).\n\n\ [Safe](http://commonmark.org).\n"; assert_eq!(markdown_to_html(input, &options), "<!-- raw HTML omitted -->\n\ <p>Possibly <!-- raw HTML omitted -->annoying<!-- raw HTML omitted -->.</p>\n\ <p><a href=\"\">Dangerous</a>.</p>\n\ <p><a href=\"http://commonmark.org\">Safe</a>.</p>\n"); options.render.unsafe_ = true; assert_eq!(markdown_to_html(input, &options), "<script>\nalert(\'xyz\');\n</script>\n\ <p>Possibly <marquee>annoying</marquee>.</p>\n\ <p><a href=\"javascript:alert(document.cookie)\">Dangerous</a>.</p>\n\ <p><a href=\"http://commonmark.org\">Safe</a>.</p>\n");
escape: bool
Escape raw HTML instead of clobbering it.
let mut options = ComrakOptions::default(); let input = "<i>italic text</i>"; assert_eq!(markdown_to_html(input, &options), "<p><!-- raw HTML omitted -->italic text<!-- raw HTML omitted --></p>\n"); options.render.escape = true; assert_eq!(markdown_to_html(input, &options), "<p><i>italic text</i></p>\n");
Trait Implementations
impl Clone for ComrakRenderOptions
[src]
fn clone(&self) -> ComrakRenderOptions
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for ComrakRenderOptions
[src]
impl Debug for ComrakRenderOptions
[src]
impl Default for ComrakRenderOptions
[src]
fn default() -> ComrakRenderOptions
[src]
Auto Trait Implementations
impl RefUnwindSafe for ComrakRenderOptions
impl Send for ComrakRenderOptions
impl Sync for ComrakRenderOptions
impl Unpin for ComrakRenderOptions
impl UnwindSafe for ComrakRenderOptions
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>,