Added support for definition lists to markdown
writer. git-svn-id: https://pandoc.googlecode.com/svn/trunk@591 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
parent
23841bdf77
commit
292d2bd38d
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue