git.iko.soy/typeable/pandoc
on master help sign in
Moved lineBlockLines to Parsing.

This will be used by both RST and markdown readers.

commit0598cf0fee810f809e976cc7e564d07c55080d49 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 13 Jan 2013, 11:39 (14 years ago) parentb92b8e8
2 files changed+19−12
src/Text/Pandoc/Parsing.hs+18 src/Text/Pandoc/Readers/RST.hs+1−12
src/Text/Pandoc/Parsing.hs+18
@@ -54,6 +54,7 @@ module Text.Pandoc.Parsing ( (>>~),
5454 anyOrderedListMarker,
5555 orderedListMarker,
5656 charRef,
57+ lineBlockLines,
5758 tableWith,
5859 widthsFromIndices,
5960 gridTableWith,
@@ -550,6 +551,23 @@ charRef = do
550551 c <- characterReference
551552 return $ Str [c]
552553
554+lineBlockLine :: Parser [Char] st String
555+lineBlockLine = try $ do
556+ char '|'
557+ char ' '
558+ white <- many (spaceChar >> return '\160')
559+ notFollowedBy newline
560+ line <- anyLine
561+ continuations <- many (try $ char ' ' >> anyLine)
562+ return $ white ++ unwords (line : continuations)
563+
564+-- | Parses an RST-style line block and returns a list of strings.
565+lineBlockLines :: Parser [Char] st [String]
566+lineBlockLines = try $ do
567+ lines' <- many1 lineBlockLine
568+ skipMany1 $ blankline <|> try (char '|' >> blankline)
569+ return lines'
570+
553571-- | Parse a table using 'headerParser', 'rowParser',
554572-- 'lineParser', and 'footerParser'.
555573tableWith :: Parser [Char] ParserState ([[Block]], [Alignment], [Int])
src/Text/Pandoc/Readers/RST.hs+1−12
@@ -201,22 +201,11 @@ fieldList = try $ do
201201-- line block
202202--
203203
204−lineBlockLine :: RSTParser String
205−lineBlockLine = try $ do
206− char '|'
207− char ' '
208− white <- many (spaceChar >> return '\160')
209− notFollowedBy newline
210− line <- anyLine
211− continuations <- many (try $ char ' ' >> anyLine)
212− return $ white ++ unwords (line : continuations)
213−
214204lineBlock :: RSTParser Blocks
215205lineBlock = try $ do
216− lines' <- many1 lineBlockLine
206+ lines' <- lineBlockLines
217207 lines'' <- mapM (parseFromString
218208 (trimInlines . mconcat <$> many inline)) lines'
219− skipMany1 $ blankline <|> try (char '|' >> blankline)
220209 return $ B.para (mconcat $ intersperse B.linebreak lines'')
221210
222211--