@@ -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