Muse reader: parse empty comments correctly

This commit is contained in:
Alexander Krotov 2017-12-19 04:16:57 +03:00
parent c0cc9270cb
commit f6abf15832
2 changed files with 3 additions and 2 deletions

View file

@ -220,8 +220,7 @@ blockElements = choice [ comment
comment :: PandocMonad m => MuseParser m (F Blocks) comment :: PandocMonad m => MuseParser m (F Blocks)
comment = try $ do comment = try $ do
char ';' char ';'
space optionMaybe (spaceChar >> (many $ noneOf "\n"))
many $ noneOf "\n"
eol eol
return mempty return mempty

View file

@ -421,6 +421,8 @@ tests =
, testGroup "Comments" , testGroup "Comments"
[ "Comment tag" =: "<comment>\nThis is a comment\n</comment>" =?> (mempty::Blocks) [ "Comment tag" =: "<comment>\nThis is a comment\n</comment>" =?> (mempty::Blocks)
, "Line comment" =: "; Comment" =?> (mempty::Blocks) , "Line comment" =: "; Comment" =?> (mempty::Blocks)
, "Empty comment" =: ";" =?> (mempty::Blocks)
, "Text after empty comment" =: ";\nfoo" =?> para "foo" -- Make sure we don't consume newline while looking for whitespace
, "Not a comment (does not start with a semicolon)" =: " ; Not a comment" =?> para (text "; Not a comment") , "Not a comment (does not start with a semicolon)" =: " ; Not a comment" =?> para (text "; Not a comment")
, "Not a comment (has no space after semicolon)" =: ";Not a comment" =?> para (text ";Not a comment") , "Not a comment (has no space after semicolon)" =: ";Not a comment" =?> para (text ";Not a comment")
] ]