diff options
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 8f1b3cea9..7f46e8097 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -163,6 +163,9 @@ blockToMarkdown opts (OrderedList items) = do contents <- mapM (\(item, num) -> orderedListItemToMarkdown opts item num) $ zip [1..] items return $ (vcat contents) <> text "\n" +blockToMarkdown opts (DefinitionList items) = do + contents <- mapM (definitionListItemToMarkdown opts) items + return $ (vcat contents) <> text "\n" -- | Convert bullet list item (list of blocks) to markdown. bulletListItemToMarkdown :: WriterOptions -> [Block] -> State WriterState Doc @@ -181,6 +184,17 @@ orderedListItemToMarkdown opts num items = do return $ hang (text ((show num) ++ "." ++ spacer)) (writerTabStop opts) contents +-- | Convert definition list item (label, list of blocks) to markdown. +definitionListItemToMarkdown :: WriterOptions + -> ([Inline],[Block]) + -> State WriterState Doc +definitionListItemToMarkdown opts (label, items) = do + labelText <- inlineListToMarkdown opts label + contents <- mapM (\item -> blockToMarkdown opts item >>= + (return . hang (text ": ") (writerTabStop opts))) + items >>= (return . vcat) + return $ labelText $+$ contents + -- | Convert list of Pandoc block elements to markdown. blockListToMarkdown :: WriterOptions -- ^ Options -> [Block] -- ^ List of block elements |