summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2021-09-18 10:46:12 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2021-09-18 10:46:12 +0100
commit59311238193b0b0b4cdd7d0e90db6c1804a19521 (patch)
treed2ef8d9903f399ff26e2ee7bc52401b62f3471e2
parent85e1d8fe7e0b2a6e020ec1d1319b3759c5ae0c2d (diff)
downloadsubplot-59311238193b0b0b4cdd7d0e90db6c1804a19521.tar.gz
ast: Codeblocks should not have extra trailing newlines
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
-rw-r--r--src/ast.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ast.rs b/src/ast.rs
index 60d234d..2033553 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -188,6 +188,12 @@ fn code_block(kind: &CodeBlockKind, inlines: &mut Vec<Inline>) -> Block {
let text = plain_text_inline(inline);
code.push_str(&text);
}
+ // pulldown_cmark and pandoc differ in their codeblock handling,
+ // pulldown_cmark has an extra newline which we trim for now to be
+ // compatible with pandoc's parsing
+ if !code.is_empty() {
+ assert_eq!(code.pop(), Some('\n'));
+ }
Block::CodeBlock(attr, code)
}