From 60372cda339bd5029143c210d02d1b19480098a5 Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Fri, 2 Dec 2022 08:16:47 +0100 Subject: [PATCH] fixup! e15eb6a0955c5bc1f747738a03bd9fbe93f6ffb1 --- src/block.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/block.rs b/src/block.rs index 04ce9a6..7303b23 100644 --- a/src/block.rs +++ b/src/block.rs @@ -85,7 +85,7 @@ impl<'s> Parser<'s> { let lines = &mut lines[blanklines..]; Block::parse(lines.iter().map(|sp| sp.of(self.src))).map_or( blanklines, - |(kind, span, len)| { + |(kind, span, line_count)| { let start = lines.get(0).map(|sp| sp.start()).unwrap(); let span = span.translate(start); match &kind { @@ -99,8 +99,8 @@ impl<'s> Parser<'s> { first.end(), ); let len = match l { - CodeBlock { .. } => len - 2, - _ => len, + CodeBlock { .. } => line_count - 2, + _ => line_count, }; if !matches!(l, Leaf::CodeBlock { .. }) { // trim ending whitespace of block @@ -144,7 +144,7 @@ impl<'s> Parser<'s> { } } self.tree.exit(); - blanklines + len + blanklines + line_count }, ) } @@ -159,9 +159,8 @@ impl Block { kind, Self::Leaf(CodeBlock { .. }) | Self::Container(Div { .. }) ); - let line_count = 1 - + lines.take_while(|l| kind.continues(l)).count() - + usize::from(has_end_delimiter); + let line_count_match = lines.take_while(|l| kind.continues(l)).count(); + let line_count = 1 + line_count_match + usize::from(has_end_delimiter); (kind, sp, line_count) }) } @@ -417,7 +416,7 @@ mod test { ); test_parse!( concat!( - "````lang\n", + "```` lang\n", "l0\n", "```\n", " l1\n",