parser: keep inlines of code blocks verbatim

This commit is contained in:
Noah Hellman 2023-01-30 18:28:32 +01:00
parent 2893977dae
commit de7404137e

View file

@ -684,7 +684,7 @@ impl<'s> Parser<'s> {
self.block_attributes = Attributes::new(); self.block_attributes = Attributes::new();
continue; continue;
} }
if enter { if enter && !matches!(l, block::Leaf::CodeBlock) {
self.inlines.set_spans(self.tree.take_inlines()); self.inlines.set_spans(self.tree.take_inlines());
self.inline_parser = self.inline_parser =
Some(inline::Parser::new(self.inlines.chars())); Some(inline::Parser::new(self.inlines.chars()));
@ -784,7 +784,7 @@ impl<'s> Parser<'s> {
Event::End(cont) Event::End(cont)
} }
} }
tree::EventKind::Inline => unreachable!(), tree::EventKind::Inline => Event::Str(content.into()), // verbatim
}; };
return Some(event); return Some(event);
} }
@ -1065,8 +1065,7 @@ mod test {
test_parse!( test_parse!(
"``` =html\n<table>\n```", "``` =html\n<table>\n```",
Start(RawBlock { format: "html" }, Attributes::new()), Start(RawBlock { format: "html" }, Attributes::new()),
Str("<table>".into()), Str("<table>\n".into()),
Atom(Softbreak),
End(RawBlock { format: "html" }), End(RawBlock { format: "html" }),
); );
} }