From de7404137eb89e2e7ee0e2f670b8cd3f6046ab7b Mon Sep 17 00:00:00 2001 From: Noah Hellman Date: Mon, 30 Jan 2023 18:28:32 +0100 Subject: [PATCH] parser: keep inlines of code blocks verbatim --- src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f0bef23..993a1c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -684,7 +684,7 @@ impl<'s> Parser<'s> { self.block_attributes = Attributes::new(); continue; } - if enter { + if enter && !matches!(l, block::Leaf::CodeBlock) { self.inlines.set_spans(self.tree.take_inlines()); self.inline_parser = Some(inline::Parser::new(self.inlines.chars())); @@ -784,7 +784,7 @@ impl<'s> Parser<'s> { Event::End(cont) } } - tree::EventKind::Inline => unreachable!(), + tree::EventKind::Inline => Event::Str(content.into()), // verbatim }; return Some(event); } @@ -1065,8 +1065,7 @@ mod test { test_parse!( "``` =html\n\n```", Start(RawBlock { format: "html" }, Attributes::new()), - Str("
".into()), - Atom(Softbreak), + Str("
\n".into()), End(RawBlock { format: "html" }), ); }