git.iko.soy/typeable/pandoc
on master help sign in
Changes to fit new charsInBalanced.
d34f856John MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+2−2
@@ -59,7 +59,7 @@ specialChars = "\\`$%^&_~#{}[]\n \t|<>'\"-"
59-- | Returns text between brackets and its matching pair.
59-- | Returns text between brackets and its matching pair.
60bracketedText :: Char -> Char -> GenParser Char st [Char]
60bracketedText :: Char -> Char -> GenParser Char st [Char]
61bracketedText openB closeB = do
61bracketedText openB closeB = do
62− result <- charsInBalanced' openB closeB
62+ result <- charsInBalanced openB closeB anyChar
63 return $ [openB] ++ result ++ [closeB]
63 return $ [openB] ++ result ++ [closeB]
64
64
65-- | Returns an option or argument of a LaTeX command.
65-- | Returns an option or argument of a LaTeX command.
@@ -888,7 +888,7 @@ ensureMath = try $ do
888url :: GenParser Char ParserState Inline
888url :: GenParser Char ParserState Inline
889url = try $ do
889url = try $ do
890 string "\\url"
890 string "\\url"
891− url' <- charsInBalanced '{' '}'
891+ url' <- charsInBalanced '{' '}' anyChar
892 return $ Link [Code ("",["url"],[]) url'] (escapeURI url', "")
892 return $ Link [Code ("",["url"],[]) url'] (escapeURI url', "")
893
893
894link :: GenParser Char ParserState Inline
894link :: GenParser Char ParserState Inline
src/Text/Pandoc/Readers/Markdown.hs+11−6
@@ -108,6 +108,11 @@ atMostSpaces :: Int -> GenParser Char ParserState ()
108atMostSpaces 0 = notFollowedBy (char ' ')
108atMostSpaces 0 = notFollowedBy (char ' ')
109atMostSpaces n = (char ' ' >> atMostSpaces (n-1)) <|> return ()
109atMostSpaces n = (char ' ' >> atMostSpaces (n-1)) <|> return ()
110
110
111+litChar :: GenParser Char ParserState Char
112+litChar = escapedChar'
113+ <|> noneOf "\n"
114+ <|> (newline >> notFollowedBy blankline >> return ' ')
115+
111-- | Fail unless we're at beginning of a line.
116-- | Fail unless we're at beginning of a line.
112failUnlessBeginningOfLine :: GenParser tok st ()
117failUnlessBeginningOfLine :: GenParser tok st ()
113failUnlessBeginningOfLine = do
118failUnlessBeginningOfLine = do
@@ -233,12 +238,12 @@ referenceKey = try $ do
233 -- return blanks so line count isn't affected
238 -- return blanks so line count isn't affected
234 return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
239 return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
235
240
236−referenceTitle :: GenParser Char st String
241+referenceTitle :: GenParser Char ParserState String
237−referenceTitle = try $ do
242+referenceTitle = try $ do
238 skipSpaces >> optional newline >> skipSpaces
243 skipSpaces >> optional newline >> skipSpaces
239− tit <- (charsInBalanced '(' ')' >>= return . unwords . words)
244+ tit <- (charsInBalanced '(' ')' litChar >>= return . unwords . words)
240 <|> do delim <- char '\'' <|> char '"'
245 <|> do delim <- char '\'' <|> char '"'
241− manyTill anyChar (try (char delim >> skipSpaces >>
246+ manyTill litChar (try (char delim >> skipSpaces >>
242 notFollowedBy (noneOf ")\n")))
247 notFollowedBy (noneOf ")\n")))
243 return $ decodeCharacterReferences tit
248 return $ decodeCharacterReferences tit
244
249
@@ -1136,9 +1141,9 @@ reference = do notFollowedBy' (string "[^") -- footnote reference
1136 return $ normalizeSpaces result
1141 return $ normalizeSpaces result
1137
1142
1138-- source for a link, with optional title
1143-- source for a link, with optional title
1139−source :: GenParser Char st (String, [Char])
1144+source :: GenParser Char ParserState (String, [Char])
1140source =
1145source =
1141− (try $ charsInBalanced '(' ')' >>= parseFromString source') <|>
1146+ (try $ charsInBalanced '(' ')' litChar >>= parseFromString source') <|>
1142 -- the following is needed for cases like: [ref](/url(a).
1147 -- the following is needed for cases like: [ref](/url(a).
1143 (enclosed (char '(') (char ')') anyChar >>=
1148 (enclosed (char '(') (char ')') anyChar >>=
1144 parseFromString source')
1149 parseFromString source')