git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: parse empty comments correctly
f6abf15Alexander Krotov
src/Text/Pandoc/Readers/Muse.hs+1−2
@@ -220,8 +220,7 @@ blockElements = choice [ comment
220comment :: PandocMonad m => MuseParser m (F Blocks)
220comment :: PandocMonad m => MuseParser m (F Blocks)
221comment = try $ do
221comment = try $ do
222 char ';'
222 char ';'
223− space
224− many $ noneOf "\n"
223+ optionMaybe (spaceChar >> (many $ noneOf "\n"))
225 eol
224 eol
226 return mempty
225 return mempty
227
226
test/Tests/Readers/Muse.hs+2
@@ -421,6 +421,8 @@ tests =
421 , testGroup "Comments"
421 , testGroup "Comments"
422 [ "Comment tag" =: "<comment>\nThis is a comment\n</comment>" =?> (mempty::Blocks)
422 [ "Comment tag" =: "<comment>\nThis is a comment\n</comment>" =?> (mempty::Blocks)
423 , "Line comment" =: "; Comment" =?> (mempty::Blocks)
423 , "Line comment" =: "; Comment" =?> (mempty::Blocks)
424+ , "Empty comment" =: ";" =?> (mempty::Blocks)
425+ , "Text after empty comment" =: ";\nfoo" =?> para "foo" -- Make sure we don't consume newline while looking for whitespace
424 , "Not a comment (does not start with a semicolon)" =: " ; Not a comment" =?> para (text "; Not a comment")
426 , "Not a comment (does not start with a semicolon)" =: " ; Not a comment" =?> para (text "; Not a comment")
425 , "Not a comment (has no space after semicolon)" =: ";Not a comment" =?> para (text ";Not a comment")
427 , "Not a comment (has no space after semicolon)" =: ";Not a comment" =?> para (text ";Not a comment")
426 ]
428 ]