diff --git a/components/rendering/src/markdown.rs b/components/rendering/src/markdown.rs index d326595..9d48206 100644 --- a/components/rendering/src/markdown.rs +++ b/components/rendering/src/markdown.rs @@ -243,6 +243,10 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result { + error = Some(Error::msg("There is a link that is missing a URL")); + Event::Start(Tag::Link(link_type, "#".into(), title)) + } Event::Start(Tag::Link(link_type, link, title)) => { let fixed_link = match fix_link( link_type, diff --git a/components/rendering/tests/markdown.rs b/components/rendering/tests/markdown.rs index dece103..338f19e 100644 --- a/components/rendering/tests/markdown.rs +++ b/components/rendering/tests/markdown.rs @@ -857,3 +857,27 @@ fn leaves_custom_url_scheme_untouched() { assert_eq!(res.body, expected); } + +#[test] +fn stops_with_an_error_on_an_empty_link() { + let content = r#"[some link]()"#; + + let tera_ctx = Tera::default(); + let config = Config::default(); + let permalinks_ctx = HashMap::new(); + + let context = RenderContext::new( + &tera_ctx, + &config, + "https://vincent.is/", + &permalinks_ctx, + InsertAnchor::None, + ); + + let res = render_content(content, &context); + + let expected = "There is a link that is missing a URL"; + + assert!(res.is_err()); + assert_eq!(res.unwrap_err().to_string(), expected); +} \ No newline at end of file