summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-02-01 22:35:27 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2011-02-01 22:35:27 -0800
commitd4b71a6423721c79852b96c4ac398dff1c7ac428 (patch)
tree06a46f4441627d7ea92dff876560ea79a5289473 /src
parent5dce199ff7e80e9eb1709f1ea68093b3d10d0e15 (diff)
Markdown reader: Simplified and corrected footnote block parser.
Diffstat (limited to 'src')
-rw-r--r--src/Tests/Readers/Markdown.hs2
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs17
2 files changed, 11 insertions, 8 deletions
diff --git a/src/Tests/Readers/Markdown.hs b/src/Tests/Readers/Markdown.hs
index 9fc0496bb..eae03fcae 100644
--- a/src/Tests/Readers/Markdown.hs
+++ b/src/Tests/Readers/Markdown.hs
@@ -31,7 +31,7 @@ tests = [ testGroup "inline code"
"[^1]\n\n[^1]: my note\n\n \nnot in note\n"
=?> para (note (para "my note")) +++ para "not in note"
, "indent followed by newline and indented text" =:
- "[^1]\n\n[^1]: my note\n\n \n in note\n"
+ "[^1]\n\n[^1]: my note\n \n in note\n"
=?> para (note (para "my note" +++ para "in note"))
]
]
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 2bfb742bd..01cc5e2e8 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -245,15 +245,17 @@ noteMarker :: GenParser Char ParserState [Char]
noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']')
rawLine :: GenParser Char ParserState [Char]
-rawLine = do
+rawLine = try $ do
notFollowedBy blankline
notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker
- contents <- many1 nonEndline
- end <- option "" (newline >> optional indentSpaces >> return "\n")
- return $ contents ++ end
+ optional indentSpaces
+ anyLine
rawLines :: GenParser Char ParserState [Char]
-rawLines = many1 rawLine >>= return . concat
+rawLines = do
+ first <- anyLine
+ rest <- many rawLine
+ return $ unlines (first:rest)
noteBlock :: GenParser Char ParserState [Char]
noteBlock = try $ do
@@ -263,8 +265,9 @@ noteBlock = try $ do
char ':'
optional blankline
optional indentSpaces
- raw <- sepBy rawLines (try (blankline >> indentSpaces >>
- notFollowedBy blankline))
+ raw <- sepBy rawLines
+ (try (blankline >> indentSpaces >>
+ notFollowedBy blankline))
optional blanklines
endPos <- getPosition
let newnote = (ref, (intercalate "\n" raw) ++ "\n\n")