From 6eea612483ddf81f721d9a7a91b560d2b3937c1a Mon Sep 17 00:00:00 2001 From: Romain Porte Date: Tue, 24 Aug 2021 17:50:36 +0200 Subject: [PATCH] render: add HTML image tests with align support The current align test was only used for text, but we want to be sure that images can be aligned too. This is why a new test is added to verify that the align attribute is also kept for images. Since the align attribute requires RAW HTML for the tag, the relative_links test has also been updated to check for this usage. --- src/render.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/render.rs b/src/render.rs index 3b7fb8d1983..9e1623efa1f 100644 --- a/src/render.rs +++ b/src/render.rs @@ -391,6 +391,7 @@ mod tests { let absolute = "[hi](/hi)"; let relative = "[there](there)"; let image = "![alt](img.png)"; + let html_image = "\"alt\""; let svg = "![alt](sanitize.svg)"; for host in &["github.com", "gitlab.com", "bitbucket.org"] { @@ -429,6 +430,15 @@ mod tests { ) ); + let result = markdown_to_html(html_image, Some(&url)); + assert_eq!( + result, + format!( + "\"alt\"\n", + host + ) + ); + let result = markdown_to_html(svg, Some(&url)); assert_eq!( result, @@ -520,4 +530,15 @@ mod tests { "

foo-bar

\n
Hello World!
\n" ); } + + #[test] + fn image_alignment() { + let text = + "\"\"\n"; + let result = markdown_to_html(text, None); + assert_eq!( + result, + "\"\"\n" + ); + } }