From 928681ca049e769bd32c195c6102db5506e7f6fa Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 3 Jun 2019 09:47:08 -0700 Subject: Avoid unwanted interpretation of def list term as other kind of block, e.g. ordered list item, in Markdown writer. Closes #554. --- src/Text/Pandoc/Writers/Markdown.hs | 8 ++++---- test/command/5543.md | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 test/command/5543.md diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 85d9e85e1..50fba2dba 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -783,7 +783,7 @@ definitionListItemToMarkdown :: PandocMonad m -> ([Inline],[[Block]]) -> MD m Doc definitionListItemToMarkdown opts (label, defs) = do - labelText <- inlineListToMarkdown opts label + labelText <- blockToMarkdown opts (Plain label) defs' <- mapM (mapM (blockToMarkdown opts)) defs if isEnabled Ext_definition_lists opts then do @@ -804,10 +804,10 @@ definitionListItemToMarkdown opts (label, defs) = do let isTight = case defs of ((Plain _ : _): _) -> True _ -> False - return $ blankline <> nowrap labelText <> - (if isTight then cr else blankline) <> contents <> blankline + return $ blankline <> nowrap labelText $$ + (if isTight then empty else blankline) <> contents <> blankline else do - return $ nowrap labelText <> text " " <> cr <> + return $ nowrap (chomp labelText <> text " " <> cr) <> vsep (map vsep defs') <> blankline -- | Convert list of Pandoc block elements to markdown. diff --git a/test/command/5543.md b/test/command/5543.md new file mode 100644 index 000000000..6cae49e66 --- /dev/null +++ b/test/command/5543.md @@ -0,0 +1,8 @@ +``` +% pandoc -t markdown +1\. item +: description +^D +1\. item +: description +``` -- cgit v1.2.3