git.iko.soy/typeable/pandoc
on master help sign in
Removed (>>~) function
2fb8063Matthew Pickering
src/Text/Pandoc/Parsing.hs+4−9
@@ -32,8 +32,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32
32
33A utility library with parsers used in pandoc readers.
33A utility library with parsers used in pandoc readers.
34-}
34-}
35−module Text.Pandoc.Parsing ( (>>~),
35+module Text.Pandoc.Parsing ( anyLine,
36− anyLine,
37 many1Till,
36 many1Till,
38 notFollowedBy',
37 notFollowedBy',
39 oneOfStrings,
38 oneOfStrings,
@@ -101,6 +100,7 @@ module Text.Pandoc.Parsing ( (>>~),
101 macro,
100 macro,
102 applyMacros',
101 applyMacros',
103 Parser,
102 Parser,
103+ ParserT,
104 F(..),
104 F(..),
105 runF,
105 runF,
106 askF,
106 askF,
@@ -205,11 +205,6 @@ instance Monoid a => Monoid (F a) where
205 mappend = liftM2 mappend
205 mappend = liftM2 mappend
206 mconcat = liftM mconcat . sequence
206 mconcat = liftM mconcat . sequence
207
207
208−-- | Like >>, but returns the operation on the left.
209−-- (Suggested by Tillmann Rendel on Haskell-cafe list.)
210−(>>~) :: (Applicative m) => m a -> m b -> m a
211−a >>~ b = a <* b
212−
213-- | Parse any line of text
208-- | Parse any line of text
214anyLine :: Stream [Char] m Char => ParserT [Char] st m [Char]
209anyLine :: Stream [Char] m Char => ParserT [Char] st m [Char]
215anyLine = do
210anyLine = do
@@ -484,7 +479,7 @@ mathInlineWith op cl = try $ do
484mathDisplayWith :: Stream s m Char => String -> String -> ParserT s st m String
479mathDisplayWith :: Stream s m Char => String -> String -> ParserT s st m String
485mathDisplayWith op cl = try $ do
480mathDisplayWith op cl = try $ do
486 string op
481 string op
487− many1Till (noneOf "\n" <|> (newline >>~ notFollowedBy' blankline)) (try $ string cl)
482+ many1Till (noneOf "\n" <|> (newline <* notFollowedBy' blankline)) (try $ string cl)
488
483
489mathDisplay :: Stream s m Char => ParserT s ParserState m String
484mathDisplay :: Stream s m Char => ParserT s ParserState m String
490mathDisplay =
485mathDisplay =
@@ -759,7 +754,7 @@ gridPart ch = do
759 return (length dashes, length dashes + 1)
754 return (length dashes, length dashes + 1)
760
755
761gridDashedLines :: Stream s m Char => Char -> ParserT s st m [(Int,Int)]
756gridDashedLines :: Stream s m Char => Char -> ParserT s st m [(Int,Int)]
762−gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) >>~ blankline
757+gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) <* blankline
763
758
764removeFinalBar :: String -> String
759removeFinalBar :: String -> String
765removeFinalBar =
760removeFinalBar =
src/Text/Pandoc/Readers/HTML.hs+3−3
@@ -128,7 +128,7 @@ pBulletList = try $ do
128 -- note: if they have an <ol> or <ul> not in scope of a <li>,
128 -- note: if they have an <ol> or <ul> not in scope of a <li>,
129 -- treat it as a list item, though it's not valid xhtml...
129 -- treat it as a list item, though it's not valid xhtml...
130 skipMany nonItem
130 skipMany nonItem
131− items <- manyTill (pInTags "li" block >>~ skipMany nonItem) (pCloses "ul")
131+ items <- manyTill (pInTags "li" block <* skipMany nonItem) (pCloses "ul")
132 return $ B.bulletList $ map (fixPlains True) items
132 return $ B.bulletList $ map (fixPlains True) items
133
133
134pOrderedList :: TagParser Blocks
134pOrderedList :: TagParser Blocks
@@ -156,7 +156,7 @@ pOrderedList = try $ do
156 -- note: if they have an <ol> or <ul> not in scope of a <li>,
156 -- note: if they have an <ol> or <ul> not in scope of a <li>,
157 -- treat it as a list item, though it's not valid xhtml...
157 -- treat it as a list item, though it's not valid xhtml...
158 skipMany nonItem
158 skipMany nonItem
159− items <- manyTill (pInTags "li" block >>~ skipMany nonItem) (pCloses "ol")
159+ items <- manyTill (pInTags "li" block <* skipMany nonItem) (pCloses "ol")
160 return $ B.orderedListWith (start, style, DefaultDelim) $ map (fixPlains True) items
160 return $ B.orderedListWith (start, style, DefaultDelim) $ map (fixPlains True) items
161
161
162pDefinitionList :: TagParser Blocks
162pDefinitionList :: TagParser Blocks
@@ -244,7 +244,7 @@ pTable :: TagParser Blocks
244pTable = try $ do
244pTable = try $ do
245 TagOpen _ _ <- pSatisfy (~== TagOpen "table" [])
245 TagOpen _ _ <- pSatisfy (~== TagOpen "table" [])
246 skipMany pBlank
246 skipMany pBlank
247− caption <- option mempty $ pInTags "caption" inline >>~ skipMany pBlank
247+ caption <- option mempty $ pInTags "caption" inline <* skipMany pBlank
248 -- TODO actually read these and take width information from them
248 -- TODO actually read these and take width information from them
249 widths' <- pColgroup <|> many pCol
249 widths' <- pColgroup <|> many pCol
250 head' <- option [] $ pOptInTag "thead" $ pInTags "tr" (pCell "th")
250 head' <- option [] $ pOptInTag "thead" $ pInTags "tr" (pCell "th")
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -104,7 +104,7 @@ dimenarg = try $ do
104
104
105sp :: LP ()
105sp :: LP ()
106sp = skipMany1 $ satisfy (\c -> c == ' ' || c == '\t')
106sp = skipMany1 $ satisfy (\c -> c == ' ' || c == '\t')
107− <|> (try $ newline >>~ lookAhead anyChar >>~ notFollowedBy blankline)
107+ <|> (try $ newline <* lookAhead anyChar <* notFollowedBy blankline)
108
108
109isLowerHex :: Char -> Bool
109isLowerHex :: Char -> Bool
110isLowerHex x = x >= '0' && x <= '9' || x >= 'a' && x <= 'f'
110isLowerHex x = x >= '0' && x <= '9' || x >= 'a' && x <= 'f'
src/Text/Pandoc/Readers/Markdown.hs+4−4
@@ -571,7 +571,7 @@ attributes :: MarkdownParser Attr
571attributes = try $ do
571attributes = try $ do
572 char '{'
572 char '{'
573 spnl
573 spnl
574− attrs <- many (attribute >>~ spnl)
574+ attrs <- many (attribute <* spnl)
575 char '}'
575 char '}'
576 return $ foldl (\x f -> f x) nullAttr attrs
576 return $ foldl (\x f -> f x) nullAttr attrs
577
577
@@ -688,7 +688,7 @@ birdTrackLine c = try $ do
688--
688--
689
689
690emailBlockQuoteStart :: MarkdownParser Char
690emailBlockQuoteStart :: MarkdownParser Char
691−emailBlockQuoteStart = try $ skipNonindentSpaces >> char '>' >>~ optional (char ' ')
691+emailBlockQuoteStart = try $ skipNonindentSpaces >> char '>' <* optional (char ' ')
692
692
693emailBlockQuote :: MarkdownParser [String]
693emailBlockQuote :: MarkdownParser [String]
694emailBlockQuote = try $ do
694emailBlockQuote = try $ do
@@ -1165,7 +1165,7 @@ gridPart ch = do
1165 return (length dashes, length dashes + 1)
1165 return (length dashes, length dashes + 1)
1166
1166
1167gridDashedLines :: Char -> Parser [Char] st [(Int,Int)]
1167gridDashedLines :: Char -> Parser [Char] st [(Int,Int)]
1168−gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) >>~ blankline
1168+gridDashedLines ch = try $ char '+' >> many1 (gridPart ch) <* blankline
1169
1169
1170removeFinalBar :: String -> String
1170removeFinalBar :: String -> String
1171removeFinalBar =
1171removeFinalBar =
@@ -1499,7 +1499,7 @@ inlinesBetween :: (Show b)
1499inlinesBetween start end =
1499inlinesBetween start end =
1500 (trimInlinesF . mconcat) <$> try (start >> many1Till inner end)
1500 (trimInlinesF . mconcat) <$> try (start >> many1Till inner end)
1501 where inner = innerSpace <|> (notFollowedBy' (() <$ whitespace) >> inline)
1501 where inner = innerSpace <|> (notFollowedBy' (() <$ whitespace) >> inline)
1502− innerSpace = try $ whitespace >>~ notFollowedBy' end
1502+ innerSpace = try $ whitespace <* notFollowedBy' end
1503
1503
1504strikeout :: MarkdownParser (F Inlines)
1504strikeout :: MarkdownParser (F Inlines)
1505strikeout = fmap B.strikeout <$>
1505strikeout = fmap B.strikeout <$>
src/Text/Pandoc/Readers/MediaWiki.hs+1−1
@@ -634,7 +634,7 @@ inlinesBetween :: (Show b) => MWParser a -> MWParser b -> MWParser Inlines
634inlinesBetween start end =
634inlinesBetween start end =
635 (trimInlines . mconcat) <$> try (start >> many1Till inner end)
635 (trimInlines . mconcat) <$> try (start >> many1Till inner end)
636 where inner = innerSpace <|> (notFollowedBy' (() <$ whitespace) >> inline)
636 where inner = innerSpace <|> (notFollowedBy' (() <$ whitespace) >> inline)
637− innerSpace = try $ whitespace >>~ notFollowedBy' end
637+ innerSpace = try $ whitespace <* notFollowedBy' end
638
638
639emph :: MWParser Inlines
639emph :: MWParser Inlines
640emph = B.emph <$> nested (inlinesBetween start end)
640emph = B.emph <$> nested (inlinesBetween start end)
src/Text/Pandoc/Readers/RST.hs+4−4
@@ -460,7 +460,7 @@ listItem :: RSTParser Int
460listItem start = try $ do
460listItem start = try $ do
461 (markerLength, first) <- rawListItem start
461 (markerLength, first) <- rawListItem start
462 rest <- many (listContinuation markerLength)
462 rest <- many (listContinuation markerLength)
463− blanks <- choice [ try (many blankline >>~ lookAhead start),
463+ blanks <- choice [ try (many blankline <* lookAhead start),
464 many1 blankline ] -- whole list must end with blank.
464 many1 blankline ] -- whole list must end with blank.
465 -- parsing with ListItemState forces markers at beginning of lines to
465 -- parsing with ListItemState forces markers at beginning of lines to
466 -- count as list item markers, even if not separated by blank space.
466 -- count as list item markers, even if not separated by blank space.
@@ -480,7 +480,7 @@ listItem start = try $ do
480
480
481orderedList :: RSTParser Blocks
481orderedList :: RSTParser Blocks
482orderedList = try $ do
482orderedList = try $ do
483− (start, style, delim) <- lookAhead (anyOrderedListMarker >>~ spaceChar)
483+ (start, style, delim) <- lookAhead (anyOrderedListMarker <* spaceChar)
484 items <- many1 (listItem (orderedListStart style delim))
484 items <- many1 (listItem (orderedListStart style delim))
485 let items' = compactify' items
485 let items' = compactify' items
486 return $ B.orderedListWith (start, style, delim) items'
486 return $ B.orderedListWith (start, style, delim) items'
@@ -747,7 +747,7 @@ simpleReferenceName = do
747
747
748referenceName :: RSTParser Inlines
748referenceName :: RSTParser Inlines
749referenceName = quotedReferenceName <|>
749referenceName = quotedReferenceName <|>
750− (try $ simpleReferenceName >>~ lookAhead (char ':')) <|>
750+ (try $ simpleReferenceName <* lookAhead (char ':')) <|>
751 unquotedReferenceName
751 unquotedReferenceName
752
752
753referenceKey :: RSTParser [Char]
753referenceKey :: RSTParser [Char]
@@ -1076,7 +1076,7 @@ explicitLink = try $ do
1076
1076
1077referenceLink :: RSTParser Inlines
1077referenceLink :: RSTParser Inlines
1078referenceLink = try $ do
1078referenceLink = try $ do
1079− (label',ref) <- withRaw (quotedReferenceName <|> simpleReferenceName) >>~
1079+ (label',ref) <- withRaw (quotedReferenceName <|> simpleReferenceName) <*
1080 char '_'
1080 char '_'
1081 state <- getState
1081 state <- getState
1082 let keyTable = stateKeys state
1082 let keyTable = stateKeys state