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/Text/Pandoc | |
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/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 14 |
1 files changed, 13 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. |