diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-13 09:25:56 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-13 09:25:56 -0800 |
commit | 5ecadd7bfac0fea7b4269822b82aacf63fb192be (patch) | |
tree | 46888951f750f5101c33d55b966ca35096fc2621 /src | |
parent | 15829d5c3a842fdddad149b173b2c57272eeeb57 (diff) | |
download | pandoc-5ecadd7bfac0fea7b4269822b82aacf63fb192be.tar.gz |
Use line block in RST writer when a paragraph contains linebreaks.
Previously linebreaks weren't supported in RST, since RST
has no native linebreak construct.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Writers/RST.hs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 85ca98f5a..a8513a7be 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -153,9 +153,13 @@ blockToRST (Para [Image txt (src,tit)]) = do let fig = "figure:: " <> text src let alt = ":alt: " <> if null tit then capt else text tit return $ hang 3 ".. " $ fig $$ alt $+$ capt $$ blankline -blockToRST (Para inlines) = do - contents <- inlineListToRST inlines - return $ contents <> blankline +blockToRST (Para inlines) + | LineBreak `elem` inlines = do -- use line block if LineBreaks + lns <- mapM inlineListToRST $ splitBy (==LineBreak) inlines + return $ (nowrap $ vcat $ map (text "| " <>) lns) <> blankline + | otherwise = do + contents <- inlineListToRST inlines + return $ contents <> blankline blockToRST (RawBlock f str) = return $ blankline <> ".. raw:: " <> text f $+$ (nest 3 $ text str) $$ blankline @@ -346,7 +350,7 @@ inlineToRST (Math t str) = do else blankline $$ (".. math:: " <> text str) $$ blankline inlineToRST (RawInline "rst" x) = return $ text x inlineToRST (RawInline _ _) = return empty -inlineToRST (LineBreak) = return cr -- there's no line break in RST +inlineToRST (LineBreak) = return cr -- there's no line break in RST (see Para) inlineToRST Space = return space -- autolink inlineToRST (Link [Str str] (src, _)) |