Made markdown writer sensitive to Ext_definition_lists.

IF not set, definition lists will be rendered as regular
paragraphs, with the term set off by a line break.
This commit is contained in:
John MacFarlane 2012-08-02 21:35:02 -07:00
parent 03b1ba546f
commit aef0f1d7c7

View file

@ -366,15 +366,20 @@ definitionListItemToMarkdown :: WriterOptions
-> State WriterState Doc
definitionListItemToMarkdown opts (label, defs) = do
labelText <- inlineListToMarkdown opts label
let tabStop = writerTabStop opts
st <- get
let leader = if stPlain st then " " else ": "
let sps = case writerTabStop opts - 3 of
n | n > 0 -> text $ replicate n ' '
_ -> text " "
defs' <- mapM (mapM (blockToMarkdown opts)) defs
let contents = vcat $ map (\d -> hang tabStop (leader <> sps) $ vcat d <> cr) defs'
return $ nowrap labelText <> cr <> contents <> cr
if isEnabled Ext_definition_lists opts
then do
let tabStop = writerTabStop opts
st <- get
let leader = if stPlain st then " " else ": "
let sps = case writerTabStop opts - 3 of
n | n > 0 -> text $ replicate n ' '
_ -> text " "
let contents = vcat $ map (\d -> hang tabStop (leader <> sps) $ vcat d <> cr) defs'
return $ nowrap labelText <> cr <> contents <> cr
else do
return $ nowrap labelText <> text " " <> cr <>
vsep (map vsep defs') <> blankline
-- | Convert list of Pandoc block elements to markdown.
blockListToMarkdown :: WriterOptions -- ^ Options