@@ -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 ()
111+litChar :: GenParser Char ParserState Char
112+litChar = escapedChar'
114+ <|> (newline >> notFollowedBy blankline >> return ' ')
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'
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
@@ -1136,9 +1141,9 @@ reference = do notFollowedBy' (string "[^") -- footnote reference
1136 return $ normalizeSpaces result
1141 return $ normalizeSpaces result
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])
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')