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.
This commit is contained in:
parent
15829d5c3a
commit
5ecadd7bfa
2 changed files with 10 additions and 6 deletions
|
@ -153,9 +153,13 @@ blockToRST (Para [Image txt (src,tit)]) = do
|
||||||
let fig = "figure:: " <> text src
|
let fig = "figure:: " <> text src
|
||||||
let alt = ":alt: " <> if null tit then capt else text tit
|
let alt = ":alt: " <> if null tit then capt else text tit
|
||||||
return $ hang 3 ".. " $ fig $$ alt $+$ capt $$ blankline
|
return $ hang 3 ".. " $ fig $$ alt $+$ capt $$ blankline
|
||||||
blockToRST (Para inlines) = do
|
blockToRST (Para inlines)
|
||||||
contents <- inlineListToRST inlines
|
| LineBreak `elem` inlines = do -- use line block if LineBreaks
|
||||||
return $ contents <> blankline
|
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) =
|
blockToRST (RawBlock f str) =
|
||||||
return $ blankline <> ".. raw:: " <> text f $+$
|
return $ blankline <> ".. raw:: " <> text f $+$
|
||||||
(nest 3 $ text str) $$ blankline
|
(nest 3 $ text str) $$ blankline
|
||||||
|
@ -346,7 +350,7 @@ inlineToRST (Math t str) = do
|
||||||
else blankline $$ (".. math:: " <> text str) $$ blankline
|
else blankline $$ (".. math:: " <> text str) $$ blankline
|
||||||
inlineToRST (RawInline "rst" x) = return $ text x
|
inlineToRST (RawInline "rst" x) = return $ text x
|
||||||
inlineToRST (RawInline _ _) = return empty
|
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
|
inlineToRST Space = return space
|
||||||
-- autolink
|
-- autolink
|
||||||
inlineToRST (Link [Str str] (src, _))
|
inlineToRST (Link [Str str] (src, _))
|
||||||
|
|
|
@ -59,8 +59,8 @@ item.
|
||||||
|
|
||||||
Here’s one with a bullet. \* criminey.
|
Here’s one with a bullet. \* criminey.
|
||||||
|
|
||||||
There should be a hard line break
|
| There should be a hard line break
|
||||||
here.
|
| here.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue