block: rm redundant block scope

This commit is contained in:
Noah Hellman 2023-05-03 23:36:30 +02:00
parent 7fc739cad4
commit c29b926d16

View file

@ -461,34 +461,32 @@ impl<'s> TreeParser<'s> {
} else { } else {
match kind { match kind {
lex::Kind::Sym(lex::Symbol::Pipe) => { lex::Kind::Sym(lex::Symbol::Pipe) => {
{ let span = Span::new(cell_start, pos).trim(self.src);
let span = Span::new(cell_start, pos).trim(self.src); let cell = span.of(self.src);
let cell = span.of(self.src); let separator_cell = match cell.len() {
let separator_cell = match cell.len() { 0 => false,
0 => false, 1 => cell == "-",
1 => cell == "-", 2 => matches!(cell, ":-" | "--" | "-:"),
2 => matches!(cell, ":-" | "--" | "-:"), l => {
l => { matches!(cell.as_bytes()[0], b'-' | b':')
matches!(cell.as_bytes()[0], b'-' | b':') && matches!(cell.as_bytes()[l - 1], b'-' | b':')
&& matches!(cell.as_bytes()[l - 1], b'-' | b':') && cell.chars().skip(1).take(l - 2).all(|c| c == '-')
&& cell.chars().skip(1).take(l - 2).all(|c| c == '-') }
} };
}; separator_row &= separator_cell;
separator_row &= separator_cell; self.tree.enter(
self.tree.enter( Node::Leaf(TableCell(
Node::Leaf(TableCell( self.alignments
self.alignments .get(column_index)
.get(column_index) .copied()
.copied() .unwrap_or(Alignment::Unspecified),
.unwrap_or(Alignment::Unspecified), )),
)), Span::by_len(cell_start - 1, 1),
Span::by_len(cell_start - 1, 1), );
); self.tree.inline(span);
self.tree.inline(span); self.tree.exit(); // cell
self.tree.exit(); // cell cell_start = pos + len;
cell_start = pos + len; column_index += 1;
column_index += 1;
}
} }
lex::Kind::Seq(lex::Sequence::Backtick) => { lex::Kind::Seq(lex::Sequence::Backtick) => {
verbatim = Some(len); verbatim = Some(len);