summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-01-13 11:39:32 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-01-13 11:39:32 -0800
commit0598cf0fee810f809e976cc7e564d07c55080d49 (patch)
treef604f5eafc86261ee4c460162f253c2e65c7f0dd /src/Text
parentb92b8e8a3da929ff0c96cef6c085d21016ac1851 (diff)
Moved lineBlockLines to Parsing.
This will be used by both RST and markdown readers.
Diffstat (limited to 'src/Text')
-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'')
--