git.iko.soy/typeable/pandoc
on master help sign in
Removed followedBy' parser from Text/ParserCombinators/Pandoc,

replacing it with the 'lookAhead' parser from Text/ParserCombinators/Parsec. git-svn-id: https://pandoc.googlecode.com/svn/trunk@535 788f1e2b-df1e-0410-8736-df70ead52e1b

commitae19b94fd17cb3983d10b9b0af372b68d353db6d authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 15 Feb 2007, 01:10 (20 years ago) parent0114f68
4 files changed+8−18
src/Text/Pandoc/Readers/LaTeX.hs+1−1 src/Text/Pandoc/Readers/Markdown.hs+5−5 src/Text/Pandoc/Readers/RST.hs+2−2 src/Text/ParserCombinators/Pandoc.hs−10
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -322,7 +322,7 @@ itemBlock = try (do
322322--
323323
324324specialEnvironment = do -- these are always parsed as raw
325− followedBy' (choice (map (\name -> begin name) ["tabular", "figure",
325+ lookAhead (choice (map (\name -> begin name) ["tabular", "figure",
326326 "tabbing", "eqnarry", "picture", "table", "verse", "theorem"]))
327327 rawLaTeXEnvironment
328328
src/Text/Pandoc/Readers/Markdown.hs+5−5
@@ -394,7 +394,7 @@ rawListItem start = try (do
394394-- or (in compact lists) endline.
395395-- note: nested lists are parsed as continuations
396396listContinuation start = try (do
397− followedBy' indentSpaces
397+ lookAhead indentSpaces
398398 result <- many1 (listContinuationLine start)
399399 blanks <- many blankline
400400 return ((concat result) ++ blanks))
@@ -443,10 +443,10 @@ para = try (do
443443 newline
444444 st <- getState
445445 if stateStrict st
446− then choice [followedBy' blockQuote, followedBy' header,
447− (do{blanklines; return ()})]
448− else choice [followedBy' emacsBoxQuote,
449− (do{blanklines; return ()})]
446+ then choice [lookAhead blockQuote, lookAhead header,
447+ (do{blanklines; return Null})]
448+ else choice [(do{lookAhead emacsBoxQuote; return Null}),
449+ (do{blanklines; return Null})]
450450 let result' = normalizeSpaces result
451451 return (Para result'))
452452
src/Text/Pandoc/Readers/RST.hs+2−2
@@ -198,7 +198,7 @@ codeBlockStart = try (do
198198-- paragraph that ends in a :: starting a code block
199199paraBeforeCodeBlock = try (do
200200 result <- many1 (do {notFollowedBy' codeBlockStart; inline})
201− followedBy' (string "::")
201+ lookAhead (string "::")
202202 return (Para (if (last result == Space)
203203 then normalizeSpaces result
204204 else (normalizeSpaces result) ++ [Str ":"])))
@@ -446,7 +446,7 @@ listItem start = try (do
446446 rest <- many (listContinuation markerLength)
447447 blanks <- choice [ try (do
448448 b <- many blankline
449− followedBy' start
449+ lookAhead start
450450 return b),
451451 many1 blankline ] -- whole list must end with blank
452452 -- parsing with ListItemState forces markers at beginning of lines to
src/Text/ParserCombinators/Pandoc.hs−10
@@ -30,7 +30,6 @@ Special parser combinators for Pandoc readers.
3030module Text.ParserCombinators.Pandoc (
3131 anyLine,
3232 many1Till,
33− followedBy',
3433 notFollowedBy',
3534 oneOfStrings,
3635 spaceChar,
@@ -119,15 +118,6 @@ notFollowedBy' :: Show b => GenParser a st b -> GenParser a st ()
119118notFollowedBy' parser = try (do { c <- try parser; unexpected (show c) }
120119 <|> return ())
121120
122−-- | The inverse of @notFollowedBy'@. Fails if parser will fail, otherwise
123−-- returns @()@ (but does not consume any input).
124−followedBy' :: (Show b) => GenParser a st b -> GenParser a st ()
125−followedBy' parser = do
126− isNotFollowed <- option False (do{ notFollowedBy' parser; return True})
127− if isNotFollowed
128− then fail "not followed by parser"
129− else return ()
130−
131121-- | Parses one of a list of strings (tried in order).
132122oneOfStrings :: [String] -> GenParser Char st String
133123oneOfStrings listOfStrings = choice $ map (try . string) listOfStrings