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.
This commit is contained in:
John MacFarlane 2018-10-14 17:12:06 -07:00
parent ab3e41c822
commit 88faa45f1d
3 changed files with 15 additions and 0 deletions

View file

@ -847,6 +847,13 @@ blockListToMarkdown opts blocks = do
Plain ils : fixBlocks bs Plain ils : fixBlocks bs
fixBlocks (Plain ils : bs) = fixBlocks (Plain ils : bs) =
Para ils : fixBlocks 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 (x : xs) = x : fixBlocks xs
fixBlocks [] = [] fixBlocks [] = []
isListBlock (BulletList _) = True isListBlock (BulletList _) = True

View file

@ -4,6 +4,7 @@
$\my+\my$ $\my+\my$
^D ^D
\newcommand{\my}{\phi} \newcommand{\my}{\phi}
$\phi+\phi$ $\phi+\phi$
``` ```
@ -13,6 +14,7 @@ $\phi+\phi$
$\my+\my$ $\my+\my$
^D ^D
\newcommand{\my}{\phi} \newcommand{\my}{\phi}
$\my+\my$ $\my+\my$
``` ```
@ -75,6 +77,7 @@ x &= y\\\end{aligned}\]
\end{equation} \end{equation}
^D ^D
\newcommand{\my}{\phi} \newcommand{\my}{\phi}
\begin{equation} \begin{equation}
\phi+\phi \phi+\phi
\end{equation} \end{equation}
@ -88,6 +91,7 @@ x &= y\\\end{aligned}\]
\end{equation} \end{equation}
^D ^D
\newcommand{\my}{\phi} \newcommand{\my}{\phi}
\begin{equation} \begin{equation}
\my+\my \my+\my
\end{equation} \end{equation}

View file

@ -409,6 +409,7 @@ And this is **strong**
</tr> </tr>
</table> </table>
<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script> <script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
Here's a simple block: Here's a simple block:
<div> <div>
@ -446,6 +447,7 @@ foo
This should just be an HTML comment: This should just be an HTML comment:
<!-- Comment --> <!-- Comment -->
Multiline: Multiline:
<!-- <!--
@ -455,6 +457,7 @@ Blah
<!-- <!--
This is another comment. This is another comment.
--> -->
Code block: Code block:
<!-- Comment --> <!-- Comment -->
@ -462,6 +465,7 @@ Code block:
Just plain comment, with trailing spaces on the line: Just plain comment, with trailing spaces on the line:
<!-- foo --> <!-- foo -->
Code: Code:
<hr /> <hr />