Added test for RST image parser
+ Fixed some small issues
This commit is contained in:
parent
68ecb118a9
commit
acddf5c51e
@ -27,7 +27,7 @@ impl RSTImage {
|
|||||||
let mut style = "".to_string();
|
let mut style = "".to_string();
|
||||||
|
|
||||||
if let Some(alt) = &self.alt {
|
if let Some(alt) = &self.alt {
|
||||||
html = format!("{} {}", html, alt);
|
html = format!("{} alt=\"{}\"", html, alt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(height) = &self.height {
|
if let Some(height) = &self.height {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use super::rst_parser::parse_links;
|
use super::rst_parser::{parse_links, parse_images};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_link_parser() {
|
fn test_link_parser() {
|
||||||
@ -9,7 +9,22 @@ fn test_link_parser() {
|
|||||||
.. _a link: https://domain.invalida\n",
|
.. _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 class=\"link\" href=\"https://domain.invalida\">a link</a>.")
|
assert_eq!(output.trim_end(), "This is a paragraph that contains <a class=\"link\" href=\"https://domain.invalida\">a link</a>.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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(), "<img src=\"cool/image/123.png\" alt=\"this is the alt text\" style=\"height;60%;width:60%;\">")
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user