block: fix headings with first line empty

This commit is contained in:
Noah Hellman 2023-01-29 11:33:39 +01:00
parent bfa58dfc0d
commit df8846cdba

View file

@ -301,7 +301,10 @@ impl<'s> TreeParser<'s> {
}
self.tree.enter(Node::Leaf(leaf), span);
lines.iter().for_each(|line| self.tree.inline(*line));
lines
.iter()
.filter(|l| !l.is_empty())
.for_each(|line| self.tree.inline(*line));
self.tree.exit();
}
@ -992,6 +995,21 @@ mod test {
);
}
#[test]
fn parse_heading_empty_first_line() {
test_parse!(
concat!(
"#\n",
"heading\n", //
),
(Enter(Container(Section)), "#"),
(Enter(Leaf(Heading)), "#"),
(Inline, "heading"),
(Exit(Leaf(Heading)), "#"),
(Exit(Container(Section)), "#"),
);
}
#[test]
fn parse_heading_multi() {
test_parse!(