@@ -1,4 +1,4 @@
1−{-# LANGUAGE
1+{-# LANGUAGE
2 FlexibleContexts
2 FlexibleContexts
3, GeneralizedNewtypeDeriving
3, GeneralizedNewtypeDeriving
4, TypeSynonymInstances
4, TypeSynonymInstances
@@ -100,7 +100,7 @@ module Text.Pandoc.Parsing ( anyLine,
101 applyMacros',
101 applyMacros',
103− ParserT,
103+ ParserT,
@@ -222,7 +222,7 @@ anyLine = do
222 _ -> mzero
222 _ -> mzero
224-- | Like @manyTill@, but reads at least one item.
224-- | Like @manyTill@, but reads at least one item.
225−many1Till :: Stream s m t
225+many1Till :: Stream s m t
226 => ParserT s st m a
226 => ParserT s st m a
227 -> ParserT s st m end
227 -> ParserT s st m end
228 -> ParserT s st m [a]
228 -> ParserT s st m [a]
@@ -501,7 +501,7 @@ mathInline =
501-- displacement (the difference between the source column at the end
501-- displacement (the difference between the source column at the end
502-- and the source column at the beginning). Vertical displacement
502-- and the source column at the beginning). Vertical displacement
503-- (source row) is ignored.
503-- (source row) is ignored.
504−withHorizDisplacement :: Stream s m Char
504+withHorizDisplacement :: Stream s m Char
505 => ParserT s st m a -- ^ Parser to apply
505 => ParserT s st m a -- ^ Parser to apply
506 -> ParserT s st m (a, Int) -- ^ (result, displacement)
506 -> ParserT s st m (a, Int) -- ^ (result, displacement)
507withHorizDisplacement parser = do
507withHorizDisplacement parser = do
@@ -528,7 +528,7 @@ withRaw parser = do
528 return (result, raw)
528 return (result, raw)
530-- | Parses backslash, then applies character parser.
530-- | Parses backslash, then applies character parser.
531−escaped :: Stream s m Char
531+escaped :: Stream s m Char
532 => ParserT s st m Char -- ^ Parser for character to escape
532 => ParserT s st m Char -- ^ Parser for character to escape
533 -> ParserT s st m Char
533 -> ParserT s st m Char
534escaped parser = try $ char '\\' >> parser
534escaped parser = try $ char '\\' >> parser
@@ -564,7 +564,7 @@ decimal = do
564-- returns (DefaultStyle, [next example number]). The next
564-- returns (DefaultStyle, [next example number]). The next
565-- example number is incremented in parser state, and the label
565-- example number is incremented in parser state, and the label
566-- (if present) is added to the label table.
566-- (if present) is added to the label table.
567−exampleNum :: Stream s m Char
567+exampleNum :: Stream s m Char
568 => ParserT s ParserState m (ListNumberStyle, Int)
568 => ParserT s ParserState m (ListNumberStyle, Int)
569exampleNum = do
569exampleNum = do
@@ -609,7 +609,7 @@ anyOrderedListMarker = choice $
609 lowerAlpha, lowerRoman, upperAlpha, upperRoman]]
609 lowerAlpha, lowerRoman, upperAlpha, upperRoman]]
611-- | Parses a list number (num) followed by a period, returns list attributes.
611-- | Parses a list number (num) followed by a period, returns list attributes.
612−inPeriod :: Stream s m Char
612+inPeriod :: Stream s m Char
613 => ParserT s st m (ListNumberStyle, Int)
613 => ParserT s st m (ListNumberStyle, Int)
614 -> ParserT s st m ListAttributes
614 -> ParserT s st m ListAttributes
615inPeriod num = try $ do
615inPeriod num = try $ do
@@ -621,7 +621,7 @@ inPeriod num = try $ do
621 return (start, style, delim)
621 return (start, style, delim)
623-- | Parses a list number (num) followed by a paren, returns list attributes.
623-- | Parses a list number (num) followed by a paren, returns list attributes.
624−inOneParen :: Stream s m Char
624+inOneParen :: Stream s m Char
625 => ParserT s st m (ListNumberStyle, Int)
625 => ParserT s st m (ListNumberStyle, Int)
626 -> ParserT s st m ListAttributes
626 -> ParserT s st m ListAttributes
627inOneParen num = try $ do
627inOneParen num = try $ do
@@ -630,7 +630,7 @@ inOneParen num = try $ do
630 return (start, style, OneParen)
630 return (start, style, OneParen)
632-- | Parses a list number (num) enclosed in parens, returns list attributes.
632-- | Parses a list number (num) enclosed in parens, returns list attributes.
633−inTwoParens :: Stream s m Char
633+inTwoParens :: Stream s m Char
634 => ParserT s st m (ListNumberStyle, Int)
634 => ParserT s st m (ListNumberStyle, Int)
635 -> ParserT s st m ListAttributes
635 -> ParserT s st m ListAttributes
636inTwoParens num = try $ do
636inTwoParens num = try $ do
@@ -641,7 +641,7 @@ inTwoParens num = try $ do
642-- | Parses an ordered list marker with a given style and delimiter,
642-- | Parses an ordered list marker with a given style and delimiter,
643-- returns number.
643-- returns number.
644−orderedListMarker :: Stream s m Char
644+orderedListMarker :: Stream s m Char
645 => ListNumberStyle
645 => ListNumberStyle
646 -> ListNumberDelim
646 -> ListNumberDelim
647 -> ParserT s ParserState m Int
647 -> ParserT s ParserState m Int
@@ -688,7 +688,7 @@ lineBlockLines = try $ do
689-- | Parse a table using 'headerParser', 'rowParser',
689-- | Parse a table using 'headerParser', 'rowParser',
690-- 'lineParser', and 'footerParser'.
690-- 'lineParser', and 'footerParser'.
691−tableWith :: Stream s m Char
691+tableWith :: Stream s m Char
692 => ParserT s ParserState m ([[Block]], [Alignment], [Int])
692 => ParserT s ParserState m ([[Block]], [Alignment], [Int])
693 -> ([Int] -> ParserT s ParserState m [[Block]])
693 -> ([Int] -> ParserT s ParserState m [[Block]])
694 -> ParserT s ParserState m sep
694 -> ParserT s ParserState m sep
@@ -735,7 +735,7 @@ widthsFromIndices numColumns' indices =
735-- (which may be grid), then the rows,
735-- (which may be grid), then the rows,
736-- which may be grid, separated by blank lines, and
736-- which may be grid, separated by blank lines, and
737-- ending with a footer (dashed line followed by blank line).
737-- ending with a footer (dashed line followed by blank line).
738−gridTableWith :: Stream [Char] m Char
738+gridTableWith :: Stream [Char] m Char
739 => ParserT [Char] ParserState m [Block] -- ^ Block list parser
739 => ParserT [Char] ParserState m [Block] -- ^ Block list parser
740 -> Bool -- ^ Headerless table
740 -> Bool -- ^ Headerless table
741 -> ParserT [Char] ParserState m Block
741 -> ParserT [Char] ParserState m Block
@@ -765,7 +765,7 @@ gridTableSep :: Stream s m Char => Char -> ParserT s ParserState m Char
765gridTableSep ch = try $ gridDashedLines ch >> return '\n'
765gridTableSep ch = try $ gridDashedLines ch >> return '\n'
767-- | Parse header for a grid table.
767-- | Parse header for a grid table.
768−gridTableHeader :: Stream [Char] m Char
768+gridTableHeader :: Stream [Char] m Char
769 => Bool -- ^ Headerless table
769 => Bool -- ^ Headerless table
770 -> ParserT [Char] ParserState m [Block]
770 -> ParserT [Char] ParserState m [Block]
771 -> ParserT [Char] ParserState m ([[Block]], [Alignment], [Int])
771 -> ParserT [Char] ParserState m ([[Block]], [Alignment], [Int])
@@ -798,7 +798,7 @@ gridTableRawLine indices = do
798 return (gridTableSplitLine indices line)
798 return (gridTableSplitLine indices line)
800-- | Parse row of grid table.
800-- | Parse row of grid table.
801−gridTableRow :: Stream [Char] m Char
801+gridTableRow :: Stream [Char] m Char
802 => ParserT [Char] ParserState m [Block]
802 => ParserT [Char] ParserState m [Block]
804 -> ParserT [Char] ParserState m [[Block]]
804 -> ParserT [Char] ParserState m [[Block]]
@@ -826,7 +826,7 @@ gridTableFooter = blanklines
828-- | Parse a string with a given parser and state.
828-- | Parse a string with a given parser and state.
829−readWith :: (Show s, Stream s Identity Char)
829+readWith :: (Show s, Stream s Identity Char)
830 => ParserT s st Identity a -- ^ parser
830 => ParserT s st Identity a -- ^ parser
831 -> st -- ^ initial state
831 -> st -- ^ initial state
832 -> s -- ^ input
832 -> s -- ^ input
@@ -844,7 +844,7 @@ readWith parser state input =
844 Right result -> result
844 Right result -> result
846-- | Parse a string with @parser@ (for testing).
846-- | Parse a string with @parser@ (for testing).
847−testStringWith :: (Show s, Show a, Stream s Identity Char)
847+testStringWith :: (Show s, Show a, Stream s Identity Char)
848 => ParserT s ParserState Identity a
848 => ParserT s ParserState Identity a
@@ -1038,7 +1038,7 @@ registerHeader (ident,classes,kvs) header' = do
1038failUnlessSmart :: (Stream s m a, HasReaderOptions st) => ParserT s st m ()
1038failUnlessSmart :: (Stream s m a, HasReaderOptions st) => ParserT s st m ()
1039failUnlessSmart = getOption readerSmart >>= guard
1039failUnlessSmart = getOption readerSmart >>= guard
1041−smartPunctuation :: Stream s m Char
1041+smartPunctuation :: Stream s m Char
1042 => ParserT s ParserState m Inlines
1042 => ParserT s ParserState m Inlines
1043 -> ParserT s ParserState m Inlines
1043 -> ParserT s ParserState m Inlines
1044smartPunctuation inlineParser = do
1044smartPunctuation inlineParser = do
@@ -1048,12 +1048,12 @@ smartPunctuation inlineParser = do
1048apostrophe :: Stream s m Char => ParserT s st m Inlines
1048apostrophe :: Stream s m Char => ParserT s st m Inlines
1049apostrophe = (char '\'' <|> char '\8217') >> return (B.str "\x2019")
1049apostrophe = (char '\'' <|> char '\8217') >> return (B.str "\x2019")
1051−quoted :: Stream s m Char
1051+quoted :: Stream s m Char
1052 => ParserT s ParserState m Inlines
1052 => ParserT s ParserState m Inlines
1053 -> ParserT s ParserState m Inlines
1053 -> ParserT s ParserState m Inlines
1054quoted inlineParser = doubleQuoted inlineParser <|> singleQuoted inlineParser
1054quoted inlineParser = doubleQuoted inlineParser <|> singleQuoted inlineParser
1056−withQuoteContext :: Stream s m t
1056+withQuoteContext :: Stream s m t
1057 => QuoteContext
1057 => QuoteContext
1058 -> ParserT s ParserState m a
1058 -> ParserT s ParserState m a
1059 -> ParserT s ParserState m a
1059 -> ParserT s ParserState m a
@@ -1066,7 +1066,7 @@ withQuoteContext context parser = do
1066 setState newState { stateQuoteContext = oldQuoteContext }
1066 setState newState { stateQuoteContext = oldQuoteContext }
1067 return result
1067 return result
1069−singleQuoted :: Stream s m Char
1069+singleQuoted :: Stream s m Char
1070 => ParserT s ParserState m Inlines
1070 => ParserT s ParserState m Inlines
1071 -> ParserT s ParserState m Inlines
1071 -> ParserT s ParserState m Inlines
1072singleQuoted inlineParser = try $ do
1072singleQuoted inlineParser = try $ do
@@ -1074,7 +1074,7 @@ singleQuoted inlineParser = try $ do
1074 withQuoteContext InSingleQuote $ many1Till inlineParser singleQuoteEnd >>=
1074 withQuoteContext InSingleQuote $ many1Till inlineParser singleQuoteEnd >>=
1075 return . B.singleQuoted . mconcat
1075 return . B.singleQuoted . mconcat
1077−doubleQuoted :: Stream s m Char
1077+doubleQuoted :: Stream s m Char
1078 => ParserT s ParserState m Inlines
1078 => ParserT s ParserState m Inlines
1079 -> ParserT s ParserState m Inlines
1079 -> ParserT s ParserState m Inlines
1080doubleQuoted inlineParser = try $ do
1080doubleQuoted inlineParser = try $ do
@@ -1082,8 +1082,8 @@ doubleQuoted inlineParser = try $ do
1082 withQuoteContext InDoubleQuote $ manyTill inlineParser doubleQuoteEnd >>=
1082 withQuoteContext InDoubleQuote $ manyTill inlineParser doubleQuoteEnd >>=
1083 return . B.doubleQuoted . mconcat
1083 return . B.doubleQuoted . mconcat
1085−failIfInQuoteContext :: Stream s m t
1085+failIfInQuoteContext :: Stream s m t
1086− => QuoteContext
1086+ => QuoteContext
1087 -> ParserT s ParserState m ()
1087 -> ParserT s ParserState m ()
1088failIfInQuoteContext context = do
1088failIfInQuoteContext context = do
1089 st <- getState
1089 st <- getState
@@ -1097,7 +1097,7 @@ charOrRef cs =
1097 guard (c `elem` cs)
1097 guard (c `elem` cs)
1098 return c)
1098 return c)
1100−singleQuoteStart :: Stream s m Char
1100+singleQuoteStart :: Stream s m Char
1101 => ParserT s ParserState m ()
1101 => ParserT s ParserState m ()
1102singleQuoteStart = do
1102singleQuoteStart = do
1103 failIfInQuoteContext InSingleQuote
1103 failIfInQuoteContext InSingleQuote
@@ -1105,24 +1105,24 @@ singleQuoteStart = do
1105 guard =<< notAfterString
1105 guard =<< notAfterString
1106 () <$ charOrRef "'\8216\145"
1106 () <$ charOrRef "'\8216\145"
1108−singleQuoteEnd :: Stream s m Char
1108+singleQuoteEnd :: Stream s m Char
1109 => ParserT s st m ()
1109 => ParserT s st m ()
1110singleQuoteEnd = try $ do
1110singleQuoteEnd = try $ do
1111 charOrRef "'\8217\146"
1111 charOrRef "'\8217\146"
1112 notFollowedBy alphaNum
1112 notFollowedBy alphaNum
1114−doubleQuoteStart :: Stream s m Char
1114+doubleQuoteStart :: Stream s m Char
1115 => ParserT s ParserState m ()
1115 => ParserT s ParserState m ()
1116doubleQuoteStart = do
1116doubleQuoteStart = do
1117 failIfInQuoteContext InDoubleQuote
1117 failIfInQuoteContext InDoubleQuote
1118 try $ do charOrRef "\"\8220\147"
1118 try $ do charOrRef "\"\8220\147"
1119 notFollowedBy . satisfy $ flip elem [' ', '\t', '\n']
1119 notFollowedBy . satisfy $ flip elem [' ', '\t', '\n']
1121−doubleQuoteEnd :: Stream s m Char
1121+doubleQuoteEnd :: Stream s m Char
1122 => ParserT s st m ()
1122 => ParserT s st m ()
1123doubleQuoteEnd = void (charOrRef "\"\8221\148")
1123doubleQuoteEnd = void (charOrRef "\"\8221\148")
1125−ellipses :: Stream s m Char
1125+ellipses :: Stream s m Char
1126 => ParserT s st m Inlines
1126 => ParserT s st m Inlines
1127ellipses = do
1127ellipses = do
1128 try (charOrRef "\8230\133") <|> try (string "..." >> return '…')
1128 try (charOrRef "\8230\133") <|> try (string "..." >> return '…')
@@ -1136,32 +1136,32 @@ dash = do
1136 else B.str <$> (hyphenDash <|> emDash <|> enDash)
1136 else B.str <$> (hyphenDash <|> emDash <|> enDash)
1138-- Two hyphens = en-dash, three = em-dash
1138-- Two hyphens = en-dash, three = em-dash
1139−hyphenDash :: Stream s m Char
1139+hyphenDash :: Stream s m Char
1140 => ParserT s st m String
1140 => ParserT s st m String
1141hyphenDash = do
1141hyphenDash = do
1142 try $ string "--"
1142 try $ string "--"
1143 option "\8211" (char '-' >> return "\8212")
1143 option "\8211" (char '-' >> return "\8212")
1145−emDash :: Stream s m Char
1145+emDash :: Stream s m Char
1146 => ParserT s st m String
1146 => ParserT s st m String
1147emDash = do
1147emDash = do
1148 try (charOrRef "\8212\151")
1148 try (charOrRef "\8212\151")
1149 return "\8212"
1149 return "\8212"
1151−enDash :: Stream s m Char
1151+enDash :: Stream s m Char
1152 => ParserT s st m String
1152 => ParserT s st m String
1153enDash = do
1153enDash = do
1154 try (charOrRef "\8212\151")
1154 try (charOrRef "\8212\151")
1155 return "\8211"
1155 return "\8211"
1157−enDashOld :: Stream s m Char
1157+enDashOld :: Stream s m Char
1158 => ParserT s st m Inlines
1158 => ParserT s st m Inlines
1159enDashOld = do
1159enDashOld = do
1160 try (charOrRef "\8211\150") <|>
1160 try (charOrRef "\8211\150") <|>
1161 try (char '-' >> lookAhead (satisfy isDigit) >> return '–')
1161 try (char '-' >> lookAhead (satisfy isDigit) >> return '–')
1162 return (B.str "\8211")
1162 return (B.str "\8211")
1164−emDashOld :: Stream s m Char
1164+emDashOld :: Stream s m Char
1165 => ParserT s st m Inlines
1165 => ParserT s st m Inlines
1166emDashOld = do
1166emDashOld = do
1167 try (charOrRef "\8212\151") <|> (try $ string "--" >> optional (char '-') >> return '-')
1167 try (charOrRef "\8212\151") <|> (try $ string "--" >> optional (char '-') >> return '-')
@@ -1169,7 +1169,7 @@ emDashOld = do
1170-- This is used to prevent exponential blowups for things like:
1170-- This is used to prevent exponential blowups for things like:
1171-- a**a*a**a*a**a*a**a*a**a*a**a*a**
1171-- a**a*a**a*a**a*a**a*a**a*a**a*a**
1172−nested :: Stream s m a
1172+nested :: Stream s m a
1173 => ParserT s ParserState m a
1173 => ParserT s ParserState m a
1174 -> ParserT s ParserState m a
1174 -> ParserT s ParserState m a
1175nested p = do
1175nested p = do
@@ -1198,7 +1198,7 @@ citeKey = try $ do
1200-- | Parse a \newcommand or \renewcommand macro definition.
1200-- | Parse a \newcommand or \renewcommand macro definition.
1201−macro :: (Stream [Char] m Char, HasMacros st, HasReaderOptions st)
1201+macro :: (Stream [Char] m Char, HasMacros st, HasReaderOptions st)
1202 => ParserT [Char] st m Blocks
1202 => ParserT [Char] st m Blocks
1203macro = do
1203macro = do
1204 apply <- getOption readerApplyMacros
1204 apply <- getOption readerApplyMacros
@@ -1214,8 +1214,8 @@ macro = do
1214 else return $ rawBlock "latex" def'
1214 else return $ rawBlock "latex" def'
1216-- | Apply current macros to string.
1216-- | Apply current macros to string.
1217−applyMacros' :: Stream [Char] m Char
1217+applyMacros' :: Stream [Char] m Char
1218− => String
1218+ => String
1219 -> ParserT [Char] ParserState m String
1219 -> ParserT [Char] ParserState m String
1220applyMacros' target = do
1220applyMacros' target = do
1221 apply <- getOption readerApplyMacros
1221 apply <- getOption readerApplyMacros