mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 08:25:52 +00:00
Moved lineBlockLines to Parsing.
This will be used by both RST and markdown readers.
This commit is contained in:
@@ -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])
|
||||
|
||||
@@ -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'')
|
||||
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user