|
|
@@ -5,6 +5,7 @@ extern crate rendering; |
|
|
|
extern crate config; |
|
|
|
|
|
|
|
use std::collections::HashMap; |
|
|
|
use std::path::Path; |
|
|
|
|
|
|
|
use tera::Tera; |
|
|
|
|
|
|
@@ -19,7 +20,7 @@ fn can_do_render_content_simple() { |
|
|
|
let tera_ctx = Tera::default(); |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("hello", &context).unwrap(); |
|
|
|
assert_eq!(res.0, "<p>hello</p>\n"); |
|
|
|
} |
|
|
@@ -30,7 +31,7 @@ fn doesnt_highlight_code_block_with_highlighting_off() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let mut config = Config::default(); |
|
|
|
config.highlight_code = false; |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("```\n$ gutenberg server\n```", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -43,7 +44,7 @@ fn can_highlight_code_block_no_lang() { |
|
|
|
let tera_ctx = Tera::default(); |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("```\n$ gutenberg server\n$ ping\n```", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -56,7 +57,7 @@ fn can_highlight_code_block_with_lang() { |
|
|
|
let tera_ctx = Tera::default(); |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("```python\nlist.append(1)\n```", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -69,7 +70,7 @@ fn can_higlight_code_block_with_unknown_lang() { |
|
|
|
let tera_ctx = Tera::default(); |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("```yolo\nlist.append(1)\n```", &context).unwrap(); |
|
|
|
// defaults to plain text |
|
|
|
assert_eq!( |
|
|
@@ -82,7 +83,7 @@ fn can_higlight_code_block_with_unknown_lang() { |
|
|
|
fn can_render_shortcode() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content(r#" |
|
|
|
Hello |
|
|
|
|
|
|
@@ -96,7 +97,7 @@ Hello |
|
|
|
fn can_render_shortcode_with_markdown_char_in_args_name() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let input = vec![ |
|
|
|
"name", |
|
|
|
"na_me", |
|
|
@@ -113,7 +114,7 @@ fn can_render_shortcode_with_markdown_char_in_args_name() { |
|
|
|
fn can_render_shortcode_with_markdown_char_in_args_value() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let input = vec![ |
|
|
|
"ub36ffWAqgQ-hey", |
|
|
|
"ub36ffWAqgQ_hey", |
|
|
@@ -140,7 +141,7 @@ fn can_render_body_shortcode_with_markdown_char_in_name() { |
|
|
|
|
|
|
|
for i in input { |
|
|
|
tera.add_raw_template(&format!("shortcodes/{}.html", i), "<blockquote>{{ body }} - {{ author}}</blockquote>").unwrap(); |
|
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
|
|
|
|
let res = render_content(&format!("{{% {}(author=\"Bob\") %}}\nhey\n{{% end %}}", i), &context).unwrap(); |
|
|
|
println!("{:?}", res); |
|
|
@@ -169,7 +170,7 @@ Here is another paragraph. |
|
|
|
|
|
|
|
tera.add_raw_template(&format!("shortcodes/{}.html", "figure"), shortcode).unwrap(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
|
|
|
|
let res = render_content(markdown_string, &context).unwrap(); |
|
|
|
println!("{:?}", res); |
|
|
@@ -202,7 +203,7 @@ Here is another paragraph. |
|
|
|
|
|
|
|
tera.add_raw_template(&format!("shortcodes/{}.html", "figure"), shortcode).unwrap(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
|
|
|
|
let res = render_content(markdown_string, &context).unwrap(); |
|
|
|
println!("{:?}", res); |
|
|
@@ -213,7 +214,7 @@ Here is another paragraph. |
|
|
|
fn can_render_several_shortcode_in_row() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content(r#" |
|
|
|
Hello |
|
|
|
|
|
|
@@ -240,7 +241,7 @@ fn doesnt_render_ignored_shortcodes() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let mut config = Config::default(); |
|
|
|
config.highlight_code = false; |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content(r#"```{{/* youtube(id="w7Ft2ymGmfc") */}}```"#, &context).unwrap(); |
|
|
|
assert_eq!(res.0, "<p><code>{{ youtube(id="w7Ft2ymGmfc") }}</code></p>\n"); |
|
|
|
} |
|
|
@@ -252,7 +253,7 @@ fn can_render_shortcode_with_body() { |
|
|
|
tera.add_raw_template("shortcodes/quote.html", "<blockquote>{{ body }} - {{ author }}</blockquote>").unwrap(); |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
|
|
|
|
let res = render_content(r#" |
|
|
|
Hello |
|
|
@@ -268,7 +269,7 @@ fn errors_rendering_unknown_shortcode() { |
|
|
|
let tera_ctx = Tera::default(); |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("{{ hello(flash=true) }}", &context); |
|
|
|
assert!(res.is_err()); |
|
|
|
} |
|
|
@@ -279,10 +280,10 @@ fn can_make_valid_relative_link() { |
|
|
|
permalinks.insert("pages/about.md".to_string(), "https://vincent.is/about".to_string()); |
|
|
|
let tera_ctx = Tera::default(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content( |
|
|
|
r#"[rel link](./pages/about.md), [abs link](https://vincent.is/about)"#, |
|
|
|
&context |
|
|
|
&context, |
|
|
|
).unwrap(); |
|
|
|
|
|
|
|
assert!( |
|
|
@@ -296,7 +297,7 @@ fn can_make_relative_links_with_anchors() { |
|
|
|
permalinks.insert("pages/about.md".to_string(), "https://vincent.is/about".to_string()); |
|
|
|
let tera_ctx = Tera::default(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content(r#"[rel link](./pages/about.md#cv)"#, &context).unwrap(); |
|
|
|
|
|
|
|
assert!( |
|
|
@@ -309,7 +310,7 @@ fn errors_relative_link_inexistant() { |
|
|
|
let tera_ctx = Tera::default(); |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("[rel link](./pages/about.md)", &context); |
|
|
|
assert!(res.is_err()); |
|
|
|
} |
|
|
@@ -319,7 +320,7 @@ fn can_add_id_to_headers() { |
|
|
|
let tera_ctx = Tera::default(); |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content(r#"# Hello"#, &context).unwrap(); |
|
|
|
assert_eq!(res.0, "<h1 id=\"hello\">Hello</h1>\n"); |
|
|
|
} |
|
|
@@ -329,7 +330,7 @@ fn can_add_id_to_headers_same_slug() { |
|
|
|
let tera_ctx = Tera::default(); |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("# Hello\n# Hello", &context).unwrap(); |
|
|
|
assert_eq!(res.0, "<h1 id=\"hello\">Hello</h1>\n<h1 id=\"hello-1\">Hello</h1>\n"); |
|
|
|
} |
|
|
@@ -338,7 +339,7 @@ fn can_add_id_to_headers_same_slug() { |
|
|
|
fn can_insert_anchor_left() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::Left); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left); |
|
|
|
let res = render_content("# Hello", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -350,7 +351,7 @@ fn can_insert_anchor_left() { |
|
|
|
fn can_insert_anchor_right() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::Right); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Right); |
|
|
|
let res = render_content("# Hello", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -363,7 +364,7 @@ fn can_insert_anchor_right() { |
|
|
|
fn can_insert_anchor_with_exclamation_mark() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::Left); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left); |
|
|
|
let res = render_content("# Hello!", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -376,7 +377,7 @@ fn can_insert_anchor_with_exclamation_mark() { |
|
|
|
fn can_insert_anchor_with_link() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::Left); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left); |
|
|
|
let res = render_content("## [Rust](https://rust-lang.org)", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -388,7 +389,7 @@ fn can_insert_anchor_with_link() { |
|
|
|
fn can_insert_anchor_with_other_special_chars() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::Left); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::Left); |
|
|
|
let res = render_content("# Hello*_()", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -405,7 +406,8 @@ fn can_make_toc() { |
|
|
|
&config, |
|
|
|
"https://mysite.com/something", |
|
|
|
&permalinks_ctx, |
|
|
|
InsertAnchor::Left |
|
|
|
Path::new("something"), |
|
|
|
InsertAnchor::Left, |
|
|
|
); |
|
|
|
|
|
|
|
let res = render_content(r#" |
|
|
@@ -422,14 +424,13 @@ fn can_make_toc() { |
|
|
|
assert_eq!(toc.len(), 1); |
|
|
|
assert_eq!(toc[0].children.len(), 2); |
|
|
|
assert_eq!(toc[0].children[1].children.len(), 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#[test] |
|
|
|
fn can_understand_backtick_in_titles() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("# `Hello`", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -441,7 +442,7 @@ fn can_understand_backtick_in_titles() { |
|
|
|
fn can_understand_backtick_in_paragraphs() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("Hello `world`", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -454,7 +455,7 @@ fn can_understand_backtick_in_paragraphs() { |
|
|
|
fn can_understand_links_in_header() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("# [Rust](https://rust-lang.org)", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -466,7 +467,7 @@ fn can_understand_links_in_header() { |
|
|
|
fn can_understand_link_with_title_in_header() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("# [Rust](https://rust-lang.org \"Rust homepage\")", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -480,10 +481,10 @@ fn can_make_valid_relative_link_in_header() { |
|
|
|
permalinks.insert("pages/about.md".to_string(), "https://vincent.is/about/".to_string()); |
|
|
|
let tera_ctx = Tera::default(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&tera_ctx, &config, "", &permalinks, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content( |
|
|
|
r#" # [rel link](./pages/about.md)"#, |
|
|
|
&context |
|
|
|
&context, |
|
|
|
).unwrap(); |
|
|
|
|
|
|
|
assert_eq!( |
|
|
@@ -496,7 +497,7 @@ fn can_make_valid_relative_link_in_header() { |
|
|
|
fn can_make_permalinks_with_colocated_assets_for_link() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("[an image](image.jpg)", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -508,7 +509,7 @@ fn can_make_permalinks_with_colocated_assets_for_link() { |
|
|
|
fn can_make_permalinks_with_colocated_assets_for_image() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("![alt text](image.jpg)", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -520,7 +521,7 @@ fn can_make_permalinks_with_colocated_assets_for_image() { |
|
|
|
fn markdown_doesnt_wrap_html_in_paragraph() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let config = Config::default(); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content(r#" |
|
|
|
Some text |
|
|
|
|
|
|
@@ -543,7 +544,7 @@ fn can_validate_valid_external_links() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let mut config = Config::default(); |
|
|
|
config.check_external_links = true; |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("[a link](http://google.com)", &context).unwrap(); |
|
|
|
assert_eq!( |
|
|
|
res.0, |
|
|
@@ -556,7 +557,7 @@ fn can_show_error_message_for_invalid_external_links() { |
|
|
|
let permalinks_ctx = HashMap::new(); |
|
|
|
let mut config = Config::default(); |
|
|
|
config.check_external_links = true; |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, InsertAnchor::None); |
|
|
|
let context = RenderContext::new(&GUTENBERG_TERA, &config, "https://vincent.is/about/", &permalinks_ctx, Path::new("something"), InsertAnchor::None); |
|
|
|
let res = render_content("[a link](http://google.comy)", &context); |
|
|
|
assert!(res.is_err()); |
|
|
|
let err = res.unwrap_err(); |
|
|
|