aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-05-03 14:44:04 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-05-03 14:44:04 +0000
commit292d2bd38dafdfb4a8837b334adc2174c9501169 (patch)
tree650767121eec645901a0b35f6abafbc87ad7bbc9 /src
parent23841bdf77b4aa595ebcb2bcddcbb93a89231745 (diff)
downloadpandoc-292d2bd38dafdfb4a8837b334adc2174c9501169.tar.gz
Added support for definition lists to markdown
writer. git-svn-id: https://pandoc.googlecode.com/svn/trunk@591 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs14
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