git.iko.soy/typeable/pandoc
on master help sign in
Use Parser as type synonym for Parsec.
commit2c30c4875727c530677b2689178a227e6be0288a authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 20 Jul 2012, 15:54 (14 years ago) parent5085962
10 files changed+324−322
src/Text/Pandoc/Biblio.hs+5−5 src/Text/Pandoc/Parsing.hs+3−1 src/Text/Pandoc/Readers/HTML.hs+8−8 src/Text/Pandoc/Readers/LaTeX.hs+3−3 src/Text/Pandoc/Readers/Markdown.hs+134−134 src/Text/Pandoc/Readers/RST.hs+92−92 src/Text/Pandoc/Readers/Textile.hs+68−68 src/Text/Pandoc/Templates.hs+9−9 src/Text/Pandoc/Writers/AsciiDoc.hs+1−1 src/Text/Pandoc/Writers/Markdown.hs+1−1
src/Text/Pandoc/Biblio.hs+5−5
@@ -165,7 +165,7 @@ locatorWords inp =
165165 breakup (x : xs) = x : breakup xs
166166 splitup = groupBy (\x y -> x /= '\160' && y /= '\160')
167167
168−pLocatorWords :: Parsec [Inline] st (String, [Inline])
168+pLocatorWords :: Parser [Inline] st (String, [Inline])
169169pLocatorWords = do
170170 l <- pLocator
171171 s <- getInput -- rest is suffix
@@ -173,16 +173,16 @@ pLocatorWords = do
173173 then return (init l, Str "," : s)
174174 else return (l, s)
175175
176−pMatch :: (Inline -> Bool) -> Parsec [Inline] st Inline
176+pMatch :: (Inline -> Bool) -> Parser [Inline] st Inline
177177pMatch condition = try $ do
178178 t <- anyToken
179179 guard $ condition t
180180 return t
181181
182−pSpace :: Parsec [Inline] st Inline
182+pSpace :: Parser [Inline] st Inline
183183pSpace = pMatch (\t -> t == Space || t == Str "\160")
184184
185−pLocator :: Parsec [Inline] st String
185+pLocator :: Parser [Inline] st String
186186pLocator = try $ do
187187 optional $ pMatch (== Str ",")
188188 optional pSpace
@@ -190,7 +190,7 @@ pLocator = try $ do
190190 gs <- many1 pWordWithDigits
191191 return $ stringify f ++ (' ' : unwords gs)
192192
193−pWordWithDigits :: Parsec [Inline] st String
193+pWordWithDigits :: Parser [Inline] st String
194194pWordWithDigits = try $ do
195195 pSpace
196196 r <- many1 (notFollowedBy pSpace >> anyToken)
src/Text/Pandoc/Parsing.hs+3−1
@@ -75,7 +75,7 @@ module Text.Pandoc.Parsing ( (>>~),
7575 macro,
7676 applyMacros',
7777 -- * Re-exports from Text.Pandoc.Parsec
78− Parsec,
78+ Parser,
7979 runParser,
8080 parse,
8181 anyToken,
@@ -141,6 +141,8 @@ import Text.TeXMath.Macros (applyMacros, Macro, parseMacroDefinitions)
141141import Text.HTML.TagSoup.Entity ( lookupEntity )
142142import Data.Default
143143
144+type Parser t s = Parsec t s
145+
144146-- | Like >>, but returns the operation on the left.
145147-- (Suggested by Tillmann Rendel on Haskell-cafe list.)
146148(>>~) :: (Monad m) => m a -> m b -> m a
src/Text/Pandoc/Readers/HTML.hs+8−8
@@ -66,7 +66,7 @@ readHtml st inp = Pandoc meta blocks
6666 then parseHeader tags
6767 else (Meta [] [] [], tags)
6868
69−type TagParser = Parsec [Tag String] ParserState
69+type TagParser = Parser [Tag String] ParserState
7070
7171-- TODO - fix this - not every header has a title tag
7272parseHeader :: [Tag String] -> (Meta, [Tag String])
@@ -430,11 +430,11 @@ pBlank = try $ do
430430 (TagText str) <- pSatisfy isTagText
431431 guard $ all isSpace str
432432
433−pTagContents :: Parsec [Char] ParserState Inline
433+pTagContents :: Parser [Char] ParserState Inline
434434pTagContents =
435435 pStr <|> pSpace <|> smartPunctuation pTagContents <|> pSymbol <|> pBad
436436
437−pStr :: Parsec [Char] ParserState Inline
437+pStr :: Parser [Char] ParserState Inline
438438pStr = do
439439 result <- many1 $ satisfy $ \c ->
440440 not (isSpace c) && not (isSpecial c) && not (isBad c)
@@ -453,13 +453,13 @@ isSpecial '\8220' = True
453453isSpecial '\8221' = True
454454isSpecial _ = False
455455
456−pSymbol :: Parsec [Char] ParserState Inline
456+pSymbol :: Parser [Char] ParserState Inline
457457pSymbol = satisfy isSpecial >>= return . Str . (:[])
458458
459459isBad :: Char -> Bool
460460isBad c = c >= '\128' && c <= '\159' -- not allowed in HTML
461461
462−pBad :: Parsec [Char] ParserState Inline
462+pBad :: Parser [Char] ParserState Inline
463463pBad = do
464464 c <- satisfy isBad
465465 let c' = case c of
@@ -493,7 +493,7 @@ pBad = do
493493 _ -> '?'
494494 return $ Str [c']
495495
496−pSpace :: Parsec [Char] ParserState Inline
496+pSpace :: Parser [Char] ParserState Inline
497497pSpace = many1 (satisfy isSpace) >> return Space
498498
499499--
@@ -591,7 +591,7 @@ _ `closes` _ = False
591591--- parsers for use in markdown, textile readers
592592
593593-- | Matches a stretch of HTML in balanced tags.
594−htmlInBalanced :: (Tag String -> Bool) -> Parsec [Char] ParserState String
594+htmlInBalanced :: (Tag String -> Bool) -> Parser [Char] ParserState String
595595htmlInBalanced f = try $ do
596596 (TagOpen t _, tag) <- htmlTag f
597597 guard $ '/' `notElem` tag -- not a self-closing tag
@@ -604,7 +604,7 @@ htmlInBalanced f = try $ do
604604 return $ tag ++ concat contents ++ endtag
605605
606606-- | Matches a tag meeting a certain condition.
607−htmlTag :: (Tag String -> Bool) -> Parsec [Char] ParserState (Tag String, String)
607+htmlTag :: (Tag String -> Bool) -> Parser [Char] ParserState (Tag String, String)
608608htmlTag f = try $ do
609609 lookAhead (char '<')
610610 (next : _) <- getInput >>= return . canonicalizeTags . parseTags
src/Text/Pandoc/Readers/LaTeX.hs+3−3
@@ -63,7 +63,7 @@ parseLaTeX = do
6363 let date' = stateDate st
6464 return $ Pandoc (Meta title' authors' date') $ toList bs
6565
66−type LP = Parsec [Char] ParserState
66+type LP = Parser [Char] ParserState
6767
6868anyControlSeq :: LP String
6969anyControlSeq = do
@@ -712,10 +712,10 @@ verbatimEnv = do
712712 rest <- getInput
713713 return (r,rest)
714714
715−rawLaTeXBlock :: Parsec [Char] ParserState String
715+rawLaTeXBlock :: Parser [Char] ParserState String
716716rawLaTeXBlock = snd <$> withRaw (environment <|> blockCommand)
717717
718−rawLaTeXInline :: Parsec [Char] ParserState Inline
718+rawLaTeXInline :: Parser [Char] ParserState Inline
719719rawLaTeXInline = do
720720 (res, raw) <- withRaw inlineCommand
721721 if res == mempty
src/Text/Pandoc/Readers/Markdown.hs+134−134
@@ -82,14 +82,14 @@ isBlank _ = False
8282-- auxiliary functions
8383--
8484
85−indentSpaces :: Parsec [Char] ParserState [Char]
85+indentSpaces :: Parser [Char] ParserState [Char]
8686indentSpaces = try $ do
8787 state <- getState
8888 let tabStop = stateTabStop state
8989 count tabStop (char ' ') <|>
9090 string "\t" <?> "indentation"
9191
92−nonindentSpaces :: Parsec [Char] ParserState [Char]
92+nonindentSpaces :: Parser [Char] ParserState [Char]
9393nonindentSpaces = do
9494 state <- getState
9595 let tabStop = stateTabStop state
@@ -98,30 +98,30 @@ nonindentSpaces = do
9898 then return sps
9999 else unexpected "indented line"
100100
101−skipNonindentSpaces :: Parsec [Char] ParserState ()
101+skipNonindentSpaces :: Parser [Char] ParserState ()
102102skipNonindentSpaces = do
103103 state <- getState
104104 atMostSpaces (stateTabStop state - 1)
105105
106−atMostSpaces :: Int -> Parsec [Char] ParserState ()
106+atMostSpaces :: Int -> Parser [Char] ParserState ()
107107atMostSpaces 0 = notFollowedBy (char ' ')
108108atMostSpaces n = (char ' ' >> atMostSpaces (n-1)) <|> return ()
109109
110−litChar :: Parsec [Char] ParserState Char
110+litChar :: Parser [Char] ParserState Char
111111litChar = escapedChar'
112112 <|> noneOf "\n"
113113 <|> (newline >> notFollowedBy blankline >> return ' ')
114114
115115-- | Fail unless we're at beginning of a line.
116−failUnlessBeginningOfLine :: Parsec [tok] st ()
116+failUnlessBeginningOfLine :: Parser [tok] st ()
117117failUnlessBeginningOfLine = do
118118 pos <- getPosition
119119 if sourceColumn pos == 1 then return () else fail "not beginning of line"
120120
121121-- | Parse a sequence of inline elements between square brackets,
122122-- including inlines between balanced pairs of square brackets.
123−inlinesInBalancedBrackets :: Parsec [Char] ParserState Inline
124− -> Parsec [Char] ParserState [Inline]
123+inlinesInBalancedBrackets :: Parser [Char] ParserState Inline
124+ -> Parser [Char] ParserState [Inline]
125125inlinesInBalancedBrackets parser = try $ do
126126 char '['
127127 result <- manyTill ( (do lookAhead $ try $ do (Str res) <- parser
@@ -136,7 +136,7 @@ inlinesInBalancedBrackets parser = try $ do
136136-- document structure
137137--
138138
139−titleLine :: Parsec [Char] ParserState [Inline]
139+titleLine :: Parser [Char] ParserState [Inline]
140140titleLine = try $ do
141141 char '%'
142142 skipSpaces
@@ -145,7 +145,7 @@ titleLine = try $ do
145145 newline
146146 return $ normalizeSpaces res
147147
148−authorsLine :: Parsec [Char] ParserState [[Inline]]
148+authorsLine :: Parser [Char] ParserState [[Inline]]
149149authorsLine = try $ do
150150 char '%'
151151 skipSpaces
@@ -156,14 +156,14 @@ authorsLine = try $ do
156156 newline
157157 return $ filter (not . null) $ map normalizeSpaces authors
158158
159−dateLine :: Parsec [Char] ParserState [Inline]
159+dateLine :: Parser [Char] ParserState [Inline]
160160dateLine = try $ do
161161 char '%'
162162 skipSpaces
163163 date <- manyTill inline newline
164164 return $ normalizeSpaces date
165165
166−titleBlock :: Parsec [Char] ParserState ([Inline], [[Inline]], [Inline])
166+titleBlock :: Parser [Char] ParserState ([Inline], [[Inline]], [Inline])
167167titleBlock = try $ do
168168 failIfStrict
169169 title <- option [] titleLine
@@ -172,7 +172,7 @@ titleBlock = try $ do
172172 optional blanklines
173173 return (title, author, date)
174174
175−parseMarkdown :: Parsec [Char] ParserState Pandoc
175+parseMarkdown :: Parser [Char] ParserState Pandoc
176176parseMarkdown = do
177177 -- markdown allows raw HTML
178178 updateState (\state -> state { stateParseRaw = True })
@@ -210,7 +210,7 @@ parseMarkdown = do
210210-- initial pass for references and notes
211211--
212212
213−referenceKey :: Parsec [Char] ParserState [Char]
213+referenceKey :: Parser [Char] ParserState [Char]
214214referenceKey = try $ do
215215 startPos <- getPosition
216216 skipNonindentSpaces
@@ -237,7 +237,7 @@ referenceKey = try $ do
237237 -- return blanks so line count isn't affected
238238 return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
239239
240−referenceTitle :: Parsec [Char] ParserState String
240+referenceTitle :: Parser [Char] ParserState String
241241referenceTitle = try $ do
242242 skipSpaces >> optional newline >> skipSpaces
243243 tit <- (charsInBalanced '(' ')' litChar >>= return . unwords . words)
@@ -246,23 +246,23 @@ referenceTitle = try $ do
246246 notFollowedBy (noneOf ")\n")))
247247 return $ fromEntities tit
248248
249−noteMarker :: Parsec [Char] ParserState [Char]
249+noteMarker :: Parser [Char] ParserState [Char]
250250noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']')
251251
252−rawLine :: Parsec [Char] ParserState [Char]
252+rawLine :: Parser [Char] ParserState [Char]
253253rawLine = try $ do
254254 notFollowedBy blankline
255255 notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker
256256 optional indentSpaces
257257 anyLine
258258
259−rawLines :: Parsec [Char] ParserState [Char]
259+rawLines :: Parser [Char] ParserState [Char]
260260rawLines = do
261261 first <- anyLine
262262 rest <- many rawLine
263263 return $ unlines (first:rest)
264264
265−noteBlock :: Parsec [Char] ParserState [Char]
265+noteBlock :: Parser [Char] ParserState [Char]
266266noteBlock = try $ do
267267 startPos <- getPosition
268268 skipNonindentSpaces
@@ -286,10 +286,10 @@ noteBlock = try $ do
286286-- parsing blocks
287287--
288288
289−parseBlocks :: Parsec [Char] ParserState [Block]
289+parseBlocks :: Parser [Char] ParserState [Block]
290290parseBlocks = manyTill block eof
291291
292−block :: Parsec [Char] ParserState Block
292+block :: Parser [Char] ParserState Block
293293block = do
294294 st <- getState
295295 choice (if stateStrict st
@@ -324,10 +324,10 @@ block = do
324324-- header blocks
325325--
326326
327−header :: Parsec [Char] ParserState Block
327+header :: Parser [Char] ParserState Block
328328header = setextHeader <|> atxHeader <?> "header"
329329
330−atxHeader :: Parsec [Char] ParserState Block
330+atxHeader :: Parser [Char] ParserState Block
331331atxHeader = try $ do
332332 level <- many1 (char '#') >>= return . length
333333 notFollowedBy (char '.' <|> char ')') -- this would be a list
@@ -335,10 +335,10 @@ atxHeader = try $ do
335335 text <- manyTill inline atxClosing >>= return . normalizeSpaces
336336 return $ Header level text
337337
338−atxClosing :: Parsec [Char] st [Char]
338+atxClosing :: Parser [Char] st [Char]
339339atxClosing = try $ skipMany (char '#') >> blanklines
340340
341−setextHeader :: Parsec [Char] ParserState Block
341+setextHeader :: Parser [Char] ParserState Block
342342setextHeader = try $ do
343343 -- This lookahead prevents us from wasting time parsing Inlines
344344 -- unless necessary -- it gives a significant performance boost.
@@ -354,7 +354,7 @@ setextHeader = try $ do
354354-- hrule block
355355--
356356
357−hrule :: Parsec [Char] st Block
357+hrule :: Parser [Char] st Block
358358hrule = try $ do
359359 skipSpaces
360360 start <- satisfy isHruleChar
@@ -368,12 +368,12 @@ hrule = try $ do
368368-- code blocks
369369--
370370
371−indentedLine :: Parsec [Char] ParserState [Char]
371+indentedLine :: Parser [Char] ParserState [Char]
372372indentedLine = indentSpaces >> manyTill anyChar newline >>= return . (++ "\n")
373373
374374blockDelimiter :: (Char -> Bool)
375375 -> Maybe Int
376− -> Parsec [Char] st (Int, (String, [String], [(String, String)]), Char)
376+ -> Parser [Char] st (Int, (String, [String], [(String, String)]), Char)
377377blockDelimiter f len = try $ do
378378 c <- lookAhead (satisfy f)
379379 size <- case len of
@@ -387,7 +387,7 @@ blockDelimiter f len = try $ do
387387 blankline
388388 return (size, attr, c)
389389
390−attributes :: Parsec [Char] st ([Char], [[Char]], [([Char], [Char])])
390+attributes :: Parser [Char] st ([Char], [[Char]], [([Char], [Char])])
391391attributes = try $ do
392392 char '{'
393393 spnl
@@ -399,28 +399,28 @@ attributes = try $ do
399399 | otherwise = firstNonNull xs
400400 return (firstNonNull $ reverse ids, concat classes, concat keyvals)
401401
402−attribute :: Parsec [Char] st ([Char], [[Char]], [([Char], [Char])])
402+attribute :: Parser [Char] st ([Char], [[Char]], [([Char], [Char])])
403403attribute = identifierAttr <|> classAttr <|> keyValAttr
404404
405−identifier :: Parsec [Char] st [Char]
405+identifier :: Parser [Char] st [Char]
406406identifier = do
407407 first <- letter
408408 rest <- many $ alphaNum <|> oneOf "-_:."
409409 return (first:rest)
410410
411−identifierAttr :: Parsec [Char] st ([Char], [a], [a1])
411+identifierAttr :: Parser [Char] st ([Char], [a], [a1])
412412identifierAttr = try $ do
413413 char '#'
414414 result <- identifier
415415 return (result,[],[])
416416
417−classAttr :: Parsec [Char] st ([Char], [[Char]], [a])
417+classAttr :: Parser [Char] st ([Char], [[Char]], [a])
418418classAttr = try $ do
419419 char '.'
420420 result <- identifier
421421 return ("",[result],[])
422422
423−keyValAttr :: Parsec [Char] st ([Char], [a], [([Char], [Char])])
423+keyValAttr :: Parser [Char] st ([Char], [a], [([Char], [Char])])
424424keyValAttr = try $ do
425425 key <- identifier
426426 char '='
@@ -429,14 +429,14 @@ keyValAttr = try $ do
429429 <|> many nonspaceChar
430430 return ("",[],[(key,val)])
431431
432−codeBlockDelimited :: Parsec [Char] st Block
432+codeBlockDelimited :: Parser [Char] st Block
433433codeBlockDelimited = try $ do
434434 (size, attr, c) <- blockDelimiter (\c -> c == '~' || c == '`') Nothing
435435 contents <- manyTill anyLine (blockDelimiter (== c) (Just size))
436436 blanklines
437437 return $ CodeBlock attr $ intercalate "\n" contents
438438
439−codeBlockIndented :: Parsec [Char] ParserState Block
439+codeBlockIndented :: Parser [Char] ParserState Block
440440codeBlockIndented = do
441441 contents <- many1 (indentedLine <|>
442442 try (do b <- blanklines
@@ -447,7 +447,7 @@ codeBlockIndented = do
447447 return $ CodeBlock ("", stateIndentedCodeClasses st, []) $
448448 stripTrailingNewlines $ concat contents
449449
450−lhsCodeBlock :: Parsec [Char] ParserState Block
450+lhsCodeBlock :: Parser [Char] ParserState Block
451451lhsCodeBlock = do
452452 failUnlessLHS
453453 liftM (CodeBlock ("",["sourceCode","literate","haskell"],[]))
@@ -455,7 +455,7 @@ lhsCodeBlock = do
455455 <|> liftM (CodeBlock ("",["sourceCode","haskell"],[]))
456456 lhsCodeBlockInverseBird
457457
458−lhsCodeBlockLaTeX :: Parsec [Char] ParserState String
458+lhsCodeBlockLaTeX :: Parser [Char] ParserState String
459459lhsCodeBlockLaTeX = try $ do
460460 string "\\begin{code}"
461461 manyTill spaceChar newline
@@ -463,13 +463,13 @@ lhsCodeBlockLaTeX = try $ do
463463 blanklines
464464 return $ stripTrailingNewlines contents
465465
466−lhsCodeBlockBird :: Parsec [Char] ParserState String
466+lhsCodeBlockBird :: Parser [Char] ParserState String
467467lhsCodeBlockBird = lhsCodeBlockBirdWith '>'
468468
469−lhsCodeBlockInverseBird :: Parsec [Char] ParserState String
469+lhsCodeBlockInverseBird :: Parser [Char] ParserState String
470470lhsCodeBlockInverseBird = lhsCodeBlockBirdWith '<'
471471
472−lhsCodeBlockBirdWith :: Char -> Parsec [Char] ParserState String
472+lhsCodeBlockBirdWith :: Char -> Parser [Char] ParserState String
473473lhsCodeBlockBirdWith c = try $ do
474474 pos <- getPosition
475475 when (sourceColumn pos /= 1) $ fail "Not in first column"
@@ -481,7 +481,7 @@ lhsCodeBlockBirdWith c = try $ do
481481 blanklines
482482 return $ intercalate "\n" lns'
483483
484−birdTrackLine :: Char -> Parsec [Char] st [Char]
484+birdTrackLine :: Char -> Parser [Char] st [Char]
485485birdTrackLine c = try $ do
486486 char c
487487 -- allow html tags on left margin:
@@ -493,10 +493,10 @@ birdTrackLine c = try $ do
493493-- block quotes
494494--
495495
496−emailBlockQuoteStart :: Parsec [Char] ParserState Char
496+emailBlockQuoteStart :: Parser [Char] ParserState Char
497497emailBlockQuoteStart = try $ skipNonindentSpaces >> char '>' >>~ optional (char ' ')
498498
499−emailBlockQuote :: Parsec [Char] ParserState [[Char]]
499+emailBlockQuote :: Parser [Char] ParserState [[Char]]
500500emailBlockQuote = try $ do
501501 emailBlockQuoteStart
502502 raw <- sepBy (many (nonEndline <|>
@@ -507,7 +507,7 @@ emailBlockQuote = try $ do
507507 optional blanklines
508508 return raw
509509
510−blockQuote :: Parsec [Char] ParserState Block
510+blockQuote :: Parser [Char] ParserState Block
511511blockQuote = do
512512 raw <- emailBlockQuote
513513 -- parse the extracted block, which may contain various block elements:
@@ -518,7 +518,7 @@ blockQuote = do
518518-- list blocks
519519--
520520
521−bulletListStart :: Parsec [Char] ParserState ()
521+bulletListStart :: Parser [Char] ParserState ()
522522bulletListStart = try $ do
523523 optional newline -- if preceded by a Plain block in a list context
524524 skipNonindentSpaces
@@ -527,7 +527,7 @@ bulletListStart = try $ do
527527 spaceChar
528528 skipSpaces
529529
530−anyOrderedListStart :: Parsec [Char] ParserState (Int, ListNumberStyle, ListNumberDelim)
530+anyOrderedListStart :: Parser [Char] ParserState (Int, ListNumberStyle, ListNumberDelim)
531531anyOrderedListStart = try $ do
532532 optional newline -- if preceded by a Plain block in a list context
533533 skipNonindentSpaces
@@ -547,11 +547,11 @@ anyOrderedListStart = try $ do
547547 skipSpaces
548548 return (num, style, delim)
549549
550−listStart :: Parsec [Char] ParserState ()
550+listStart :: Parser [Char] ParserState ()
551551listStart = bulletListStart <|> (anyOrderedListStart >> return ())
552552
553553-- parse a line of a list item (start = parser for beginning of list item)
554−listLine :: Parsec [Char] ParserState [Char]
554+listLine :: Parser [Char] ParserState [Char]
555555listLine = try $ do
556556 notFollowedBy blankline
557557 notFollowedBy' (do indentSpaces
@@ -561,8 +561,8 @@ listLine = try $ do
561561 return $ concat chunks ++ "\n"
562562
563563-- parse raw text for one list item, excluding start marker and continuations
564−rawListItem :: Parsec [Char] ParserState a
565− -> Parsec [Char] ParserState [Char]
564+rawListItem :: Parser [Char] ParserState a
565+ -> Parser [Char] ParserState [Char]
566566rawListItem start = try $ do
567567 start
568568 first <- listLine
@@ -573,14 +573,14 @@ rawListItem start = try $ do
573573-- continuation of a list item - indented and separated by blankline
574574-- or (in compact lists) endline.
575575-- note: nested lists are parsed as continuations
576−listContinuation :: Parsec [Char] ParserState [Char]
576+listContinuation :: Parser [Char] ParserState [Char]
577577listContinuation = try $ do
578578 lookAhead indentSpaces
579579 result <- many1 listContinuationLine
580580 blanks <- many blankline
581581 return $ concat result ++ blanks
582582
583−listContinuationLine :: Parsec [Char] ParserState [Char]
583+listContinuationLine :: Parser [Char] ParserState [Char]
584584listContinuationLine = try $ do
585585 notFollowedBy blankline
586586 notFollowedBy' listStart
@@ -588,8 +588,8 @@ listContinuationLine = try $ do
588588 result <- manyTill anyChar newline
589589 return $ result ++ "\n"
590590
591−listItem :: Parsec [Char] ParserState a
592− -> Parsec [Char] ParserState [Block]
591+listItem :: Parser [Char] ParserState a
592+ -> Parser [Char] ParserState [Block]
593593listItem start = try $ do
594594 first <- rawListItem start
595595 continuations <- many listContinuation
@@ -605,7 +605,7 @@ listItem start = try $ do
605605 updateState (\st -> st {stateParserContext = oldContext})
606606 return contents
607607
608−orderedList :: Parsec [Char] ParserState Block
608+orderedList :: Parser [Char] ParserState Block
609609orderedList = try $ do
610610 (start, style, delim) <- lookAhead anyOrderedListStart
611611 items <- many1 $ listItem $ try $
@@ -614,13 +614,13 @@ orderedList = try $ do
614614 orderedListMarker style delim
615615 return $ OrderedList (start, style, delim) $ compactify items
616616
617−bulletList :: Parsec [Char] ParserState Block
617+bulletList :: Parser [Char] ParserState Block
618618bulletList =
619619 many1 (listItem bulletListStart) >>= return . BulletList . compactify
620620
621621-- definition lists
622622
623−defListMarker :: Parsec [Char] ParserState ()
623+defListMarker :: Parser [Char] ParserState ()
624624defListMarker = do
625625 sps <- nonindentSpaces
626626 char ':' <|> char '~'
@@ -632,7 +632,7 @@ defListMarker = do
632632 else mzero
633633 return ()
634634
635−definitionListItem :: Parsec [Char] ParserState ([Inline], [[Block]])
635+definitionListItem :: Parser [Char] ParserState ([Inline], [[Block]])
636636definitionListItem = try $ do
637637 -- first, see if this has any chance of being a definition list:
638638 lookAhead (anyLine >> optional blankline >> defListMarker)
@@ -646,7 +646,7 @@ definitionListItem = try $ do
646646 updateState (\st -> st {stateParserContext = oldContext})
647647 return ((normalizeSpaces term), contents)
648648
649−defRawBlock :: Parsec [Char] ParserState [Char]
649+defRawBlock :: Parser [Char] ParserState [Char]
650650defRawBlock = try $ do
651651 defListMarker
652652 firstline <- anyLine
@@ -658,7 +658,7 @@ defRawBlock = try $ do
658658 return $ unlines lns ++ trl
659659 return $ firstline ++ "\n" ++ unlines rawlines ++ trailing ++ cont
660660
661−definitionList :: Parsec [Char] ParserState Block
661+definitionList :: Parser [Char] ParserState Block
662662definitionList = do
663663 items <- many1 definitionListItem
664664 -- "compactify" the definition list:
@@ -687,7 +687,7 @@ isHtmlOrBlank (Space) = True
687687isHtmlOrBlank (LineBreak) = True
688688isHtmlOrBlank _ = False
689689
690−para :: Parsec [Char] ParserState Block
690+para :: Parser [Char] ParserState Block
691691para = try $ do
692692 result <- liftM normalizeSpaces $ many1 inline
693693 guard $ not . all isHtmlOrBlank $ result
@@ -698,17 +698,17 @@ para = try $ do
698698 lookAhead (blockQuote <|> header) >> return "")
699699 return $ Para result
700700
701−plain :: Parsec [Char] ParserState Block
701+plain :: Parser [Char] ParserState Block
702702plain = many1 inline >>~ spaces >>= return . Plain . normalizeSpaces
703703
704704--
705705-- raw html
706706--
707707
708−htmlElement :: Parsec [Char] ParserState [Char]
708+htmlElement :: Parser [Char] ParserState [Char]
709709htmlElement = strictHtmlBlock <|> liftM snd (htmlTag isBlockTag)
710710
711−htmlBlock :: Parsec [Char] ParserState Block
711+htmlBlock :: Parser [Char] ParserState Block
712712htmlBlock = try $ do
713713 failUnlessBeginningOfLine
714714 first <- htmlElement
@@ -716,12 +716,12 @@ htmlBlock = try $ do
716716 finalNewlines <- many newline
717717 return $ RawBlock "html" $ first ++ finalSpace ++ finalNewlines
718718
719−strictHtmlBlock :: Parsec [Char] ParserState [Char]
719+strictHtmlBlock :: Parser [Char] ParserState [Char]
720720strictHtmlBlock = do
721721 failUnlessBeginningOfLine
722722 htmlInBalanced (not . isInlineTag)
723723
724−rawVerbatimBlock :: Parsec [Char] ParserState String
724+rawVerbatimBlock :: Parser [Char] ParserState String
725725rawVerbatimBlock = try $ do
726726 (TagOpen tag _, open) <- htmlTag (tagOpen (\t ->
727727 t == "pre" || t == "style" || t == "script")
@@ -729,7 +729,7 @@ rawVerbatimBlock = try $ do
729729 contents <- manyTill anyChar (htmlTag (~== TagClose tag))
730730 return $ open ++ contents ++ renderTags [TagClose tag]
731731
732−rawTeXBlock :: Parsec [Char] ParserState Block
732+rawTeXBlock :: Parser [Char] ParserState Block
733733rawTeXBlock = do
734734 failIfStrict
735735 result <- liftM (RawBlock "latex") rawLaTeXBlock
@@ -737,7 +737,7 @@ rawTeXBlock = do
737737 spaces
738738 return result
739739
740−rawHtmlBlocks :: Parsec [Char] ParserState Block
740+rawHtmlBlocks :: Parser [Char] ParserState Block
741741rawHtmlBlocks = do
742742 htmlBlocks <- many1 $ do blk <- rawVerbatimBlock <|>
743743 liftM snd (htmlTag isBlockTag)
@@ -761,7 +761,7 @@ rawHtmlBlocks = do
761761-- Parse a dashed line with optional trailing spaces; return its length
762762-- and the length including trailing space.
763763dashedLine :: Char
764− -> Parsec [Char] st (Int, Int)
764+ -> Parser [Char] st (Int, Int)
765765dashedLine ch = do
766766 dashes <- many1 (char ch)
767767 sp <- many spaceChar
@@ -770,7 +770,7 @@ dashedLine ch = do
770770-- Parse a table header with dashed lines of '-' preceded by
771771-- one (or zero) line of text.
772772simpleTableHeader :: Bool -- ^ Headerless table
773− -> Parsec [Char] ParserState ([[Block]], [Alignment], [Int])
773+ -> Parser [Char] ParserState ([[Block]], [Alignment], [Int])
774774simpleTableHeader headless = try $ do
775775 rawContent <- if headless
776776 then return ""
@@ -794,16 +794,16 @@ simpleTableHeader headless = try $ do
794794 return (heads, aligns, indices)
795795
796796-- Parse a table footer - dashed lines followed by blank line.
797−tableFooter :: Parsec [Char] ParserState [Char]
797+tableFooter :: Parser [Char] ParserState [Char]
798798tableFooter = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> blanklines
799799
800800-- Parse a table separator - dashed line.
801−tableSep :: Parsec [Char] ParserState Char
801+tableSep :: Parser [Char] ParserState Char
802802tableSep = try $ skipNonindentSpaces >> many1 (dashedLine '-') >> char '\n'
803803
804804-- Parse a raw line and split it into chunks by indices.
805805rawTableLine :: [Int]
806− -> Parsec [Char] ParserState [String]
806+ -> Parser [Char] ParserState [String]
807807rawTableLine indices = do
808808 notFollowedBy' (blanklines <|> tableFooter)
809809 line <- many1Till anyChar newline
@@ -812,12 +812,12 @@ rawTableLine indices = do
812812
813813-- Parse a table line and return a list of lists of blocks (columns).
814814tableLine :: [Int]
815− -> Parsec [Char] ParserState [[Block]]
815+ -> Parser [Char] ParserState [[Block]]
816816tableLine indices = rawTableLine indices >>= mapM (parseFromString (many plain))
817817
818818-- Parse a multiline table row and return a list of blocks (columns).
819819multilineRow :: [Int]
820− -> Parsec [Char] ParserState [[Block]]
820+ -> Parser [Char] ParserState [[Block]]
821821multilineRow indices = do
822822 colLines <- many1 (rawTableLine indices)
823823 let cols = map unlines $ transpose colLines
@@ -825,7 +825,7 @@ multilineRow indices = do
825825
826826-- Parses a table caption: inlines beginning with 'Table:'
827827-- and followed by blank lines.
828−tableCaption :: Parsec [Char] ParserState [Inline]
828+tableCaption :: Parser [Char] ParserState [Inline]
829829tableCaption = try $ do
830830 skipNonindentSpaces
831831 string ":" <|> string "Table:"
@@ -835,7 +835,7 @@ tableCaption = try $ do
835835
836836-- Parse a simple table with '---' header and one line per row.
837837simpleTable :: Bool -- ^ Headerless table
838− -> Parsec [Char] ParserState Block
838+ -> Parser [Char] ParserState Block
839839simpleTable headless = do
840840 Table c a _w h l <- tableWith (simpleTableHeader headless) tableLine
841841 (return ())
@@ -849,12 +849,12 @@ simpleTable headless = do
849849-- which may be multiline, separated by blank lines, and
850850-- ending with a footer (dashed line followed by blank line).
851851multilineTable :: Bool -- ^ Headerless table
852− -> Parsec [Char] ParserState Block
852+ -> Parser [Char] ParserState Block
853853multilineTable headless =
854854 tableWith (multilineTableHeader headless) multilineRow blanklines tableFooter tableCaption
855855
856856multilineTableHeader :: Bool -- ^ Headerless table
857− -> Parsec [Char] ParserState ([[Block]], [Alignment], [Int])
857+ -> Parser [Char] ParserState ([[Block]], [Alignment], [Int])
858858multilineTableHeader headless = try $ do
859859 if headless
860860 then return '\n'
@@ -902,10 +902,10 @@ alignType strLst len =
902902 (False, False) -> AlignDefault
903903
904904gridTable :: Bool -- ^ Headerless table
905− -> Parsec [Char] ParserState Block
905+ -> Parser [Char] ParserState Block
906906gridTable = gridTableWith block tableCaption
907907
908−table :: Parsec [Char] ParserState Block
908+table :: Parser [Char] ParserState Block
909909table = multilineTable False <|> simpleTable True <|>
910910 simpleTable False <|> multilineTable True <|>
911911 gridTable False <|> gridTable True <?> "table"
@@ -914,10 +914,10 @@ table = multilineTable False <|> simpleTable True <|>
914914-- inline
915915--
916916
917−inline :: Parsec [Char] ParserState Inline
917+inline :: Parser [Char] ParserState Inline
918918inline = choice inlineParsers <?> "inline"
919919
920−inlineParsers :: [Parsec [Char] ParserState Inline]
920+inlineParsers :: [Parser [Char] ParserState Inline]
921921inlineParsers = [ whitespace
922922 , str
923923 , endline
@@ -944,7 +944,7 @@ inlineParsers = [ whitespace
944944 , symbol
945945 , ltSign ]
946946
947−escapedChar' :: Parsec [Char] ParserState Char
947+escapedChar' :: Parser [Char] ParserState Char
948948escapedChar' = try $ do
949949 char '\\'
950950 state <- getState
@@ -952,7 +952,7 @@ escapedChar' = try $ do
952952 then oneOf "\\`*_{}[]()>#+-.!~"
953953 else satisfy (not . isAlphaNum)
954954
955−escapedChar :: Parsec [Char] ParserState Inline
955+escapedChar :: Parser [Char] ParserState Inline
956956escapedChar = do
957957 result <- escapedChar'
958958 return $ case result of
@@ -960,7 +960,7 @@ escapedChar = do
960960 '\n' -> LineBreak -- "\[newline]" is a linebreak
961961 _ -> Str [result]
962962
963−ltSign :: Parsec [Char] ParserState Inline
963+ltSign :: Parser [Char] ParserState Inline
964964ltSign = do
965965 st <- getState
966966 if stateStrict st
@@ -968,7 +968,7 @@ ltSign = do
968968 else notFollowedBy' rawHtmlBlocks >> char '<' -- unless it starts html
969969 return $ Str ['<']
970970
971−exampleRef :: Parsec [Char] ParserState Inline
971+exampleRef :: Parser [Char] ParserState Inline
972972exampleRef = try $ do
973973 char '@'
974974 lab <- many1 (alphaNum <|> oneOf "-_")
@@ -976,7 +976,7 @@ exampleRef = try $ do
976976 -- later. See the end of parseMarkdown.
977977 return $ Str $ '@' : lab
978978
979−symbol :: Parsec [Char] ParserState Inline
979+symbol :: Parser [Char] ParserState Inline
980980symbol = do
981981 result <- noneOf "<\\\n\t "
982982 <|> try (do lookAhead $ char '\\'
@@ -985,7 +985,7 @@ symbol = do
985985 return $ Str [result]
986986
987987-- parses inline code, between n `s and n `s
988−code :: Parsec [Char] ParserState Inline
988+code :: Parser [Char] ParserState Inline
989989code = try $ do
990990 starts <- many1 (char '`')
991991 skipSpaces
@@ -996,26 +996,26 @@ code = try $ do
996996 attr <- option ([],[],[]) (try $ optional whitespace >> attributes)
997997 return $ Code attr $ removeLeadingTrailingSpace $ concat result
998998
999−mathWord :: Parsec [Char] st [Char]
999+mathWord :: Parser [Char] st [Char]
10001000mathWord = liftM concat $ many1 mathChunk
10011001
1002−mathChunk :: Parsec [Char] st [Char]
1002+mathChunk :: Parser [Char] st [Char]
10031003mathChunk = do char '\\'
10041004 c <- anyChar
10051005 return ['\\',c]
10061006 <|> many1 (satisfy $ \c -> not (isBlank c || c == '\\' || c == '$'))
10071007
1008−math :: Parsec [Char] ParserState Inline
1008+math :: Parser [Char] ParserState Inline
10091009math = (mathDisplay >>= applyMacros' >>= return . Math DisplayMath)
10101010 <|> (mathInline >>= applyMacros' >>= return . Math InlineMath)
10111011
1012−mathDisplay :: Parsec [Char] ParserState String
1012+mathDisplay :: Parser [Char] ParserState String
10131013mathDisplay = try $ do
10141014 failIfStrict
10151015 string "$$"
10161016 many1Till (noneOf "\n" <|> (newline >>~ notFollowedBy' blankline)) (try $ string "$$")
10171017
1018−mathInline :: Parsec [Char] ParserState String
1018+mathInline :: Parser [Char] ParserState String
10191019mathInline = try $ do
10201020 failIfStrict
10211021 char '$'
@@ -1027,7 +1027,7 @@ mathInline = try $ do
10271027
10281028-- to avoid performance problems, treat 4 or more _ or * or ~ or ^ in a row
10291029-- as a literal rather than attempting to parse for emph/strong/strikeout/super/sub
1030−fours :: Parsec [Char] st Inline
1030+fours :: Parser [Char] st Inline
10311031fours = try $ do
10321032 x <- char '*' <|> char '_' <|> char '~' <|> char '^'
10331033 count 2 $ satisfy (==x)
@@ -1036,9 +1036,9 @@ fours = try $ do
10361036
10371037-- | Parses a list of inlines between start and end delimiters.
10381038inlinesBetween :: (Show b)
1039− => Parsec [Char] ParserState a
1040− -> Parsec [Char] ParserState b
1041− -> Parsec [Char] ParserState [Inline]
1039+ => Parser [Char] ParserState a
1040+ -> Parser [Char] ParserState b
1041+ -> Parser [Char] ParserState [Inline]
10421042inlinesBetween start end =
10431043 normalizeSpaces `liftM` try (start >> many1Till inner end)
10441044 where inner = innerSpace <|> (notFollowedBy' whitespace >> inline)
@@ -1046,8 +1046,8 @@ inlinesBetween start end =
10461046
10471047-- This is used to prevent exponential blowups for things like:
10481048-- a**a*a**a*a**a*a**a*a**a*a**a*a**
1049−nested :: Parsec [Char] ParserState a
1050− -> Parsec [Char] ParserState a
1049+nested :: Parser [Char] ParserState a
1050+ -> Parser [Char] ParserState a
10511051nested p = do
10521052 nestlevel <- stateMaxNestingLevel `fmap` getState
10531053 guard $ nestlevel > 0
@@ -1056,7 +1056,7 @@ nested p = do
10561056 updateState $ \st -> st{ stateMaxNestingLevel = nestlevel }
10571057 return res
10581058
1059−emph :: Parsec [Char] ParserState Inline
1059+emph :: Parser [Char] ParserState Inline
10601060emph = Emph `fmap` nested
10611061 (inlinesBetween starStart starEnd <|> inlinesBetween ulStart ulEnd)
10621062 where starStart = char '*' >> lookAhead nonspaceChar
@@ -1064,7 +1064,7 @@ emph = Emph `fmap` nested
10641064 ulStart = char '_' >> lookAhead nonspaceChar
10651065 ulEnd = notFollowedBy' strong >> char '_'
10661066
1067−strong :: Parsec [Char] ParserState Inline
1067+strong :: Parser [Char] ParserState Inline
10681068strong = Strong `liftM` nested
10691069 (inlinesBetween starStart starEnd <|> inlinesBetween ulStart ulEnd)
10701070 where starStart = string "**" >> lookAhead nonspaceChar
@@ -1072,32 +1072,32 @@ strong = Strong `liftM` nested
10721072 ulStart = string "__" >> lookAhead nonspaceChar
10731073 ulEnd = try $ string "__"
10741074
1075−strikeout :: Parsec [Char] ParserState Inline
1075+strikeout :: Parser [Char] ParserState Inline
10761076strikeout = Strikeout `liftM`
10771077 (failIfStrict >> inlinesBetween strikeStart strikeEnd)
10781078 where strikeStart = string "~~" >> lookAhead nonspaceChar
10791079 >> notFollowedBy (char '~')
10801080 strikeEnd = try $ string "~~"
10811081
1082−superscript :: Parsec [Char] ParserState Inline
1082+superscript :: Parser [Char] ParserState Inline
10831083superscript = failIfStrict >> enclosed (char '^') (char '^')
10841084 (notFollowedBy spaceChar >> inline) >>= -- may not contain Space
10851085 return . Superscript
10861086
1087−subscript :: Parsec [Char] ParserState Inline
1087+subscript :: Parser [Char] ParserState Inline
10881088subscript = failIfStrict >> enclosed (char '~') (char '~')
10891089 (notFollowedBy spaceChar >> inline) >>= -- may not contain Space
10901090 return . Subscript
10911091
1092−whitespace :: Parsec [Char] ParserState Inline
1092+whitespace :: Parser [Char] ParserState Inline
10931093whitespace = spaceChar >>
10941094 ( (spaceChar >> skipMany spaceChar >> option Space (endline >> return LineBreak))
10951095 <|> (skipMany spaceChar >> return Space) ) <?> "whitespace"
10961096
1097−nonEndline :: Parsec [Char] st Char
1097+nonEndline :: Parser [Char] st Char
10981098nonEndline = satisfy (/='\n')
10991099
1100−str :: Parsec [Char] ParserState Inline
1100+str :: Parser [Char] ParserState Inline
11011101str = do
11021102 smart <- stateSmart `fmap` getState
11031103 a <- alphaNum
@@ -1135,7 +1135,7 @@ likelyAbbrev x =
11351135 in map snd $ filter (\(y,_) -> y == x) abbrPairs
11361136
11371137-- an endline character that can be treated as a space, not a structural break
1138−endline :: Parsec [Char] ParserState Inline
1138+endline :: Parser [Char] ParserState Inline
11391139endline = try $ do
11401140 newline
11411141 notFollowedBy blankline
@@ -1154,20 +1154,20 @@ endline = try $ do
11541154--
11551155
11561156-- a reference label for a link
1157−reference :: Parsec [Char] ParserState [Inline]
1157+reference :: Parser [Char] ParserState [Inline]
11581158reference = do notFollowedBy' (string "[^") -- footnote reference
11591159 result <- inlinesInBalancedBrackets inline
11601160 return $ normalizeSpaces result
11611161
11621162-- source for a link, with optional title
1163−source :: Parsec [Char] ParserState (String, [Char])
1163+source :: Parser [Char] ParserState (String, [Char])
11641164source =
11651165 (try $ charsInBalanced '(' ')' litChar >>= parseFromString source') <|>
11661166 -- the following is needed for cases like: [ref](/url(a).
11671167 (enclosed (char '(') (char ')') litChar >>= parseFromString source')
11681168
11691169-- auxiliary function for source
1170−source' :: Parsec [Char] ParserState (String, [Char])
1170+source' :: Parser [Char] ParserState (String, [Char])
11711171source' = do
11721172 skipSpaces
11731173 let nl = char '\n' >>~ notFollowedBy blankline
@@ -1185,7 +1185,7 @@ source' = do
11851185 eof
11861186 return (escapeURI $ removeTrailingSpace src, tit)
11871187
1188−linkTitle :: Parsec [Char] ParserState String
1188+linkTitle :: Parser [Char] ParserState String
11891189linkTitle = try $ do
11901190 (many1 spaceChar >> option '\n' newline) <|> newline
11911191 skipSpaces
@@ -1193,7 +1193,7 @@ linkTitle = try $ do
11931193 tit <- manyTill litChar (try (char delim >> skipSpaces >> eof))
11941194 return $ fromEntities tit
11951195
1196−link :: Parsec [Char] ParserState Inline
1196+link :: Parser [Char] ParserState Inline
11971197link = try $ do
11981198 lab <- reference
11991199 (src, tit) <- source <|> referenceLink lab
@@ -1206,7 +1206,7 @@ delinkify = bottomUp $ concatMap go
12061206
12071207-- a link like [this][ref] or [this][] or [this]
12081208referenceLink :: [Inline]
1209− -> Parsec [Char] ParserState (String, [Char])
1209+ -> Parser [Char] ParserState (String, [Char])
12101210referenceLink lab = do
12111211 ref <- option [] (try (optional (char ' ') >>
12121212 optional (newline >> skipSpaces) >> reference))
@@ -1216,7 +1216,7 @@ referenceLink lab = do
12161216 Nothing -> fail "no corresponding key"
12171217 Just target -> return target
12181218
1219−autoLink :: Parsec [Char] ParserState Inline
1219+autoLink :: Parser [Char] ParserState Inline
12201220autoLink = try $ do
12211221 char '<'
12221222 (orig, src) <- uri <|> emailAddress
@@ -1226,14 +1226,14 @@ autoLink = try $ do
12261226 then Link [Str orig] (src, "")
12271227 else Link [Code ("",["url"],[]) orig] (src, "")
12281228
1229−image :: Parsec [Char] ParserState Inline
1229+image :: Parser [Char] ParserState Inline
12301230image = try $ do
12311231 char '!'
12321232 lab <- reference
12331233 (src, tit) <- source <|> referenceLink lab
12341234 return $ Image lab (src,tit)
12351235
1236−note :: Parsec [Char] ParserState Inline
1236+note :: Parser [Char] ParserState Inline
12371237note = try $ do
12381238 failIfStrict
12391239 ref <- noteMarker
@@ -1250,21 +1250,21 @@ note = try $ do
12501250 updateState $ \st -> st{ stateNotes = notes }
12511251 return $ Note contents
12521252
1253−inlineNote :: Parsec [Char] ParserState Inline
1253+inlineNote :: Parser [Char] ParserState Inline
12541254inlineNote = try $ do
12551255 failIfStrict
12561256 char '^'
12571257 contents <- inlinesInBalancedBrackets inline
12581258 return $ Note [Para contents]
12591259
1260−rawLaTeXInline' :: Parsec [Char] ParserState Inline
1260+rawLaTeXInline' :: Parser [Char] ParserState Inline
12611261rawLaTeXInline' = try $ do
12621262 failIfStrict
12631263 lookAhead $ char '\\' >> notFollowedBy' (string "start") -- context env
12641264 RawInline _ s <- rawLaTeXInline
12651265 return $ RawInline "tex" s -- "tex" because it might be context or latex
12661266
1267−rawConTeXtEnvironment :: Parsec [Char] st String
1267+rawConTeXtEnvironment :: Parser [Char] st String
12681268rawConTeXtEnvironment = try $ do
12691269 string "\\start"
12701270 completion <- inBrackets (letter <|> digit <|> spaceChar)
@@ -1273,14 +1273,14 @@ rawConTeXtEnvironment = try $ do
12731273 (try $ string "\\stop" >> string completion)
12741274 return $ "\\start" ++ completion ++ concat contents ++ "\\stop" ++ completion
12751275
1276−inBrackets :: (Parsec [Char] st Char) -> Parsec [Char] st String
1276+inBrackets :: (Parser [Char] st Char) -> Parser [Char] st String
12771277inBrackets parser = do
12781278 char '['
12791279 contents <- many parser
12801280 char ']'
12811281 return $ "[" ++ contents ++ "]"
12821282
1283−rawHtmlInline :: Parsec [Char] ParserState Inline
1283+rawHtmlInline :: Parser [Char] ParserState Inline
12841284rawHtmlInline = do
12851285 st <- getState
12861286 (_,result) <- if stateStrict st
@@ -1290,20 +1290,20 @@ rawHtmlInline = do
12901290
12911291-- Citations
12921292
1293−cite :: Parsec [Char] ParserState Inline
1293+cite :: Parser [Char] ParserState Inline
12941294cite = do
12951295 failIfStrict
12961296 citations <- textualCite <|> normalCite
12971297 return $ Cite citations []
12981298
1299−spnl :: Parsec [Char] st ()
1299+spnl :: Parser [Char] st ()
13001300spnl = try $ do
13011301 skipSpaces
13021302 optional newline
13031303 skipSpaces
13041304 notFollowedBy (char '\n')
13051305
1306−textualCite :: Parsec [Char] ParserState [Citation]
1306+textualCite :: Parser [Char] ParserState [Citation]
13071307textualCite = try $ do
13081308 (_, key) <- citeKey
13091309 let first = Citation{ citationId = key
@@ -1318,7 +1318,7 @@ textualCite = try $ do
13181318 then option [first] $ bareloc first
13191319 else return $ first : rest
13201320
1321−bareloc :: Citation -> Parsec [Char] ParserState [Citation]
1321+bareloc :: Citation -> Parser [Char] ParserState [Citation]
13221322bareloc c = try $ do
13231323 spnl
13241324 char '['
@@ -1328,7 +1328,7 @@ bareloc c = try $ do
13281328 char ']'
13291329 return $ c{ citationSuffix = suff } : rest
13301330
1331−normalCite :: Parsec [Char] ParserState [Citation]
1331+normalCite :: Parser [Char] ParserState [Citation]
13321332normalCite = try $ do
13331333 char '['
13341334 spnl
@@ -1337,7 +1337,7 @@ normalCite = try $ do
13371337 char ']'
13381338 return citations
13391339
1340−citeKey :: Parsec [Char] ParserState (Bool, String)
1340+citeKey :: Parser [Char] ParserState (Bool, String)
13411341citeKey = try $ do
13421342 suppress_author <- option False (char '-' >> return True)
13431343 char '@'
@@ -1349,7 +1349,7 @@ citeKey = try $ do
13491349 guard $ key `elem` stateCitations st
13501350 return (suppress_author, key)
13511351
1352−suffix :: Parsec [Char] ParserState [Inline]
1352+suffix :: Parser [Char] ParserState [Inline]
13531353suffix = try $ do
13541354 hasSpace <- option False (notFollowedBy nonspaceChar >> return True)
13551355 spnl
@@ -1358,14 +1358,14 @@ suffix = try $ do
13581358 then Space : rest
13591359 else rest
13601360
1361−prefix :: Parsec [Char] ParserState [Inline]
1361+prefix :: Parser [Char] ParserState [Inline]
13621362prefix = liftM normalizeSpaces $
13631363 manyTill inline (char ']' <|> liftM (const ']') (lookAhead citeKey))
13641364
1365−citeList :: Parsec [Char] ParserState [Citation]
1365+citeList :: Parser [Char] ParserState [Citation]
13661366citeList = sepBy1 citation (try $ char ';' >> spnl)
13671367
1368−citation :: Parsec [Char] ParserState Citation
1368+citation :: Parser [Char] ParserState Citation
13691369citation = try $ do
13701370 pref <- prefix
13711371 (suppress_author, key) <- citeKey
src/Text/Pandoc/Readers/RST.hs+92−92
@@ -88,7 +88,7 @@ titleTransform ((Header 1 head1):rest) |
8888 (promoteHeaders 1 rest, head1)
8989titleTransform blocks = (blocks, [])
9090
91−parseRST :: Parsec [Char] ParserState Pandoc
91+parseRST :: Parser [Char] ParserState Pandoc
9292parseRST = do
9393 optional blanklines -- skip blank lines at beginning of file
9494 startPos <- getPosition
@@ -117,10 +117,10 @@ parseRST = do
117117-- parsing blocks
118118--
119119
120−parseBlocks :: Parsec [Char] ParserState [Block]
120+parseBlocks :: Parser [Char] ParserState [Block]
121121parseBlocks = manyTill block eof
122122
123−block :: Parsec [Char] ParserState Block
123+block :: Parser [Char] ParserState Block
124124block = choice [ codeBlock
125125 , rawBlock
126126 , blockQuote
@@ -145,7 +145,7 @@ block = choice [ codeBlock
145145-- field list
146146--
147147
148−rawFieldListItem :: String -> Parsec [Char] ParserState (String, String)
148+rawFieldListItem :: String -> Parser [Char] ParserState (String, String)
149149rawFieldListItem indent = try $ do
150150 string indent
151151 char ':'
@@ -159,7 +159,7 @@ rawFieldListItem indent = try $ do
159159 return (name, raw)
160160
161161fieldListItem :: String
162− -> Parsec [Char] ParserState (Maybe ([Inline], [[Block]]))
162+ -> Parser [Char] ParserState (Maybe ([Inline], [[Block]]))
163163fieldListItem indent = try $ do
164164 (name, raw) <- rawFieldListItem indent
165165 let term = [Str name]
@@ -186,7 +186,7 @@ extractContents [Plain auth] = auth
186186extractContents [Para auth] = auth
187187extractContents _ = []
188188
189−fieldList :: Parsec [Char] ParserState Block
189+fieldList :: Parser [Char] ParserState Block
190190fieldList = try $ do
191191 indent <- lookAhead $ many spaceChar
192192 items <- many1 $ fieldListItem indent
@@ -198,7 +198,7 @@ fieldList = try $ do
198198-- line block
199199--
200200
201−lineBlockLine :: Parsec [Char] ParserState [Inline]
201+lineBlockLine :: Parser [Char] ParserState [Inline]
202202lineBlockLine = try $ do
203203 char '|'
204204 char ' ' <|> lookAhead (char '\n')
@@ -209,7 +209,7 @@ lineBlockLine = try $ do
209209 then normalizeSpaces line
210210 else Str white : normalizeSpaces line
211211
212−lineBlock :: Parsec [Char] ParserState Block
212+lineBlock :: Parser [Char] ParserState Block
213213lineBlock = try $ do
214214 lines' <- many1 lineBlockLine
215215 blanklines
@@ -219,14 +219,14 @@ lineBlock = try $ do
219219-- paragraph block
220220--
221221
222−para :: Parsec [Char] ParserState Block
222+para :: Parser [Char] ParserState Block
223223para = paraBeforeCodeBlock <|> paraNormal <?> "paragraph"
224224
225−codeBlockStart :: Parsec [Char] st Char
225+codeBlockStart :: Parser [Char] st Char
226226codeBlockStart = string "::" >> blankline >> blankline
227227
228228-- paragraph that ends in a :: starting a code block
229−paraBeforeCodeBlock :: Parsec [Char] ParserState Block
229+paraBeforeCodeBlock :: Parser [Char] ParserState Block
230230paraBeforeCodeBlock = try $ do
231231 result <- many1 (notFollowedBy' codeBlockStart >> inline)
232232 lookAhead (string "::")
@@ -235,21 +235,21 @@ paraBeforeCodeBlock = try $ do
235235 else (normalizeSpaces result) ++ [Str ":"]
236236
237237-- regular paragraph
238−paraNormal :: Parsec [Char] ParserState Block
238+paraNormal :: Parser [Char] ParserState Block
239239paraNormal = try $ do
240240 result <- many1 inline
241241 newline
242242 blanklines
243243 return $ Para $ normalizeSpaces result
244244
245−plain :: Parsec [Char] ParserState Block
245+plain :: Parser [Char] ParserState Block
246246plain = many1 inline >>= return . Plain . normalizeSpaces
247247
248248--
249249-- image block
250250--
251251
252−imageBlock :: Parsec [Char] ParserState Block
252+imageBlock :: Parser [Char] ParserState Block
253253imageBlock = try $ do
254254 string ".. image:: "
255255 src <- manyTill anyChar newline
@@ -264,11 +264,11 @@ imageBlock = try $ do
264264-- header blocks
265265--
266266
267−header :: Parsec [Char] ParserState Block
267+header :: Parser [Char] ParserState Block
268268header = doubleHeader <|> singleHeader <?> "header"
269269
270270-- a header with lines on top and bottom
271−doubleHeader :: Parsec [Char] ParserState Block
271+doubleHeader :: Parser [Char] ParserState Block
272272doubleHeader = try $ do
273273 c <- oneOf underlineChars
274274 rest <- many (char c) -- the top line
@@ -293,7 +293,7 @@ doubleHeader = try $ do
293293 return $ Header level (normalizeSpaces txt)
294294
295295-- a header with line on the bottom only
296−singleHeader :: Parsec [Char] ParserState Block
296+singleHeader :: Parser [Char] ParserState Block
297297singleHeader = try $ do
298298 notFollowedBy' whitespace
299299 txt <- many1 (do {notFollowedBy blankline; inline})
@@ -316,7 +316,7 @@ singleHeader = try $ do
316316-- hrule block
317317--
318318
319−hrule :: Parsec [Char] st Block
319+hrule :: Parser [Char] st Block
320320hrule = try $ do
321321 chr <- oneOf underlineChars
322322 count 3 (char chr)
@@ -330,14 +330,14 @@ hrule = try $ do
330330--
331331
332332-- read a line indented by a given string
333−indentedLine :: String -> Parsec [Char] st [Char]
333+indentedLine :: String -> Parser [Char] st [Char]
334334indentedLine indents = try $ do
335335 string indents
336336 manyTill anyChar newline
337337
338338-- one or more indented lines, possibly separated by blank lines.
339339-- any amount of indentation will work.
340−indentedBlock :: Parsec [Char] st [Char]
340+indentedBlock :: Parser [Char] st [Char]
341341indentedBlock = try $ do
342342 indents <- lookAhead $ many1 spaceChar
343343 lns <- many1 $ try $ do b <- option "" blanklines
@@ -346,7 +346,7 @@ indentedBlock = try $ do
346346 optional blanklines
347347 return $ unlines lns
348348
349−codeBlock :: Parsec [Char] st Block
349+codeBlock :: Parser [Char] st Block
350350codeBlock = try $ do
351351 codeBlockStart
352352 result <- indentedBlock
@@ -354,7 +354,7 @@ codeBlock = try $ do
354354
355355-- | The 'code-block' directive (from Sphinx) that allows a language to be
356356-- specified.
357−customCodeBlock :: Parsec [Char] st Block
357+customCodeBlock :: Parser [Char] st Block
358358customCodeBlock = try $ do
359359 string ".. code-block:: "
360360 language <- manyTill anyChar newline
@@ -363,7 +363,7 @@ customCodeBlock = try $ do
363363 return $ CodeBlock ("", ["sourceCode", language], []) $ stripTrailingNewlines result
364364
365365
366−figureBlock :: Parsec [Char] ParserState Block
366+figureBlock :: Parser [Char] ParserState Block
367367figureBlock = try $ do
368368 string ".. figure::"
369369 src <- removeLeadingTrailingSpace `fmap` manyTill anyChar newline
@@ -371,24 +371,24 @@ figureBlock = try $ do
371371 caption <- parseFromString extractCaption body
372372 return $ Para [Image caption (src,"")]
373373
374−extractCaption :: Parsec [Char] ParserState [Inline]
374+extractCaption :: Parser [Char] ParserState [Inline]
375375extractCaption = try $ do
376376 manyTill anyLine blanklines
377377 many inline
378378
379379-- | The 'math' directive (from Sphinx) for display math.
380−mathBlock :: Parsec [Char] st Block
380+mathBlock :: Parser [Char] st Block
381381mathBlock = try $ do
382382 string ".. math::"
383383 mathBlockMultiline <|> mathBlockOneLine
384384
385−mathBlockOneLine :: Parsec [Char] st Block
385+mathBlockOneLine :: Parser [Char] st Block
386386mathBlockOneLine = try $ do
387387 result <- manyTill anyChar newline
388388 blanklines
389389 return $ Para [Math DisplayMath $ removeLeadingTrailingSpace result]
390390
391−mathBlockMultiline :: Parsec [Char] st Block
391+mathBlockMultiline :: Parser [Char] st Block
392392mathBlockMultiline = try $ do
393393 blanklines
394394 result <- indentedBlock
@@ -403,7 +403,7 @@ mathBlockMultiline = try $ do
403403 $ filter (not . null) $ splitBy null lns'
404404 return $ Para $ map (Math DisplayMath) eqs
405405
406−lhsCodeBlock :: Parsec [Char] ParserState Block
406+lhsCodeBlock :: Parser [Char] ParserState Block
407407lhsCodeBlock = try $ do
408408 failUnlessLHS
409409 optional codeBlockStart
@@ -417,7 +417,7 @@ lhsCodeBlock = try $ do
417417 blanklines
418418 return $ CodeBlock ("", ["sourceCode", "literate", "haskell"], []) $ intercalate "\n" lns'
419419
420−birdTrackLine :: Parsec [Char] st [Char]
420+birdTrackLine :: Parser [Char] st [Char]
421421birdTrackLine = do
422422 char '>'
423423 manyTill anyChar newline
@@ -426,7 +426,7 @@ birdTrackLine = do
426426-- raw html/latex/etc
427427--
428428
429−rawBlock :: Parsec [Char] st Block
429+rawBlock :: Parser [Char] st Block
430430rawBlock = try $ do
431431 string ".. raw:: "
432432 lang <- many1 (letter <|> digit)
@@ -438,7 +438,7 @@ rawBlock = try $ do
438438-- block quotes
439439--
440440
441−blockQuote :: Parsec [Char] ParserState Block
441+blockQuote :: Parser [Char] ParserState Block
442442blockQuote = do
443443 raw <- indentedBlock
444444 -- parse the extracted block, which may contain various block elements:
@@ -449,10 +449,10 @@ blockQuote = do
449449-- list blocks
450450--
451451
452−list :: Parsec [Char] ParserState Block
452+list :: Parser [Char] ParserState Block
453453list = choice [ bulletList, orderedList, definitionList ] <?> "list"
454454
455−definitionListItem :: Parsec [Char] ParserState ([Inline], [[Block]])
455+definitionListItem :: Parser [Char] ParserState ([Inline], [[Block]])
456456definitionListItem = try $ do
457457 -- avoid capturing a directive or comment
458458 notFollowedBy (try $ char '.' >> char '.')
@@ -462,11 +462,11 @@ definitionListItem = try $ do
462462 contents <- parseFromString parseBlocks $ raw ++ "\n"
463463 return (normalizeSpaces term, [contents])
464464
465−definitionList :: Parsec [Char] ParserState Block
465+definitionList :: Parser [Char] ParserState Block
466466definitionList = many1 definitionListItem >>= return . DefinitionList
467467
468468-- parses bullet list start and returns its length (inc. following whitespace)
469−bulletListStart :: Parsec [Char] st Int
469+bulletListStart :: Parser [Char] st Int
470470bulletListStart = try $ do
471471 notFollowedBy' hrule -- because hrules start out just like lists
472472 marker <- oneOf bulletListMarkers
@@ -476,14 +476,14 @@ bulletListStart = try $ do
476476-- parses ordered list start and returns its length (inc following whitespace)
477477orderedListStart :: ListNumberStyle
478478 -> ListNumberDelim
479− -> Parsec [Char] ParserState Int
479+ -> Parser [Char] ParserState Int
480480orderedListStart style delim = try $ do
481481 (_, markerLen) <- withHorizDisplacement (orderedListMarker style delim)
482482 white <- many1 spaceChar
483483 return $ markerLen + length white
484484
485485-- parse a line of a list item
486−listLine :: Int -> Parsec [Char] ParserState [Char]
486+listLine :: Int -> Parser [Char] ParserState [Char]
487487listLine markerLength = try $ do
488488 notFollowedBy blankline
489489 indentWith markerLength
@@ -491,7 +491,7 @@ listLine markerLength = try $ do
491491 return $ line ++ "\n"
492492
493493-- indent by specified number of spaces (or equiv. tabs)
494−indentWith :: Int -> Parsec [Char] ParserState [Char]
494+indentWith :: Int -> Parser [Char] ParserState [Char]
495495indentWith num = do
496496 state <- getState
497497 let tabStop = stateTabStop state
@@ -501,8 +501,8 @@ indentWith num = do
501501 (try (char '\t' >> count (num - tabStop) (char ' '))) ]
502502
503503-- parse raw text for one list item, excluding start marker and continuations
504−rawListItem :: Parsec [Char] ParserState Int
505− -> Parsec [Char] ParserState (Int, [Char])
504+rawListItem :: Parser [Char] ParserState Int
505+ -> Parser [Char] ParserState (Int, [Char])
506506rawListItem start = try $ do
507507 markerLength <- start
508508 firstLine <- manyTill anyChar newline
@@ -512,14 +512,14 @@ rawListItem start = try $ do
512512-- continuation of a list item - indented and separated by blankline or
513513-- (in compact lists) endline.
514514-- Note: nested lists are parsed as continuations.
515−listContinuation :: Int -> Parsec [Char] ParserState [Char]
515+listContinuation :: Int -> Parser [Char] ParserState [Char]
516516listContinuation markerLength = try $ do
517517 blanks <- many1 blankline
518518 result <- many1 (listLine markerLength)
519519 return $ blanks ++ concat result
520520
521−listItem :: Parsec [Char] ParserState Int
522− -> Parsec [Char] ParserState [Block]
521+listItem :: Parser [Char] ParserState Int
522+ -> Parser [Char] ParserState [Block]
523523listItem start = try $ do
524524 (markerLength, first) <- rawListItem start
525525 rest <- many (listContinuation markerLength)
@@ -536,14 +536,14 @@ listItem start = try $ do
536536 updateState (\st -> st {stateParserContext = oldContext})
537537 return parsed
538538
539−orderedList :: Parsec [Char] ParserState Block
539+orderedList :: Parser [Char] ParserState Block
540540orderedList = try $ do
541541 (start, style, delim) <- lookAhead (anyOrderedListMarker >>~ spaceChar)
542542 items <- many1 (listItem (orderedListStart style delim))
543543 let items' = compactify items
544544 return $ OrderedList (start, style, delim) items'
545545
546−bulletList :: Parsec [Char] ParserState Block
546+bulletList :: Parser [Char] ParserState Block
547547bulletList = many1 (listItem bulletListStart) >>=
548548 return . BulletList . compactify
549549
@@ -551,7 +551,7 @@ bulletList = many1 (listItem bulletListStart) >>=
551551-- default-role block
552552--
553553
554−defaultRoleBlock :: Parsec [Char] ParserState Block
554+defaultRoleBlock :: Parser [Char] ParserState Block
555555defaultRoleBlock = try $ do
556556 string ".. default-role::"
557557 -- doesn't enforce any restrictions on the role name; embedded spaces shouldn't be allowed, for one
@@ -569,7 +569,7 @@ defaultRoleBlock = try $ do
569569-- unknown directive (e.g. comment)
570570--
571571
572−unknownDirective :: Parsec [Char] st Block
572+unknownDirective :: Parser [Char] st Block
573573unknownDirective = try $ do
574574 string ".."
575575 notFollowedBy (noneOf " \t\n")
@@ -581,7 +581,7 @@ unknownDirective = try $ do
581581--- note block
582582---
583583
584−noteBlock :: Parsec [Char] ParserState [Char]
584+noteBlock :: Parser [Char] ParserState [Char]
585585noteBlock = try $ do
586586 startPos <- getPosition
587587 string ".."
@@ -600,7 +600,7 @@ noteBlock = try $ do
600600 -- return blanks so line count isn't affected
601601 return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
602602
603−noteMarker :: Parsec [Char] ParserState [Char]
603+noteMarker :: Parser [Char] ParserState [Char]
604604noteMarker = do
605605 char '['
606606 res <- many1 digit
@@ -613,13 +613,13 @@ noteMarker = do
613613-- reference key
614614--
615615
616−quotedReferenceName :: Parsec [Char] ParserState [Inline]
616+quotedReferenceName :: Parser [Char] ParserState [Inline]
617617quotedReferenceName = try $ do
618618 char '`' >> notFollowedBy (char '`') -- `` means inline code!
619619 label' <- many1Till inline (char '`')
620620 return label'
621621
622−unquotedReferenceName :: Parsec [Char] ParserState [Inline]
622+unquotedReferenceName :: Parser [Char] ParserState [Inline]
623623unquotedReferenceName = try $ do
624624 label' <- many1Till inline (lookAhead $ char ':')
625625 return label'
@@ -628,24 +628,24 @@ unquotedReferenceName = try $ do
628628-- plus isolated (no two adjacent) internal hyphens, underscores,
629629-- periods, colons and plus signs; no whitespace or other characters
630630-- are allowed.
631−simpleReferenceName' :: Parsec [Char] st String
631+simpleReferenceName' :: Parser [Char] st String
632632simpleReferenceName' = do
633633 x <- alphaNum
634634 xs <- many $ alphaNum
635635 <|> (try $ oneOf "-_:+." >> lookAhead alphaNum)
636636 return (x:xs)
637637
638−simpleReferenceName :: Parsec [Char] st [Inline]
638+simpleReferenceName :: Parser [Char] st [Inline]
639639simpleReferenceName = do
640640 raw <- simpleReferenceName'
641641 return [Str raw]
642642
643−referenceName :: Parsec [Char] ParserState [Inline]
643+referenceName :: Parser [Char] ParserState [Inline]
644644referenceName = quotedReferenceName <|>
645645 (try $ simpleReferenceName >>~ lookAhead (char ':')) <|>
646646 unquotedReferenceName
647647
648−referenceKey :: Parsec [Char] ParserState [Char]
648+referenceKey :: Parser [Char] ParserState [Char]
649649referenceKey = do
650650 startPos <- getPosition
651651 (key, target) <- choice [imageKey, anonymousKey, regularKey]
@@ -657,7 +657,7 @@ referenceKey = do
657657 -- return enough blanks to replace key
658658 return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
659659
660−targetURI :: Parsec [Char] st [Char]
660+targetURI :: Parser [Char] st [Char]
661661targetURI = do
662662 skipSpaces
663663 optional newline
@@ -666,7 +666,7 @@ targetURI = do
666666 blanklines
667667 return $ escapeURI $ removeLeadingTrailingSpace $ contents
668668
669−imageKey :: Parsec [Char] ParserState (Key, Target)
669+imageKey :: Parser [Char] ParserState (Key, Target)
670670imageKey = try $ do
671671 string ".. |"
672672 ref <- manyTill inline (char '|')
@@ -675,14 +675,14 @@ imageKey = try $ do
675675 src <- targetURI
676676 return (toKey (normalizeSpaces ref), (src, ""))
677677
678−anonymousKey :: Parsec [Char] st (Key, Target)
678+anonymousKey :: Parser [Char] st (Key, Target)
679679anonymousKey = try $ do
680680 oneOfStrings [".. __:", "__"]
681681 src <- targetURI
682682 pos <- getPosition
683683 return (toKey [Str $ "_" ++ printf "%09d" (sourceLine pos)], (src, ""))
684684
685−regularKey :: Parsec [Char] ParserState (Key, Target)
685+regularKey :: Parser [Char] ParserState (Key, Target)
686686regularKey = try $ do
687687 string ".. _"
688688 ref <- referenceName
@@ -707,31 +707,31 @@ regularKey = try $ do
707707-- Grid tables TODO:
708708-- - column spans
709709
710−dashedLine :: Char -> Parsec [Char] st (Int, Int)
710+dashedLine :: Char -> Parser [Char] st (Int, Int)
711711dashedLine ch = do
712712 dashes <- many1 (char ch)
713713 sp <- many (char ' ')
714714 return (length dashes, length $ dashes ++ sp)
715715
716−simpleDashedLines :: Char -> Parsec [Char] st [(Int,Int)]
716+simpleDashedLines :: Char -> Parser [Char] st [(Int,Int)]
717717simpleDashedLines ch = try $ many1 (dashedLine ch)
718718
719719-- Parse a table row separator
720−simpleTableSep :: Char -> Parsec [Char] ParserState Char
720+simpleTableSep :: Char -> Parser [Char] ParserState Char
721721simpleTableSep ch = try $ simpleDashedLines ch >> newline
722722
723723-- Parse a table footer
724−simpleTableFooter :: Parsec [Char] ParserState [Char]
724+simpleTableFooter :: Parser [Char] ParserState [Char]
725725simpleTableFooter = try $ simpleTableSep '=' >> blanklines
726726
727727-- Parse a raw line and split it into chunks by indices.
728−simpleTableRawLine :: [Int] -> Parsec [Char] ParserState [String]
728+simpleTableRawLine :: [Int] -> Parser [Char] ParserState [String]
729729simpleTableRawLine indices = do
730730 line <- many1Till anyChar newline
731731 return (simpleTableSplitLine indices line)
732732
733733-- Parse a table row and return a list of blocks (columns).
734−simpleTableRow :: [Int] -> Parsec [Char] ParserState [[Block]]
734+simpleTableRow :: [Int] -> Parser [Char] ParserState [[Block]]
735735simpleTableRow indices = do
736736 notFollowedBy' simpleTableFooter
737737 firstLine <- simpleTableRawLine indices
@@ -745,7 +745,7 @@ simpleTableSplitLine indices line =
745745 $ tail $ splitByIndices (init indices) line
746746
747747simpleTableHeader :: Bool -- ^ Headerless table
748− -> Parsec [Char] ParserState ([[Block]], [Alignment], [Int])
748+ -> Parser [Char] ParserState ([[Block]], [Alignment], [Int])
749749simpleTableHeader headless = try $ do
750750 optional blanklines
751751 rawContent <- if headless
@@ -765,7 +765,7 @@ simpleTableHeader headless = try $ do
765765
766766-- Parse a simple table.
767767simpleTable :: Bool -- ^ Headerless table
768− -> Parsec [Char] ParserState Block
768+ -> Parser [Char] ParserState Block
769769simpleTable headless = do
770770 Table c a _w h l <- tableWith (simpleTableHeader headless) simpleTableRow sep simpleTableFooter (return [])
771771 -- Simple tables get 0s for relative column widths (i.e., use default)
@@ -774,10 +774,10 @@ simpleTable headless = do
774774 sep = return () -- optional (simpleTableSep '-')
775775
776776gridTable :: Bool -- ^ Headerless table
777− -> Parsec [Char] ParserState Block
777+ -> Parser [Char] ParserState Block
778778gridTable = gridTableWith block (return [])
779779
780−table :: Parsec [Char] ParserState Block
780+table :: Parser [Char] ParserState Block
781781table = gridTable False <|> simpleTable False <|>
782782 gridTable True <|> simpleTable True <?> "table"
783783
@@ -786,7 +786,7 @@ table = gridTable False <|> simpleTable False <|>
786786 -- inline
787787 --
788788
789−inline :: Parsec [Char] ParserState Inline
789+inline :: Parser [Char] ParserState Inline
790790inline = choice [ whitespace
791791 , link
792792 , str
@@ -804,26 +804,26 @@ inline = choice [ whitespace
804804 , escapedChar
805805 , symbol ] <?> "inline"
806806
807−hyphens :: Parsec [Char] ParserState Inline
807+hyphens :: Parser [Char] ParserState Inline
808808hyphens = do
809809 result <- many1 (char '-')
810810 option Space endline
811811 -- don't want to treat endline after hyphen or dash as a space
812812 return $ Str result
813813
814−escapedChar :: Parsec [Char] st Inline
814+escapedChar :: Parser [Char] st Inline
815815escapedChar = do c <- escaped anyChar
816816 return $ if c == ' ' -- '\ ' is null in RST
817817 then Str ""
818818 else Str [c]
819819
820−symbol :: Parsec [Char] ParserState Inline
820+symbol :: Parser [Char] ParserState Inline
821821symbol = do
822822 result <- oneOf specialChars
823823 return $ Str [result]
824824
825825-- parses inline code, between codeStart and codeEnd
826−code :: Parsec [Char] ParserState Inline
826+code :: Parser [Char] ParserState Inline
827827code = try $ do
828828 string "``"
829829 result <- manyTill anyChar (try (string "``"))
@@ -831,7 +831,7 @@ code = try $ do
831831 $ removeLeadingTrailingSpace $ intercalate " " $ lines result
832832
833833-- succeeds only if we're not right after a str (ie. in middle of word)
834−atStart :: Parsec [Char] ParserState a -> Parsec [Char] ParserState a
834+atStart :: Parser [Char] ParserState a -> Parser [Char] ParserState a
835835atStart p = do
836836 pos <- getPosition
837837 st <- getState
@@ -839,18 +839,18 @@ atStart p = do
839839 guard $ stateLastStrPos st /= Just pos
840840 p
841841
842−emph :: Parsec [Char] ParserState Inline
842+emph :: Parser [Char] ParserState Inline
843843emph = enclosed (atStart $ char '*') (char '*') inline >>=
844844 return . Emph . normalizeSpaces
845845
846−strong :: Parsec [Char] ParserState Inline
846+strong :: Parser [Char] ParserState Inline
847847strong = enclosed (atStart $ string "**") (try $ string "**") inline >>=
848848 return . Strong . normalizeSpaces
849849
850850-- Parses inline interpreted text which is required to have the given role.
851851-- This decision is based on the role marker (if present),
852852-- and the current default interpreted text role.
853−interpreted :: [Char] -> Parsec [Char] ParserState [Char]
853+interpreted :: [Char] -> Parser [Char] ParserState [Char]
854854interpreted role = try $ do
855855 state <- getState
856856 if role == stateRstDefaultRole state
@@ -867,19 +867,19 @@ interpreted role = try $ do
867867 result <- enclosed (atStart $ char '`') (char '`') anyChar
868868 return result
869869
870−superscript :: Parsec [Char] ParserState Inline
870+superscript :: Parser [Char] ParserState Inline
871871superscript = interpreted "sup" >>= \x -> return (Superscript [Str x])
872872
873−subscript :: Parsec [Char] ParserState Inline
873+subscript :: Parser [Char] ParserState Inline
874874subscript = interpreted "sub" >>= \x -> return (Subscript [Str x])
875875
876−math :: Parsec [Char] ParserState Inline
876+math :: Parser [Char] ParserState Inline
877877math = interpreted "math" >>= \x -> return (Math InlineMath x)
878878
879−whitespace :: Parsec [Char] ParserState Inline
879+whitespace :: Parser [Char] ParserState Inline
880880whitespace = many1 spaceChar >> return Space <?> "whitespace"
881881
882−str :: Parsec [Char] ParserState Inline
882+str :: Parser [Char] ParserState Inline
883883str = do
884884 let strChar = noneOf ("\t\n " ++ specialChars)
885885 result <- many1 strChar
@@ -887,7 +887,7 @@ str = do
887887 return $ Str result
888888
889889-- an endline character that can be treated as a space, not a structural break
890−endline :: Parsec [Char] ParserState Inline
890+endline :: Parser [Char] ParserState Inline
891891endline = try $ do
892892 newline
893893 notFollowedBy blankline
@@ -903,10 +903,10 @@ endline = try $ do
903903-- links
904904--
905905
906−link :: Parsec [Char] ParserState Inline
906+link :: Parser [Char] ParserState Inline
907907link = choice [explicitLink, referenceLink, autoLink] <?> "link"
908908
909−explicitLink :: Parsec [Char] ParserState Inline
909+explicitLink :: Parser [Char] ParserState Inline
910910explicitLink = try $ do
911911 char '`'
912912 notFollowedBy (char '`') -- `` marks start of inline code
@@ -918,7 +918,7 @@ explicitLink = try $ do
918918 return $ Link (normalizeSpaces label')
919919 (escapeURI $ removeLeadingTrailingSpace src, "")
920920
921−referenceLink :: Parsec [Char] ParserState Inline
921+referenceLink :: Parser [Char] ParserState Inline
922922referenceLink = try $ do
923923 label' <- (quotedReferenceName <|> simpleReferenceName) >>~ char '_'
924924 state <- getState
@@ -939,21 +939,21 @@ referenceLink = try $ do
939939 when (isAnonKey key) $ updateState $ \s -> s{ stateKeys = M.delete key keyTable }
940940 return $ Link (normalizeSpaces label') (src, tit)
941941
942−autoURI :: Parsec [Char] ParserState Inline
942+autoURI :: Parser [Char] ParserState Inline
943943autoURI = do
944944 (orig, src) <- uri
945945 return $ Link [Str orig] (src, "")
946946
947−autoEmail :: Parsec [Char] ParserState Inline
947+autoEmail :: Parser [Char] ParserState Inline
948948autoEmail = do
949949 (orig, src) <- emailAddress
950950 return $ Link [Str orig] (src, "")
951951
952−autoLink :: Parsec [Char] ParserState Inline
952+autoLink :: Parser [Char] ParserState Inline
953953autoLink = autoURI <|> autoEmail
954954
955955-- For now, we assume that all substitution references are for images.
956−image :: Parsec [Char] ParserState Inline
956+image :: Parser [Char] ParserState Inline
957957image = try $ do
958958 char '|'
959959 ref <- manyTill inline (char '|')
@@ -964,7 +964,7 @@ image = try $ do
964964 Just target -> return target
965965 return $ Image (normalizeSpaces ref) (src, tit)
966966
967−note :: Parsec [Char] ParserState Inline
967+note :: Parser [Char] ParserState Inline
968968note = try $ do
969969 ref <- noteMarker
970970 char '_'
src/Text/Pandoc/Readers/Textile.hs+68−68
@@ -74,7 +74,7 @@ readTextile state s =
7474
7575
7676-- | Generate a Pandoc ADT from a textile document
77−parseTextile :: Parsec [Char] ParserState Pandoc
77+parseTextile :: Parser [Char] ParserState Pandoc
7878parseTextile = do
7979 -- textile allows raw HTML and does smart punctuation by default
8080 updateState (\state -> state { stateParseRaw = True, stateSmart = True })
@@ -92,10 +92,10 @@ parseTextile = do
9292 blocks <- parseBlocks
9393 return $ Pandoc (Meta [] [] []) blocks -- FIXME
9494
95−noteMarker :: Parsec [Char] ParserState [Char]
95+noteMarker :: Parser [Char] ParserState [Char]
9696noteMarker = skipMany spaceChar >> string "fn" >> manyTill digit (char '.')
9797
98−noteBlock :: Parsec [Char] ParserState [Char]
98+noteBlock :: Parser [Char] ParserState [Char]
9999noteBlock = try $ do
100100 startPos <- getPosition
101101 ref <- noteMarker
@@ -110,11 +110,11 @@ noteBlock = try $ do
110110 return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
111111
112112-- | Parse document blocks
113−parseBlocks :: Parsec [Char] ParserState [Block]
113+parseBlocks :: Parser [Char] ParserState [Block]
114114parseBlocks = manyTill block eof
115115
116116-- | Block parsers list tried in definition order
117−blockParsers :: [Parsec [Char] ParserState Block]
117+blockParsers :: [Parser [Char] ParserState Block]
118118blockParsers = [ codeBlock
119119 , header
120120 , blockQuote
@@ -127,20 +127,20 @@ blockParsers = [ codeBlock
127127 , nullBlock ]
128128
129129-- | Any block in the order of definition of blockParsers
130−block :: Parsec [Char] ParserState Block
130+block :: Parser [Char] ParserState Block
131131block = choice blockParsers <?> "block"
132132
133−codeBlock :: Parsec [Char] ParserState Block
133+codeBlock :: Parser [Char] ParserState Block
134134codeBlock = codeBlockBc <|> codeBlockPre
135135
136−codeBlockBc :: Parsec [Char] ParserState Block
136+codeBlockBc :: Parser [Char] ParserState Block
137137codeBlockBc = try $ do
138138 string "bc. "
139139 contents <- manyTill anyLine blanklines
140140 return $ CodeBlock ("",[],[]) $ unlines contents
141141
142142-- | Code Blocks in Textile are between <pre> and </pre>
143−codeBlockPre :: Parsec [Char] ParserState Block
143+codeBlockPre :: Parser [Char] ParserState Block
144144codeBlockPre = try $ do
145145 htmlTag (tagOpen (=="pre") null)
146146 result' <- manyTill anyChar (try $ htmlTag (tagClose (=="pre")) >> blockBreak)
@@ -155,7 +155,7 @@ codeBlockPre = try $ do
155155 return $ CodeBlock ("",[],[]) result'''
156156
157157-- | Header of the form "hN. content" with N in 1..6
158−header :: Parsec [Char] ParserState Block
158+header :: Parser [Char] ParserState Block
159159header = try $ do
160160 char 'h'
161161 level <- digitToInt <$> oneOf "123456"
@@ -164,14 +164,14 @@ header = try $ do
164164 return $ Header level name
165165
166166-- | Blockquote of the form "bq. content"
167−blockQuote :: Parsec [Char] ParserState Block
167+blockQuote :: Parser [Char] ParserState Block
168168blockQuote = try $ do
169169 string "bq" >> optional attributes >> char '.' >> whitespace
170170 BlockQuote . singleton <$> para
171171
172172-- Horizontal rule
173173
174−hrule :: Parsec [Char] st Block
174+hrule :: Parser [Char] st Block
175175hrule = try $ do
176176 skipSpaces
177177 start <- oneOf "-*"
@@ -186,39 +186,39 @@ hrule = try $ do
186186-- | Can be a bullet list or an ordered list. This implementation is
187187-- strict in the nesting, sublist must start at exactly "parent depth
188188-- plus one"
189−anyList :: Parsec [Char] ParserState Block
189+anyList :: Parser [Char] ParserState Block
190190anyList = try $ ( (anyListAtDepth 1) <* blanklines )
191191
192192-- | This allow one type of list to be nested into an other type,
193193-- provided correct nesting
194−anyListAtDepth :: Int -> Parsec [Char] ParserState Block
194+anyListAtDepth :: Int -> Parser [Char] ParserState Block
195195anyListAtDepth depth = choice [ bulletListAtDepth depth,
196196 orderedListAtDepth depth,
197197 definitionList ]
198198
199199-- | Bullet List of given depth, depth being the number of leading '*'
200−bulletListAtDepth :: Int -> Parsec [Char] ParserState Block
200+bulletListAtDepth :: Int -> Parser [Char] ParserState Block
201201bulletListAtDepth depth = try $ BulletList <$> many1 (bulletListItemAtDepth depth)
202202
203203-- | Bullet List Item of given depth, depth being the number of
204204-- leading '*'
205−bulletListItemAtDepth :: Int -> Parsec [Char] ParserState [Block]
205+bulletListItemAtDepth :: Int -> Parser [Char] ParserState [Block]
206206bulletListItemAtDepth = genericListItemAtDepth '*'
207207
208208-- | Ordered List of given depth, depth being the number of
209209-- leading '#'
210−orderedListAtDepth :: Int -> Parsec [Char] ParserState Block
210+orderedListAtDepth :: Int -> Parser [Char] ParserState Block
211211orderedListAtDepth depth = try $ do
212212 items <- many1 (orderedListItemAtDepth depth)
213213 return (OrderedList (1, DefaultStyle, DefaultDelim) items)
214214
215215-- | Ordered List Item of given depth, depth being the number of
216216-- leading '#'
217−orderedListItemAtDepth :: Int -> Parsec [Char] ParserState [Block]
217+orderedListItemAtDepth :: Int -> Parser [Char] ParserState [Block]
218218orderedListItemAtDepth = genericListItemAtDepth '#'
219219
220220-- | Common implementation of list items
221−genericListItemAtDepth :: Char -> Int -> Parsec [Char] ParserState [Block]
221+genericListItemAtDepth :: Char -> Int -> Parser [Char] ParserState [Block]
222222genericListItemAtDepth c depth = try $ do
223223 count depth (char c) >> optional attributes >> whitespace
224224 p <- inlines
@@ -226,22 +226,22 @@ genericListItemAtDepth c depth = try $ do
226226 return ((Plain p):sublist)
227227
228228-- | A definition list is a set of consecutive definition items
229−definitionList :: Parsec [Char] ParserState Block
229+definitionList :: Parser [Char] ParserState Block
230230definitionList = try $ DefinitionList <$> many1 definitionListItem
231231
232232-- | A definition list item in textile begins with '- ', followed by
233233-- the term defined, then spaces and ":=". The definition follows, on
234234-- the same single line, or spaned on multiple line, after a line
235235-- break.
236−definitionListItem :: Parsec [Char] ParserState ([Inline], [[Block]])
236+definitionListItem :: Parser [Char] ParserState ([Inline], [[Block]])
237237definitionListItem = try $ do
238238 string "- "
239239 term <- many1Till inline (try (whitespace >> string ":="))
240240 def <- inlineDef <|> multilineDef
241241 return (term, def)
242− where inlineDef :: Parsec [Char] ParserState [[Block]]
242+ where inlineDef :: Parser [Char] ParserState [[Block]]
243243 inlineDef = liftM (\d -> [[Plain d]]) $ try (whitespace >> inlines)
244− multilineDef :: Parsec [Char] ParserState [[Block]]
244+ multilineDef :: Parser [Char] ParserState [[Block]]
245245 multilineDef = try $ do
246246 optional whitespace >> newline
247247 s <- many1Till anyChar (try (string "=:" >> newline))
@@ -251,57 +251,57 @@ definitionListItem = try $ do
251251
252252-- | This terminates a block such as a paragraph. Because of raw html
253253-- blocks support, we have to lookAhead for a rawHtmlBlock.
254−blockBreak :: Parsec [Char] ParserState ()
254+blockBreak :: Parser [Char] ParserState ()
255255blockBreak = try (newline >> blanklines >> return ()) <|>
256256 (lookAhead rawHtmlBlock >> return ())
257257
258258-- raw content
259259
260260-- | A raw Html Block, optionally followed by blanklines
261−rawHtmlBlock :: Parsec [Char] ParserState Block
261+rawHtmlBlock :: Parser [Char] ParserState Block
262262rawHtmlBlock = try $ do
263263 (_,b) <- htmlTag isBlockTag
264264 optional blanklines
265265 return $ RawBlock "html" b
266266
267267-- | Raw block of LaTeX content
268−rawLaTeXBlock' :: Parsec [Char] ParserState Block
268+rawLaTeXBlock' :: Parser [Char] ParserState Block
269269rawLaTeXBlock' = do
270270 failIfStrict
271271 RawBlock "latex" <$> (rawLaTeXBlock <* spaces)
272272
273273
274274-- | In textile, paragraphs are separated by blank lines.
275−para :: Parsec [Char] ParserState Block
275+para :: Parser [Char] ParserState Block
276276para = try $ Para . normalizeSpaces <$> manyTill inline blockBreak
277277
278278
279279-- Tables
280280
281281-- | A table cell spans until a pipe |
282−tableCell :: Parsec [Char] ParserState TableCell
282+tableCell :: Parser [Char] ParserState TableCell
283283tableCell = do
284284 c <- many1 (noneOf "|\n")
285285 content <- parseFromString (many1 inline) c
286286 return $ [ Plain $ normalizeSpaces content ]
287287
288288-- | A table row is made of many table cells
289−tableRow :: Parsec [Char] ParserState [TableCell]
289+tableRow :: Parser [Char] ParserState [TableCell]
290290tableRow = try $ ( char '|' *> (endBy1 tableCell (char '|')) <* newline)
291291
292292-- | Many table rows
293−tableRows :: Parsec [Char] ParserState [[TableCell]]
293+tableRows :: Parser [Char] ParserState [[TableCell]]
294294tableRows = many1 tableRow
295295
296296-- | Table headers are made of cells separated by a tag "|_."
297−tableHeaders :: Parsec [Char] ParserState [TableCell]
297+tableHeaders :: Parser [Char] ParserState [TableCell]
298298tableHeaders = let separator = (try $ string "|_.") in
299299 try $ ( separator *> (sepBy1 tableCell separator) <* char '|' <* newline )
300300
301301-- | A table with an optional header. Current implementation can
302302-- handle tables with and without header, but will parse cells
303303-- alignment attributes as content.
304−table :: Parsec [Char] ParserState Block
304+table :: Parser [Char] ParserState Block
305305table = try $ do
306306 headers <- option [] tableHeaders
307307 rows <- tableRows
@@ -317,8 +317,8 @@ table = try $ do
317317-- | Blocks like 'p' and 'table' do not need explicit block tag.
318318-- However, they can be used to set HTML/CSS attributes when needed.
319319maybeExplicitBlock :: String -- ^ block tag name
320− -> Parsec [Char] ParserState Block -- ^ implicit block
321− -> Parsec [Char] ParserState Block
320+ -> Parser [Char] ParserState Block -- ^ implicit block
321+ -> Parser [Char] ParserState Block
322322maybeExplicitBlock name blk = try $ do
323323 optional $ try $ string name >> optional attributes >> char '.' >>
324324 ((try whitespace) <|> endline)
@@ -332,15 +332,15 @@ maybeExplicitBlock name blk = try $ do
332332
333333
334334-- | Any inline element
335−inline :: Parsec [Char] ParserState Inline
335+inline :: Parser [Char] ParserState Inline
336336inline = choice inlineParsers <?> "inline"
337337
338338-- | List of consecutive inlines before a newline
339−inlines :: Parsec [Char] ParserState [Inline]
339+inlines :: Parser [Char] ParserState [Inline]
340340inlines = manyTill inline newline
341341
342342-- | Inline parsers tried in order
343−inlineParsers :: [Parsec [Char] ParserState Inline]
343+inlineParsers :: [Parser [Char] ParserState Inline]
344344inlineParsers = [ autoLink
345345 , str
346346 , whitespace
@@ -361,7 +361,7 @@ inlineParsers = [ autoLink
361361 ]
362362
363363-- | Inline markups
364−inlineMarkup :: Parsec [Char] ParserState Inline
364+inlineMarkup :: Parser [Char] ParserState Inline
365365inlineMarkup = choice [ simpleInline (string "??") (Cite [])
366366 , simpleInline (string "**") Strong
367367 , simpleInline (string "__") Emph
@@ -374,29 +374,29 @@ inlineMarkup = choice [ simpleInline (string "??") (Cite [])
374374 ]
375375
376376-- | Trademark, registered, copyright
377−mark :: Parsec [Char] st Inline
377+mark :: Parser [Char] st Inline
378378mark = try $ char '(' >> (try tm <|> try reg <|> copy)
379379
380−reg :: Parsec [Char] st Inline
380+reg :: Parser [Char] st Inline
381381reg = do
382382 oneOf "Rr"
383383 char ')'
384384 return $ Str "\174"
385385
386−tm :: Parsec [Char] st Inline
386+tm :: Parser [Char] st Inline
387387tm = do
388388 oneOf "Tt"
389389 oneOf "Mm"
390390 char ')'
391391 return $ Str "\8482"
392392
393−copy :: Parsec [Char] st Inline
393+copy :: Parser [Char] st Inline
394394copy = do
395395 oneOf "Cc"
396396 char ')'
397397 return $ Str "\169"
398398
399−note :: Parsec [Char] ParserState Inline
399+note :: Parser [Char] ParserState Inline
400400note = try $ do
401401 ref <- (char '[' *> many1 digit <* char ']')
402402 notes <- stateNotes <$> getState
@@ -420,7 +420,7 @@ wordBoundaries :: [Char]
420420wordBoundaries = markupChars ++ stringBreakers
421421
422422-- | Parse a hyphened sequence of words
423−hyphenedWords :: Parsec [Char] ParserState String
423+hyphenedWords :: Parser [Char] ParserState String
424424hyphenedWords = try $ do
425425 hd <- noneOf wordBoundaries
426426 tl <- many ( (noneOf wordBoundaries) <|>
@@ -430,7 +430,7 @@ hyphenedWords = try $ do
430430 (\r -> concat [wd, "-", r]) <$> (char '-' *> hyphenedWords)
431431
432432-- | Any string
433−str :: Parsec [Char] ParserState Inline
433+str :: Parser [Char] ParserState Inline
434434str = do
435435 baseStr <- hyphenedWords
436436 -- RedCloth compliance : if parsed word is uppercase and immediatly
@@ -443,34 +443,34 @@ str = do
443443 return $ Str fullStr
444444
445445-- | Textile allows HTML span infos, we discard them
446−htmlSpan :: Parsec [Char] ParserState Inline
446+htmlSpan :: Parser [Char] ParserState Inline
447447htmlSpan = try $ Str <$> ( char '%' *> attributes *> manyTill anyChar (char '%') )
448448
449449-- | Some number of space chars
450−whitespace :: Parsec [Char] ParserState Inline
450+whitespace :: Parser [Char] ParserState Inline
451451whitespace = many1 spaceChar >> return Space <?> "whitespace"
452452
453453-- | In Textile, an isolated endline character is a line break
454−endline :: Parsec [Char] ParserState Inline
454+endline :: Parser [Char] ParserState Inline
455455endline = try $ do
456456 newline >> notFollowedBy blankline
457457 return LineBreak
458458
459−rawHtmlInline :: Parsec [Char] ParserState Inline
459+rawHtmlInline :: Parser [Char] ParserState Inline
460460rawHtmlInline = RawInline "html" . snd <$> htmlTag isInlineTag
461461
462462-- | Raw LaTeX Inline
463−rawLaTeXInline' :: Parsec [Char] ParserState Inline
463+rawLaTeXInline' :: Parser [Char] ParserState Inline
464464rawLaTeXInline' = try $ do
465465 failIfStrict
466466 rawLaTeXInline
467467
468468-- | Textile standard link syntax is "label":target. But we
469469-- can also have ["label":target].
470−link :: Parsec [Char] ParserState Inline
470+link :: Parser [Char] ParserState Inline
471471link = linkB <|> linkNoB
472472
473−linkNoB :: Parsec [Char] ParserState Inline
473+linkNoB :: Parser [Char] ParserState Inline
474474linkNoB = try $ do
475475 name <- surrounded (char '"') inline
476476 char ':'
@@ -478,7 +478,7 @@ linkNoB = try $ do
478478 url <- manyTill nonspaceChar (lookAhead $ space <|> try (oneOf stopChars >> (space <|> newline)))
479479 return $ Link name (url, "")
480480
481−linkB :: Parsec [Char] ParserState Inline
481+linkB :: Parser [Char] ParserState Inline
482482linkB = try $ do
483483 char '['
484484 name <- surrounded (char '"') inline
@@ -487,13 +487,13 @@ linkB = try $ do
487487 return $ Link name (url, "")
488488
489489-- | Detect plain links to http or email.
490−autoLink :: Parsec [Char] ParserState Inline
490+autoLink :: Parser [Char] ParserState Inline
491491autoLink = do
492492 (orig, src) <- (try uri <|> try emailAddress)
493493 return $ Link [Str orig] (src, "")
494494
495495-- | image embedding
496−image :: Parsec [Char] ParserState Inline
496+image :: Parser [Char] ParserState Inline
497497image = try $ do
498498 char '!' >> notFollowedBy space
499499 src <- manyTill anyChar (lookAhead $ oneOf "!(")
@@ -501,49 +501,49 @@ image = try $ do
501501 char '!'
502502 return $ Image [Str alt] (src, alt)
503503
504−escapedInline :: Parsec [Char] ParserState Inline
504+escapedInline :: Parser [Char] ParserState Inline
505505escapedInline = escapedEqs <|> escapedTag
506506
507−escapedEqs :: Parsec [Char] ParserState Inline
507+escapedEqs :: Parser [Char] ParserState Inline
508508escapedEqs = Str <$> (try $ string "==" *> manyTill anyChar (try $ string "=="))
509509
510510-- | literal text escaped btw <notextile> tags
511−escapedTag :: Parsec [Char] ParserState Inline
511+escapedTag :: Parser [Char] ParserState Inline
512512escapedTag = Str <$>
513513 (try $ string "<notextile>" *> manyTill anyChar (try $ string "</notextile>"))
514514
515515-- | Any special symbol defined in wordBoundaries
516−symbol :: Parsec [Char] ParserState Inline
516+symbol :: Parser [Char] ParserState Inline
517517symbol = Str . singleton <$> oneOf wordBoundaries
518518
519519-- | Inline code
520−code :: Parsec [Char] ParserState Inline
520+code :: Parser [Char] ParserState Inline
521521code = code1 <|> code2
522522
523−code1 :: Parsec [Char] ParserState Inline
523+code1 :: Parser [Char] ParserState Inline
524524code1 = Code nullAttr <$> surrounded (char '@') anyChar
525525
526−code2 :: Parsec [Char] ParserState Inline
526+code2 :: Parser [Char] ParserState Inline
527527code2 = do
528528 htmlTag (tagOpen (=="tt") null)
529529 Code nullAttr <$> manyTill anyChar (try $ htmlTag $ tagClose (=="tt"))
530530
531531-- | Html / CSS attributes
532−attributes :: Parsec [Char] ParserState String
532+attributes :: Parser [Char] ParserState String
533533attributes = choice [ enclosed (char '(') (char ')') anyChar,
534534 enclosed (char '{') (char '}') anyChar,
535535 enclosed (char '[') (char ']') anyChar]
536536
537537-- | Parses material surrounded by a parser.
538−surrounded :: Parsec [Char] st t -- ^ surrounding parser
539− -> Parsec [Char] st a -- ^ content parser (to be used repeatedly)
540− -> Parsec [Char] st [a]
538+surrounded :: Parser [Char] st t -- ^ surrounding parser
539+ -> Parser [Char] st a -- ^ content parser (to be used repeatedly)
540+ -> Parser [Char] st [a]
541541surrounded border = enclosed border (try border)
542542
543543-- | Inlines are most of the time of the same form
544−simpleInline :: Parsec [Char] ParserState t -- ^ surrounding parser
544+simpleInline :: Parser [Char] ParserState t -- ^ surrounding parser
545545 -> ([Inline] -> Inline) -- ^ Inline constructor
546− -> Parsec [Char] ParserState Inline -- ^ content parser (to be used repeatedly)
546+ -> Parser [Char] ParserState Inline -- ^ content parser (to be used repeatedly)
547547simpleInline border construct = surrounded border (inlineWithAttribute) >>=
548548 return . construct . normalizeSpaces
549549 where inlineWithAttribute = (try $ optional attributes) >> inline
src/Text/Pandoc/Templates.hs+9−9
@@ -98,7 +98,7 @@ getDefaultTemplate user writer = do
9898
9999data TemplateState = TemplateState Int [(String,String)]
100100
101−adjustPosition :: String -> Parsec [Char] TemplateState String
101+adjustPosition :: String -> Parser [Char] TemplateState String
102102adjustPosition str = do
103103 let lastline = takeWhile (/= '\n') $ reverse str
104104 updateState $ \(TemplateState pos x) ->
@@ -132,21 +132,21 @@ renderTemplate vals templ =
132132reservedWords :: [String]
133133reservedWords = ["else","endif","for","endfor","sep"]
134134
135−parseTemplate :: Parsec [Char] TemplateState [String]
135+parseTemplate :: Parser [Char] TemplateState [String]
136136parseTemplate =
137137 many $ (plaintext <|> escapedDollar <|> conditional <|> for <|> variable)
138138 >>= adjustPosition
139139
140−plaintext :: Parsec [Char] TemplateState String
140+plaintext :: Parser [Char] TemplateState String
141141plaintext = many1 $ noneOf "$"
142142
143−escapedDollar :: Parsec [Char] TemplateState String
143+escapedDollar :: Parser [Char] TemplateState String
144144escapedDollar = try $ string "$$" >> return "$"
145145
146−skipEndline :: Parsec [Char] st ()
146+skipEndline :: Parser [Char] st ()
147147skipEndline = try $ skipMany (oneOf " \t") >> newline >> return ()
148148
149−conditional :: Parsec [Char] TemplateState String
149+conditional :: Parser [Char] TemplateState String
150150conditional = try $ do
151151 TemplateState pos vars <- getState
152152 string "$if("
@@ -170,7 +170,7 @@ conditional = try $ do
170170 then ifContents
171171 else elseContents
172172
173−for :: Parsec [Char] TemplateState String
173+for :: Parser [Char] TemplateState String
174174for = try $ do
175175 TemplateState pos vars <- getState
176176 string "$for("
@@ -193,7 +193,7 @@ for = try $ do
193193 setState $ TemplateState pos vars
194194 return $ concat $ intersperse sep contents
195195
196−ident :: Parsec [Char] TemplateState String
196+ident :: Parser [Char] TemplateState String
197197ident = do
198198 first <- letter
199199 rest <- many (alphaNum <|> oneOf "_-")
@@ -202,7 +202,7 @@ ident = do
202202 then mzero
203203 else return id'
204204
205−variable :: Parsec [Char] TemplateState String
205+variable :: Parser [Char] TemplateState String
206206variable = try $ do
207207 char '$'
208208 id' <- ident
src/Text/Pandoc/Writers/AsciiDoc.hs+1−1
@@ -92,7 +92,7 @@ escapeString = escapeStringUsing escs
9292 where escs = backslashEscapes "{"
9393
9494-- | Ordered list start parser for use in Para below.
95−olMarker :: Parsec [Char] ParserState Char
95+olMarker :: Parser [Char] ParserState Char
9696olMarker = do (start, style', delim) <- anyOrderedListMarker
9797 if delim == Period &&
9898 (style' == UpperAlpha || (style' == UpperRoman &&
src/Text/Pandoc/Writers/Markdown.hs+1−1
@@ -187,7 +187,7 @@ attrsToMarkdown attribs = braces $ hsep [attribId, attribClasses, attribKeys]
187187 <> "=\"" <> text v <> "\"") ks
188188
189189-- | Ordered list start parser for use in Para below.
190−olMarker :: Parsec [Char] ParserState Char
190+olMarker :: Parser [Char] ParserState Char
191191olMarker = do (start, style', delim) <- anyOrderedListMarker
192192 if delim == Period &&
193193 (style' == UpperAlpha || (style' == UpperRoman &&