aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Parsing.hs18
-rw-r--r--src/Text/Pandoc/Readers/RST.hs13
2 files changed, 19 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index c83a95ae1..e242aa6fb 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -54,6 +54,7 @@ module Text.Pandoc.Parsing ( (>>~),
anyOrderedListMarker,
orderedListMarker,
charRef,
+ lineBlockLines,
tableWith,
widthsFromIndices,
gridTableWith,
@@ -550,6 +551,23 @@ charRef = do
c <- characterReference
return $ Str [c]
+lineBlockLine :: Parser [Char] st String
+lineBlockLine = try $ do
+ char '|'
+ char ' '
+ white <- many (spaceChar >> return '\160')
+ notFollowedBy newline
+ line <- anyLine
+ continuations <- many (try $ char ' ' >> anyLine)
+ return $ white ++ unwords (line : continuations)
+
+-- | Parses an RST-style line block and returns a list of strings.
+lineBlockLines :: Parser [Char] st [String]
+lineBlockLines = try $ do
+ lines' <- many1 lineBlockLine
+ skipMany1 $ blankline <|> try (char '|' >> blankline)
+ return lines'
+
-- | Parse a table using 'headerParser', 'rowParser',
-- 'lineParser', and 'footerParser'.
tableWith :: Parser [Char] ParserState ([[Block]], [Alignment], [Int])
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 619f0ecff..9699cf333 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -201,22 +201,11 @@ fieldList = try $ do
-- line block
--
-lineBlockLine :: RSTParser String
-lineBlockLine = try $ do
- char '|'
- 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' <- lineBlockLines
lines'' <- mapM (parseFromString
(trimInlines . mconcat <$> many inline)) lines'
- skipMany1 $ blankline <|> try (char '|' >> blankline)
return $ B.para (mconcat $ intersperse B.linebreak lines'')
--