diff options
author | John MacFarlane <jgm@berkeley.edu> | 2011-06-06 05:56:59 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2011-06-06 05:56:59 -0700 |
commit | da2301387f9891b3b1231a3d7178bd31f973a968 (patch) | |
tree | 3b20015e40f9eb681637e740b08f7076dd944ac6 /src | |
parent | 8d54e304c647770dd6da1af844707c314898824c (diff) | |
download | pandoc-da2301387f9891b3b1231a3d7178bd31f973a968.tar.gz |
Markdown writer: Insert HTML comment btw list and indented code block.
This prevents the code block from being interpreted as part of the list.
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 |