git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Simplified and corrected footnote block parser.
d4b71a6John MacFarlane
src/Tests/Readers/Markdown.hs+1−1
@@ -31,7 +31,7 @@ tests = [ testGroup "inline code"
31 "[^1]\n\n[^1]: my note\n\n \nnot in note\n"
31 "[^1]\n\n[^1]: my note\n\n \nnot in note\n"
32 =?> para (note (para "my note")) +++ para "not in note"
32 =?> para (note (para "my note")) +++ para "not in note"
33 , "indent followed by newline and indented text" =:
33 , "indent followed by newline and indented text" =:
34− "[^1]\n\n[^1]: my note\n\n \n in note\n"
34+ "[^1]\n\n[^1]: my note\n \n in note\n"
35 =?> para (note (para "my note" +++ para "in note"))
35 =?> para (note (para "my note" +++ para "in note"))
36 ]
36 ]
37 ]
37 ]
src/Text/Pandoc/Readers/Markdown.hs+10−7
@@ -245,15 +245,17 @@ noteMarker :: GenParser Char ParserState [Char]
245noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']')
245noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']')
246
246
247rawLine :: GenParser Char ParserState [Char]
247rawLine :: GenParser Char ParserState [Char]
248−rawLine = do
248+rawLine = try $ do
249 notFollowedBy blankline
249 notFollowedBy blankline
250 notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker
250 notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker
251− contents <- many1 nonEndline
252− end <- option "" (newline >> optional indentSpaces >> return "\n")
251+ optional indentSpaces
253− return $ contents ++ end
252+ anyLine
254
253
255rawLines :: GenParser Char ParserState [Char]
254rawLines :: GenParser Char ParserState [Char]
256−rawLines = many1 rawLine >>= return . concat
255+rawLines = do
256+ first <- anyLine
257+ rest <- many rawLine
258+ return $ unlines (first:rest)
257
259
258noteBlock :: GenParser Char ParserState [Char]
260noteBlock :: GenParser Char ParserState [Char]
259noteBlock = try $ do
261noteBlock = try $ do
@@ -263,8 +265,9 @@ noteBlock = try $ do
263 char ':'
265 char ':'
264 optional blankline
266 optional blankline
265 optional indentSpaces
267 optional indentSpaces
268+ raw <- sepBy rawLines
266− raw <- sepBy rawLines (try (blankline >> indentSpaces >>
269+ (try (blankline >> indentSpaces >>
267− notFollowedBy blankline))
270+ notFollowedBy blankline))
268 optional blanklines
271 optional blanklines
269 endPos <- getPosition
272 endPos <- getPosition
270 let newnote = (ref, (intercalate "\n" raw) ++ "\n\n")
273 let newnote = (ref, (intercalate "\n" raw) ++ "\n\n")