Moved lineBlockLines to Parsing.

This will be used by both RST and markdown readers.
This commit is contained in:
John MacFarlane
2013-01-13 11:39:32 -08:00
parent b92b8e8a3d
commit 0598cf0fee
2 changed files with 19 additions and 12 deletions
+18
View File
@@ -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])
+1 -12
View File
@@ -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'')
--