diff options
author | 2023-10-04 09:33:44 +0200 | |
---|---|---|
committer | 2023-11-30 13:33:06 +0100 | |
commit | 69e2db6efadf2d15514a8947f48acaf174024a57 (patch) | |
tree | f965676406b931a7b767e8bc5f978af50f624178 /askama | |
parent | 21f840a2ad03b23fc9d54f581323b30a3cc9b620 (diff) | |
download | askama-69e2db6efadf2d15514a8947f48acaf174024a57.tar.gz askama-69e2db6efadf2d15514a8947f48acaf174024a57.tar.bz2 askama-69e2db6efadf2d15514a8947f48acaf174024a57.zip |
Upgrade to comrak 0.19
Diffstat (limited to 'askama')
-rw-r--r-- | askama/Cargo.toml | 2 | ||||
-rw-r--r-- | askama/src/filters/mod.rs | 51 |
2 files changed, 12 insertions, 41 deletions
diff --git a/askama/Cargo.toml b/askama/Cargo.toml index 1fe1afa..a4300bc 100644 --- a/askama/Cargo.toml +++ b/askama/Cargo.toml @@ -41,7 +41,7 @@ mime_guess = [] [dependencies] askama_derive = { version = "0.12.0", path = "../askama_derive" } askama_escape = { version = "0.10.3", path = "../askama_escape" } -comrak = { version = "0.18", optional = true, default-features = false } +comrak = { version = "0.19", optional = true, default-features = false } dep_humansize = { package = "humansize", version = "2", optional = true } dep_num_traits = { package = "num-traits", version = "0.2.6", optional = true } percent-encoding = { version = "2.1.0", optional = true } diff --git a/askama/src/filters/mod.rs b/askama/src/filters/mod.rs index a7aa62b..f77e2f8 100644 --- a/askama/src/filters/mod.rs +++ b/askama/src/filters/mod.rs @@ -345,51 +345,22 @@ pub fn wordcount<T: fmt::Display>(s: T) -> Result<usize> { pub fn markdown<E, S>( e: E, s: S, - options: Option<&comrak::ComrakOptions>, + options: Option<&comrak::Options>, ) -> Result<MarkupDisplay<E, String>> where E: Escaper, S: AsRef<str>, { - use comrak::{ - markdown_to_html, ComrakExtensionOptions, ComrakOptions, ComrakParseOptions, - ComrakRenderOptions, ListStyleType, - }; - - const DEFAULT_OPTIONS: ComrakOptions = ComrakOptions { - extension: ComrakExtensionOptions { - strikethrough: true, - tagfilter: true, - table: true, - autolink: true, - // default: - tasklist: false, - superscript: false, - header_ids: None, - footnotes: false, - description_lists: false, - front_matter_delimiter: None, - }, - parse: ComrakParseOptions { - // default: - smart: false, - default_info_string: None, - relaxed_tasklist_matching: false, - }, - render: ComrakRenderOptions { - escape: true, - // default: - hardbreaks: false, - github_pre_lang: false, - full_info_string: false, - width: 0, - unsafe_: false, - list_style: ListStyleType::Dash, - sourcepos: false, - }, - }; - - let s = markdown_to_html(s.as_ref(), options.unwrap_or(&DEFAULT_OPTIONS)); + use comrak::{markdown_to_html, Options}; + + let mut defaults = Options::default(); + defaults.extension.strikethrough = true; + defaults.extension.tagfilter = true; + defaults.extension.table = true; + defaults.extension.autolink = true; + defaults.render.escape = true; + + let s = markdown_to_html(s.as_ref(), options.unwrap_or(&defaults)); Ok(MarkupDisplay::new_safe(s, e)) } |