git.iko.soy/typeable/pandoc
on master help sign in
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.

commit88faa45f1d294690ad97b7f45a75c89c65227cf1 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 14 Oct 2018, 17:12 (8 years ago) parentab3e41c
3 files changed+15
src/Text/Pandoc/Writers/Markdown.hs+7 test/command/macros.md+4 test/writer.markdown+4
src/Text/Pandoc/Writers/Markdown.hs+7
@@ -847,6 +847,13 @@ blockListToMarkdown opts blocks = do
847847 Plain ils : fixBlocks bs
848848 fixBlocks (Plain ils : bs) =
849849 Para ils : fixBlocks bs
850+ fixBlocks (r@(RawBlock f raw) : b : bs)
851+ | not (null raw)
852+ , last raw /= '\n' =
853+ case b of
854+ Plain{} -> r : fixBlocks (b:bs)
855+ RawBlock{} -> r : fixBlocks (b:bs)
856+ _ -> RawBlock f (raw ++ "\n") : fixBlocks (b:bs) -- #4629
850857 fixBlocks (x : xs) = x : fixBlocks xs
851858 fixBlocks [] = []
852859 isListBlock (BulletList _) = True
test/command/macros.md+4
@@ -4,6 +4,7 @@
44$\my+\my$
55^D
66\newcommand{\my}{\phi}
7+
78$\phi+\phi$
89```
910
@@ -13,6 +14,7 @@ $\phi+\phi$
1314$\my+\my$
1415^D
1516\newcommand{\my}{\phi}
17+
1618$\my+\my$
1719```
1820
@@ -75,6 +77,7 @@ x &= y\\\end{aligned}\]
7577\end{equation}
7678^D
7779\newcommand{\my}{\phi}
80+
7881\begin{equation}
7982\phi+\phi
8083\end{equation}
@@ -88,6 +91,7 @@ x &= y\\\end{aligned}\]
8891\end{equation}
8992^D
9093\newcommand{\my}{\phi}
94+
9195\begin{equation}
9296\my+\my
9397\end{equation}
test/writer.markdown+4
@@ -409,6 +409,7 @@ And this is **strong**
409409</tr>
410410</table>
411411<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
412+
412413Here's a simple block:
413414
414415<div>
@@ -446,6 +447,7 @@ foo
446447This should just be an HTML comment:
447448
448449<!-- Comment -->
450+
449451Multiline:
450452
451453<!--
@@ -455,6 +457,7 @@ Blah
455457<!--
456458 This is another comment.
457459-->
460+
458461Code block:
459462
460463 <!-- Comment -->
@@ -462,6 +465,7 @@ Code block:
462465Just plain comment, with trailing spaces on the line:
463466
464467<!-- foo -->
468+
465469Code:
466470
467471 <hr />