Markdown reader: Simplified and corrected footnote block parser.
This commit is contained in:
parent
5dce199ff7
commit
d4b71a6423
2 changed files with 11 additions and 8 deletions
|
@ -31,7 +31,7 @@ tests = [ testGroup "inline code"
|
||||||
"[^1]\n\n[^1]: my note\n\n \nnot in note\n"
|
"[^1]\n\n[^1]: my note\n\n \nnot in note\n"
|
||||||
=?> para (note (para "my note")) +++ para "not in note"
|
=?> para (note (para "my note")) +++ para "not in note"
|
||||||
, "indent followed by newline and indented text" =:
|
, "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"))
|
=?> para (note (para "my note" +++ para "in note"))
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
|
@ -245,15 +245,17 @@ noteMarker :: GenParser Char ParserState [Char]
|
||||||
noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']')
|
noteMarker = string "[^" >> many1Till (satisfy $ not . isBlank) (char ']')
|
||||||
|
|
||||||
rawLine :: GenParser Char ParserState [Char]
|
rawLine :: GenParser Char ParserState [Char]
|
||||||
rawLine = do
|
rawLine = try $ do
|
||||||
notFollowedBy blankline
|
notFollowedBy blankline
|
||||||
notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker
|
notFollowedBy' $ try $ skipNonindentSpaces >> noteMarker
|
||||||
contents <- many1 nonEndline
|
optional indentSpaces
|
||||||
end <- option "" (newline >> optional indentSpaces >> return "\n")
|
anyLine
|
||||||
return $ contents ++ end
|
|
||||||
|
|
||||||
rawLines :: GenParser Char ParserState [Char]
|
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 :: GenParser Char ParserState [Char]
|
||||||
noteBlock = try $ do
|
noteBlock = try $ do
|
||||||
|
@ -263,7 +265,8 @@ noteBlock = try $ do
|
||||||
char ':'
|
char ':'
|
||||||
optional blankline
|
optional blankline
|
||||||
optional indentSpaces
|
optional indentSpaces
|
||||||
raw <- sepBy rawLines (try (blankline >> indentSpaces >>
|
raw <- sepBy rawLines
|
||||||
|
(try (blankline >> indentSpaces >>
|
||||||
notFollowedBy blankline))
|
notFollowedBy blankline))
|
||||||
optional blanklines
|
optional blanklines
|
||||||
endPos <- getPosition
|
endPos <- getPosition
|
||||||
|
|
Loading…
Reference in a new issue