aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-09-25 05:43:38 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-09-25 05:43:38 +0000
commit4f9814087e3aa65d4482982aca34ed40ed2a2655 (patch)
tree973191857c480ec312b9a40420ac6008045420c9 /src/Text/Pandoc/Writers
parentb0ef5b5b65d2bc1ed012638c6848325d8835ce15 (diff)
downloadpandoc-4f9814087e3aa65d4482982aca34ed40ed2a2655.tar.gz
Fixed a bug in the Markdown writer: incorrect line wrapping in
paragraphs including hard line breaks. Resolves Issue #25. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1032 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index ab9525576..554e0a059 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -156,15 +156,24 @@ beginsWithOrderedListMarker str =
Left _ -> False
Right _ -> True
+wrappedMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc
+wrappedMarkdown opts inlines = do
+ let chunks = splitBy LineBreak inlines
+ let chunks' = if null chunks
+ then []
+ else (map (++ [Str " "]) $ init chunks) ++ [last chunks]
+ lns <- mapM (wrapped (inlineListToMarkdown opts)) chunks'
+ return $ vcat lns
+
-- | Convert Pandoc block element to markdown.
blockToMarkdown :: WriterOptions -- ^ Options
-> Block -- ^ Block element
-> State WriterState Doc
blockToMarkdown opts Null = return empty
blockToMarkdown opts (Plain inlines) =
- wrapped (inlineListToMarkdown opts) inlines
+ wrappedMarkdown opts inlines
blockToMarkdown opts (Para inlines) = do
- contents <- wrapped (inlineListToMarkdown opts) inlines
+ contents <- wrappedMarkdown opts inlines
-- escape if para starts with ordered list marker
let esc = if (not (writerStrictMarkdown opts)) &&
beginsWithOrderedListMarker (render contents)