git.iko.soy/typeable/pandoc
on master help sign in
Changes to fit new charsInBalanced.
commitd34f85613a7bf32283abaff73965cf8a0436ea4f authorJohn MacFarlane <fiddlosopher@gmail.com> dateMon 5 Dec 2011, 20:55 (15 years ago) parentfa255f6
2 files changed+13−8
src/Text/Pandoc/Readers/LaTeX.hs+2−2 src/Text/Pandoc/Readers/Markdown.hs+11−6
src/Text/Pandoc/Readers/LaTeX.hs+2−2
@@ -59,7 +59,7 @@ specialChars = "\\`$%^&_~#{}[]\n \t|<>'\"-"
5959-- | Returns text between brackets and its matching pair.
6060bracketedText :: Char -> Char -> GenParser Char st [Char]
6161bracketedText openB closeB = do
62− result <- charsInBalanced' openB closeB
62+ result <- charsInBalanced openB closeB anyChar
6363 return $ [openB] ++ result ++ [closeB]
6464
6565-- | Returns an option or argument of a LaTeX command.
@@ -888,7 +888,7 @@ ensureMath = try $ do
888888url :: GenParser Char ParserState Inline
889889url = try $ do
890890 string "\\url"
891− url' <- charsInBalanced '{' '}'
891+ url' <- charsInBalanced '{' '}' anyChar
892892 return $ Link [Code ("",["url"],[]) url'] (escapeURI url', "")
893893
894894link :: GenParser Char ParserState Inline
src/Text/Pandoc/Readers/Markdown.hs+11−6
@@ -108,6 +108,11 @@ atMostSpaces :: Int -> GenParser Char ParserState ()
108108atMostSpaces 0 = notFollowedBy (char ' ')
109109atMostSpaces n = (char ' ' >> atMostSpaces (n-1)) <|> return ()
110110
111+litChar :: GenParser Char ParserState Char
112+litChar = escapedChar'
113+ <|> noneOf "\n"
114+ <|> (newline >> notFollowedBy blankline >> return ' ')
115+
111116-- | Fail unless we're at beginning of a line.
112117failUnlessBeginningOfLine :: GenParser tok st ()
113118failUnlessBeginningOfLine = do
@@ -233,12 +238,12 @@ referenceKey = try $ do
233238 -- return blanks so line count isn't affected
234239 return $ replicate (sourceLine endPos - sourceLine startPos) '\n'
235240
236−referenceTitle :: GenParser Char st String
237−referenceTitle = try $ do
241+referenceTitle :: GenParser Char ParserState String
242+referenceTitle = try $ do
238243 skipSpaces >> optional newline >> skipSpaces
239− tit <- (charsInBalanced '(' ')' >>= return . unwords . words)
244+ tit <- (charsInBalanced '(' ')' litChar >>= return . unwords . words)
240245 <|> do delim <- char '\'' <|> char '"'
241− manyTill anyChar (try (char delim >> skipSpaces >>
246+ manyTill litChar (try (char delim >> skipSpaces >>
242247 notFollowedBy (noneOf ")\n")))
243248 return $ decodeCharacterReferences tit
244249
@@ -1136,9 +1141,9 @@ reference = do notFollowedBy' (string "[^") -- footnote reference
11361141 return $ normalizeSpaces result
11371142
11381143-- source for a link, with optional title
1139−source :: GenParser Char st (String, [Char])
1144+source :: GenParser Char ParserState (String, [Char])
11401145source =
1141− (try $ charsInBalanced '(' ')' >>= parseFromString source') <|>
1146+ (try $ charsInBalanced '(' ')' litChar >>= parseFromString source') <|>
11421147 -- the following is needed for cases like: [ref](/url(a).
11431148 (enclosed (char '(') (char ')') anyChar >>=
11441149 parseFromString source')