From 5c067bb457a96d8c7c35c9e1ca114169a02c1d2d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 13 Jan 2013 11:14:50 -0800 Subject: RST reader: Line block improvements. * Use nonbreaking spaces for initial indent (otherwise lost in HTML and LaTeX). * Allow multiple paragraphs in a single line block. --- src/Text/Pandoc/Readers/RST.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index cc8293132..5f6850148 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -206,16 +206,21 @@ lineBlockLine = try $ do char '|' char ' ' <|> lookAhead (char '\n') white <- many spaceChar - line <- many $ (notFollowedBy newline >> inline) <|> (try $ endline >>~ char ' ') + line <- many1 $ (notFollowedBy newline >> inline) <|> (try $ endline >>~ char ' ') optional endline return $ if null white then mconcat line - else B.str white <> mconcat line + else B.str (spToNbsp white) <> mconcat line + +spToNbsp :: String -> String +spToNbsp (' ':xs) = '\160' : spToNbsp xs +spToNbsp (x:xs) = x : spToNbsp xs +spToNbsp [] = "" lineBlock :: RSTParser Blocks lineBlock = try $ do lines' <- many1 lineBlockLine - blanklines + skipMany1 $ blankline <|> try (char '|' >> blankline) return $ B.para (mconcat $ intersperse B.linebreak lines') -- -- cgit v1.2.3