git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: parse empty comments correctly
commitf6abf15832e4b41ed26b285b4a7c8f515ddb139f authorAlexander Krotov <ilabdsf@gmail.com> dateTue 19 Dec 2017, 04:16 (9 years ago) parentc0cc927
2 files changed+3−2
src/Text/Pandoc/Readers/Muse.hs+1−2 test/Tests/Readers/Muse.hs+2
src/Text/Pandoc/Readers/Muse.hs+1−2
@@ -220,8 +220,7 @@ blockElements = choice [ comment
220220comment :: PandocMonad m => MuseParser m (F Blocks)
221221comment = try $ do
222222 char ';'
223− space
224− many $ noneOf "\n"
223+ optionMaybe (spaceChar >> (many $ noneOf "\n"))
225224 eol
226225 return mempty
227226
test/Tests/Readers/Muse.hs+2
@@ -421,6 +421,8 @@ tests =
421421 , testGroup "Comments"
422422 [ "Comment tag" =: "<comment>\nThis is a comment\n</comment>" =?> (mempty::Blocks)
423423 , "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
424426 , "Not a comment (does not start with a semicolon)" =: " ; Not a comment" =?> para (text "; Not a comment")
425427 , "Not a comment (has no space after semicolon)" =: ";Not a comment" =?> para (text ";Not a comment")
426428 ]