diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 14 | ||||
-rw-r--r-- | src/test-pandoc.hs | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 5e12c4aca..48e9578b4 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -366,7 +366,19 @@ blockListToMarkdown :: WriterOptions -- ^ Options -> [Block] -- ^ List of block elements -> State WriterState Doc blockListToMarkdown opts blocks = - mapM (blockToMarkdown opts) blocks >>= return . cat + mapM (blockToMarkdown opts) (fixBlocks blocks) >>= return . cat + -- insert comment between list and indented code block, or the + -- code block will be treated as a list continuation paragraph + where fixBlocks (b : CodeBlock attr x : rest) + | (writerStrictMarkdown opts || attr == nullAttr) && isListBlock b = + b : RawBlock "html" "<!-- -->\n" : CodeBlock attr x : + fixBlocks rest + fixBlocks (x : xs) = x : fixBlocks xs + fixBlocks [] = [] + isListBlock (BulletList _) = True + isListBlock (OrderedList _ _) = True + isListBlock (DefinitionList _) = True + isListBlock _ = False -- | Get reference for target; if none exists, create unique one and return. -- Prefer label if possible; otherwise, generate a unique key. diff --git a/src/test-pandoc.hs b/src/test-pandoc.hs index 2b6c2bb49..33c46f2ba 100644 --- a/src/test-pandoc.hs +++ b/src/test-pandoc.hs @@ -11,6 +11,7 @@ import qualified Tests.Readers.RST import qualified Tests.Writers.ConTeXt import qualified Tests.Writers.HTML import qualified Tests.Writers.Native +import qualified Tests.Writers.Markdown import qualified Tests.Shared tests :: [Test] @@ -20,6 +21,7 @@ tests = [ testGroup "Old" Tests.Old.tests [ testGroup "Native" Tests.Writers.Native.tests , testGroup "ConTeXt" Tests.Writers.ConTeXt.tests , testGroup "HTML" Tests.Writers.HTML.tests + , testGroup "Markdown" Tests.Writers.Markdown.tests ] , testGroup "Readers" [ testGroup "LaTeX" Tests.Readers.LaTeX.tests |