|
@@ -12,8 +12,12 @@ pub fn markdown(value: Value, args: HashMap<String, Value>) -> TeraResult<Value> |
|
|
None => false, |
|
|
None => false, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let mut opts = cmark::Options::empty(); |
|
|
|
|
|
opts.insert(cmark::OPTION_ENABLE_TABLES); |
|
|
|
|
|
opts.insert(cmark::OPTION_ENABLE_FOOTNOTES); |
|
|
|
|
|
|
|
|
let mut html = String::new(); |
|
|
let mut html = String::new(); |
|
|
let parser = cmark::Parser::new(&s); |
|
|
|
|
|
|
|
|
let parser = cmark::Parser::new_ext(&s, opts); |
|
|
cmark::html::push_html(&mut html, parser); |
|
|
cmark::html::push_html(&mut html, parser); |
|
|
|
|
|
|
|
|
if inline { |
|
|
if inline { |
|
@@ -71,6 +75,21 @@ mod tests { |
|
|
assert_eq!(result.unwrap(), to_value(&"Using <code>map</code>, <code>filter</code>, and <code>fold</code> instead of <code>for</code>").unwrap()); |
|
|
assert_eq!(result.unwrap(), to_value(&"Using <code>map</code>, <code>filter</code>, and <code>fold</code> instead of <code>for</code>").unwrap()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// https://github.com/Keats/gutenberg/issues/417 |
|
|
|
|
|
#[test] |
|
|
|
|
|
fn markdown_filter_inline_tables() { |
|
|
|
|
|
let mut args = HashMap::new(); |
|
|
|
|
|
args.insert("inline".to_string(), to_value(true).unwrap()); |
|
|
|
|
|
let result = markdown(to_value(&r#" |
|
|
|
|
|
|id|author_id| timestamp_created|title |content | |
|
|
|
|
|
|-:|--------:|-----------------------:|:---------------------|:-----------------| |
|
|
|
|
|
| 1| 1|2018-09-05 08:03:43.141Z|How to train your ORM |Badly written blog| |
|
|
|
|
|
| 2| 1|2018-08-22 13:11:50.050Z|How to bake a nice pie|Badly written blog| |
|
|
|
|
|
"#).unwrap(), args); |
|
|
|
|
|
assert!(result.is_ok()); |
|
|
|
|
|
assert!(result.unwrap().as_str().unwrap().contains("<table>")); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
#[test] |
|
|
#[test] |
|
|
fn base64_encode_filter() { |
|
|
fn base64_encode_filter() { |
|
|
// from https://tools.ietf.org/html/rfc4648#section-10 |
|
|
// from https://tools.ietf.org/html/rfc4648#section-10 |
|
|