aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-01-13 11:29:00 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-01-13 11:29:00 -0800
commitb92b8e8a3da929ff0c96cef6c085d21016ac1851 (patch)
treee35803b3637d0cb4d6a56b023f0a02c92d23bf58 /src
parenta2c93c5a33b5a68b28094f3d7f4c780002d42317 (diff)
downloadpandoc-b92b8e8a3da929ff0c96cef6c085d21016ac1851.tar.gz
RST reader: Refactored line block parser.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 5f6850148..619f0ecff 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -201,27 +201,23 @@ fieldList = try $ do
-- line block
--
-lineBlockLine :: RSTParser Inlines
+lineBlockLine :: RSTParser String
lineBlockLine = try $ do
char '|'
- char ' ' <|> lookAhead (char '\n')
- white <- many spaceChar
- line <- many1 $ (notFollowedBy newline >> inline) <|> (try $ endline >>~ char ' ')
- optional endline
- return $ if null white
- then mconcat line
- else B.str (spToNbsp white) <> mconcat line
-
-spToNbsp :: String -> String
-spToNbsp (' ':xs) = '\160' : spToNbsp xs
-spToNbsp (x:xs) = x : spToNbsp xs
-spToNbsp [] = ""
+ char ' '
+ white <- many (spaceChar >> return '\160')
+ notFollowedBy newline
+ line <- anyLine
+ continuations <- many (try $ char ' ' >> anyLine)
+ return $ white ++ unwords (line : continuations)
lineBlock :: RSTParser Blocks
lineBlock = try $ do
lines' <- many1 lineBlockLine
+ lines'' <- mapM (parseFromString
+ (trimInlines . mconcat <$> many inline)) lines'
skipMany1 $ blankline <|> try (char '|' >> blankline)
- return $ B.para (mconcat $ intersperse B.linebreak lines')
+ return $ B.para (mconcat $ intersperse B.linebreak lines'')
--
-- paragraph block