fixup! 5a33d9cae978e1e151d571c610b0f6584db00cc8

This commit is contained in:
Noah Hellman 2022-11-30 19:56:08 +01:00
parent 3ca0002df8
commit d32519009e

View file

@ -98,15 +98,19 @@ impl<'s> Parser<'s> {
} }
Block::Container(c) => { Block::Container(c) => {
let (skip_chars, skip_lines_suffix) = match &c { let (skip_chars, skip_lines_suffix) = match &c {
Blockquote => (1, 0), Blockquote => (2, 0),
ListItem { indent } | Footnote { indent } => (*indent, 0), ListItem { indent } | Footnote { indent } => (*indent, 0),
Div { .. } => (0, 1), Div { .. } => (0, 1),
}; };
let line_count = lines.len() - skip_lines_suffix; let line_count_inner = lines.len() - skip_lines_suffix;
// update spans, remove indentation / container prefix // update spans, remove indentation / container prefix
lines[0] = lines[0].with_start(span.end()); lines[0] = lines[0].with_start(span.end());
lines.iter_mut().skip(1).take(line_count).for_each(|sp| { lines
.iter_mut()
.skip(1)
.take(line_count_inner)
.for_each(|sp| {
let skip = (sp let skip = (sp
.of(self.src) .of(self.src)
.chars() .chars()
@ -119,8 +123,8 @@ impl<'s> Parser<'s> {
self.tree.enter(kind, span); self.tree.enter(kind, span);
let mut l = 0; let mut l = 0;
while l < line_count { while l < line_count_inner {
l += self.parse_block(&mut lines[l..line_count]); l += self.parse_block(&mut lines[l..line_count_inner]);
} }
} }
} }
@ -165,12 +169,21 @@ impl Block {
}) })
}) })
.flatten(), .flatten(),
'>' => chars.next().map_or(true, |c| c == ' ').then(|| { '>' => {
if let Some(c) = chars.next() {
c.is_whitespace().then(|| {
( (
Self::Container(Blockquote), Self::Container(Blockquote),
Span::by_len(start, line.len() - chars.as_str().len() - 1), Span::by_len(start, line.len() - chars.as_str().len() - 1),
) )
}), })
} else {
Some((
Self::Container(Blockquote),
Span::by_len(start, line.len() - chars.as_str().len()),
))
}
}
f @ ('`' | ':') => { f @ ('`' | ':') => {
let fence_length = chars.take_while(|c| *c == f).count() + 1; let fence_length = chars.take_while(|c| *c == f).count() + 1;
(fence_length >= 3) (fence_length >= 3)