git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: Insert HTML comment btw list and indented code block.
da23013John MacFarlane
src/Text/Pandoc/Writers/Markdown.hs+13−1
@@ -366,7 +366,19 @@ blockListToMarkdown :: WriterOptions -- ^ Options
366 -> [Block] -- ^ List of block elements
366 -> [Block] -- ^ List of block elements
367 -> State WriterState Doc
367 -> State WriterState Doc
368blockListToMarkdown opts blocks =
368blockListToMarkdown opts blocks =
369− mapM (blockToMarkdown opts) blocks >>= return . cat
369+ mapM (blockToMarkdown opts) (fixBlocks blocks) >>= return . cat
370+ -- insert comment between list and indented code block, or the
371+ -- code block will be treated as a list continuation paragraph
372+ where fixBlocks (b : CodeBlock attr x : rest)
373+ | (writerStrictMarkdown opts || attr == nullAttr) && isListBlock b =
374+ b : RawBlock "html" "<!-- -->\n" : CodeBlock attr x :
375+ fixBlocks rest
376+ fixBlocks (x : xs) = x : fixBlocks xs
377+ fixBlocks [] = []
378+ isListBlock (BulletList _) = True
379+ isListBlock (OrderedList _ _) = True
380+ isListBlock (DefinitionList _) = True
381+ isListBlock _ = False
370
382
371-- | Get reference for target; if none exists, create unique one and return.
383-- | Get reference for target; if none exists, create unique one and return.
372-- Prefer label if possible; otherwise, generate a unique key.
384-- Prefer label if possible; otherwise, generate a unique key.
src/test-pandoc.hs+2
@@ -11,6 +11,7 @@ import qualified Tests.Readers.RST
11import qualified Tests.Writers.ConTeXt
11import qualified Tests.Writers.ConTeXt
12import qualified Tests.Writers.HTML
12import qualified Tests.Writers.HTML
13import qualified Tests.Writers.Native
13import qualified Tests.Writers.Native
14+import qualified Tests.Writers.Markdown
14import qualified Tests.Shared
15import qualified Tests.Shared
15
16
16tests :: [Test]
17tests :: [Test]
@@ -20,6 +21,7 @@ tests = [ testGroup "Old" Tests.Old.tests
20 [ testGroup "Native" Tests.Writers.Native.tests
21 [ testGroup "Native" Tests.Writers.Native.tests
21 , testGroup "ConTeXt" Tests.Writers.ConTeXt.tests
22 , testGroup "ConTeXt" Tests.Writers.ConTeXt.tests
22 , testGroup "HTML" Tests.Writers.HTML.tests
23 , testGroup "HTML" Tests.Writers.HTML.tests
24+ , testGroup "Markdown" Tests.Writers.Markdown.tests
23 ]
25 ]
24 , testGroup "Readers"
26 , testGroup "Readers"
25 [ testGroup "LaTeX" Tests.Readers.LaTeX.tests
27 [ testGroup "LaTeX" Tests.Readers.LaTeX.tests