Treat EOF as EOL for refdefs
@@ -1223,6 +1223,9 @@ impl<'a> FirstPass<'a> {
break;
}
}
+ if i == self.text.len() {
+ newlines += 1;
+ }
if whitespace_bytes == 0 && newlines == 0 {
return None;
}
@@ -2709,6 +2712,16 @@ mod test {
assert_eq!(3, Parser::new("<").count());
}
+ #[test]
+ fn link_def_at_eof() {
+ let test_str = "[My site][world]\n\n[world]: https://vincentprouillet.com";
+ let expected = "<p><a href=\"https://vincentprouillet.com\">My site</a></p>\n";
+
+ let mut buf = String::new();
+ crate::html::push_html(&mut buf, Parser::new(test_str));
+ assert_eq!(expected, buf);
+ }
+
#[test]
fn simple_broken_link_callback() {
let test_str = "This is a link w/o def: [hello][world]";
