From b4158921ddb9f946705e57f566c56460e6f90ee6 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Mon, 10 Sep 2018 12:40:30 +0200 Subject: [PATCH] Fix email links being checked by link checker Closes #403 --- CHANGELOG.md | 4 ++-- components/rendering/src/markdown.rs | 4 +++- components/rendering/tests/markdown.rs | 32 +++++++++++++++++++++++--- components/site/tests/site.rs | 2 +- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d23b655..b950bce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,9 @@ - Gutenberg has changed name to REPLACE_ME! - Update dependencies, fixing a few bugs with templates -- Make Gutenberg load only .html files in themes from the templates folder +- Load only .html files in themes from the templates folder - Background colour is set fewer times when highlighting syntaxes - +- Link checker will not try to validate email links anymore ## 0.4.2 (2018-09-03) diff --git a/components/rendering/src/markdown.rs b/components/rendering/src/markdown.rs index 9a9095b..f512bd9 100644 --- a/components/rendering/src/markdown.rs +++ b/components/rendering/src/markdown.rs @@ -160,7 +160,9 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result\n$ gutenberg server\n$ ping\n" + "
\n$ gutenberg server\n$ ping\n
" ); } @@ -61,7 +61,7 @@ fn can_highlight_code_block_with_lang() { let res = render_content("```python\nlist.append(1)\n```", &context).unwrap(); assert_eq!( res.body, - "
\nlist.append(1)\n
" + "
\nlist.append(1)\n
" ); } @@ -75,7 +75,7 @@ fn can_higlight_code_block_with_unknown_lang() { // defaults to plain text assert_eq!( res.body, - "
\nlist.append(1)\n
" + "
\nlist.append(1)\n
" ); } @@ -564,6 +564,32 @@ fn can_show_error_message_for_invalid_external_links() { assert!(err.description().contains("Link http://google.comy is not valid")); } +#[test] +fn doesnt_try_to_validate_email_links_mailto() { + 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, Path::new("something"), InsertAnchor::None); + let res = render_content("Email: [foo@bar.baz](mailto:foo@bar.baz)", &context).unwrap(); + assert_eq!( + res.body, + "

Email: foo@bar.baz

\n" + ); +} + +#[test] +fn doesnt_try_to_validate_email_links_angled_brackets() { + 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, Path::new("something"), InsertAnchor::None); + let res = render_content("Email: ", &context).unwrap(); + assert_eq!( + res.body, + "

Email: foo@bar.baz

\n" + ); +} + #[test] fn can_handle_summaries() { let tera_ctx = Tera::default(); diff --git a/components/site/tests/site.rs b/components/site/tests/site.rs index aebcb26..a1c7973 100644 --- a/components/site/tests/site.rs +++ b/components/site/tests/site.rs @@ -454,5 +454,5 @@ fn can_build_with_extra_syntaxes() { assert!(&public.exists()); assert!(file_exists!(public, "posts/extra-syntax/index.html")); assert!(file_contains!(public, "posts/extra-syntax/index.html", - r#"test"#)); + r#"test"#)); }