Markdown writer: Made sensitive to Ext_hard_line_breaks.

This commit is contained in:
John MacFarlane 2012-09-15 19:19:47 -04:00
parent 62225599c9
commit 0851f8d592

View file

@ -54,9 +54,12 @@ data WriterState = WriterState { stNotes :: Notes
-- | Convert Pandoc to Markdown. -- | Convert Pandoc to Markdown.
writeMarkdown :: WriterOptions -> Pandoc -> String writeMarkdown :: WriterOptions -> Pandoc -> String
writeMarkdown opts document = writeMarkdown opts document =
evalState (pandocToMarkdown opts document) WriterState{ stNotes = [] evalState (pandocToMarkdown opts{
, stRefs = [] writerWrapText = writerWrapText opts &&
, stPlain = False } not (isEnabled Ext_hard_line_breaks opts) }
document) WriterState{ stNotes = []
, stRefs = []
, stPlain = False }
-- | Convert Pandoc to plain text (like markdown, but without links, -- | Convert Pandoc to plain text (like markdown, but without links,
-- pictures, or inline formatting). -- pictures, or inline formatting).
@ -588,8 +591,9 @@ inlineToMarkdown opts (RawInline f str)
return $ text str return $ text str
inlineToMarkdown _ (RawInline _ _) = return empty inlineToMarkdown _ (RawInline _ _) = return empty
inlineToMarkdown opts (LineBreak) inlineToMarkdown opts (LineBreak)
| isEnabled Ext_hard_line_breaks opts = return cr
| isEnabled Ext_escaped_line_breaks opts = return $ "\\" <> cr | isEnabled Ext_escaped_line_breaks opts = return $ "\\" <> cr
| otherwise = return $ " " <> cr | otherwise = return $ " " <> cr
inlineToMarkdown _ Space = return space inlineToMarkdown _ Space = return space
inlineToMarkdown opts (Cite (c:cs) lst) inlineToMarkdown opts (Cite (c:cs) lst)
| writerCiteMethod opts == Citeproc = inlineListToMarkdown opts lst | writerCiteMethod opts == Citeproc = inlineListToMarkdown opts lst