From 88faa45f1d294690ad97b7f45a75c89c65227cf1 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 14 Oct 2018 17:12:06 -0700 Subject: Markdown writer: ensure blank between raw block and normal content. Otherwise a raw block can prevent a paragraph from being recognized as such. Closes #4629. --- src/Text/Pandoc/Writers/Markdown.hs | 7 +++++++ test/command/macros.md | 4 ++++ test/writer.markdown | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 9a4acb59d..ad8d5c483 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -847,6 +847,13 @@ blockListToMarkdown opts blocks = do Plain ils : fixBlocks bs fixBlocks (Plain ils : bs) = Para ils : fixBlocks bs + fixBlocks (r@(RawBlock f raw) : b : bs) + | not (null raw) + , last raw /= '\n' = + case b of + Plain{} -> r : fixBlocks (b:bs) + RawBlock{} -> r : fixBlocks (b:bs) + _ -> RawBlock f (raw ++ "\n") : fixBlocks (b:bs) -- #4629 fixBlocks (x : xs) = x : fixBlocks xs fixBlocks [] = [] isListBlock (BulletList _) = True diff --git a/test/command/macros.md b/test/command/macros.md index d091c2191..50393543a 100644 --- a/test/command/macros.md +++ b/test/command/macros.md @@ -4,6 +4,7 @@ $\my+\my$ ^D \newcommand{\my}{\phi} + $\phi+\phi$ ``` @@ -13,6 +14,7 @@ $\phi+\phi$ $\my+\my$ ^D \newcommand{\my}{\phi} + $\my+\my$ ``` @@ -75,6 +77,7 @@ x &= y\\\end{aligned}\] \end{equation} ^D \newcommand{\my}{\phi} + \begin{equation} \phi+\phi \end{equation} @@ -88,6 +91,7 @@ x &= y\\\end{aligned}\] \end{equation} ^D \newcommand{\my}{\phi} + \begin{equation} \my+\my \end{equation} diff --git a/test/writer.markdown b/test/writer.markdown index 0cc465f1e..de0821970 100644 --- a/test/writer.markdown +++ b/test/writer.markdown @@ -409,6 +409,7 @@ And this is **strong** + Here's a simple block:
@@ -446,6 +447,7 @@ foo This should just be an HTML comment: + Multiline: + Code block: @@ -462,6 +465,7 @@ Code block: Just plain comment, with trailing spaces on the line: + Code:
-- cgit v1.2.3