block: fix headings with first line empty
This commit is contained in:
parent
bfa58dfc0d
commit
df8846cdba
1 changed files with 19 additions and 1 deletions
20
src/block.rs
20
src/block.rs
|
@ -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!(
|
||||
|
|
Loading…
Reference in a new issue