git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Simplified and corrected footnote block parser.
commitd4b71a6423721c79852b96c4ac398dff1c7ac428 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 1 Feb 2011, 22:35 (16 years ago) parent5dce199
2 files changed+11−8
src/Tests/Readers/Markdown.hs+1−1 src/Text/Pandoc/Readers/Markdown.hs+10−7
src/Tests/Readers/Markdown.hs+1−1
@@ -31,7 +31,7 @@ tests = [ testGroup "inline code"
3131 "[^1]\n\n[^1]: my note\n\n \nnot in note\n"
3232 =?> para (note (para "my note")) +++ para "not in note"
3333 , "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"
3535 =?> para (note (para "my note" +++ para "in note"))
3636 ]
3737 ]
src/Text/Pandoc/Readers/Markdown.hs+10−7
@@ -245,15 +245,17 @@ noteMarker :: GenParser Char ParserState [Char]
245245noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']')
246246
247247rawLine :: GenParser Char ParserState [Char]
248−rawLine = do
248+rawLine = try $ do
249249 notFollowedBy blankline
250250 notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker
251− contents <- many1 nonEndline
252− end <- option "" (newline >> optional indentSpaces >> return "\n")
253− return $ contents ++ end
251+ optional indentSpaces
252+ anyLine
254253
255254rawLines :: 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)
257259
258260noteBlock :: GenParser Char ParserState [Char]
259261noteBlock = try $ do
@@ -263,8 +265,9 @@ noteBlock = try $ do
263265 char ':'
264266 optional blankline
265267 optional indentSpaces
266− raw <- sepBy rawLines (try (blankline >> indentSpaces >>
267− notFollowedBy blankline))
268+ raw <- sepBy rawLines
269+ (try (blankline >> indentSpaces >>
270+ notFollowedBy blankline))
268271 optional blanklines
269272 endPos <- getPosition
270273 let newnote = (ref, (intercalate "\n" raw) ++ "\n\n")