From acddf5c51e43ca59077318f0cdc0f055db6da38f Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Sat, 10 Oct 2020 10:52:07 -0500 Subject: [PATCH] Added test for RST image parser + Fixed some small issues --- src/rst_parser/mod.rs | 2 +- src/tests/mod.rs | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/rst_parser/mod.rs b/src/rst_parser/mod.rs index 56f1520..e8f7157 100644 --- a/src/rst_parser/mod.rs +++ b/src/rst_parser/mod.rs @@ -27,7 +27,7 @@ impl RSTImage { let mut style = "".to_string(); if let Some(alt) = &self.alt { - html = format!("{} {}", html, alt); + html = format!("{} alt=\"{}\"", html, alt); } if let Some(height) = &self.height { diff --git a/src/tests/mod.rs b/src/tests/mod.rs index e9eacca..239f64a 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1,5 +1,5 @@ #[cfg(test)] -use super::rst_parser::parse_links; +use super::rst_parser::{parse_links, parse_images}; #[test] fn test_link_parser() { @@ -9,7 +9,22 @@ fn test_link_parser() { .. _a link: https://domain.invalida\n", ); - let output = parse_links(&mut input); + let output = parse_links(&mut input).unwrap(); assert_eq!(output.trim_end(), "This is a paragraph that contains a link.") } + +#[test] +fn test_image_parser() { + let input = + ".. image:: cool/image/123.png + :width: 60% + :height: auto + :alt: this is the alt text + "; + + let output = parse_images(input).unwrap(); + + assert_eq!(output.trim_end(), "\"this") + +}