Markdown writer: Insert HTML comment btw list and indented code block.
This prevents the code block from being interpreted as part of the list.
This commit is contained in:
parent
8d54e304c6
commit
da2301387f
2 changed files with 15 additions and 1 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue