git.iko.soy/typeable/pandoc
on master help sign in
Org reader: fix parsing of empty comment lines

Comment lines in Org-mode can be completely empty; both of these line should produce no output: # a comment # The reader used to produce a wrong result for the latter, but ignores that line as well now. Fixes: #5856

commit909083090a63f65f4e720d210272c4bd6866cbee authorAlbert Krewinkel <albert@zeitkraut.de> dateSun 27 Oct 2019, 22:39 (7 years ago) parentbef124c
2 files changed+14−2
src/Text/Pandoc/Readers/Org/BlockStarts.hs+3−1 test/Tests/Readers/Org/Block.hs+11−1
src/Text/Pandoc/Readers/Org/BlockStarts.hs+3−1
@@ -92,7 +92,9 @@ metaLineStart :: Monad m => OrgParser m ()
9292metaLineStart = try $ skipSpaces <* string "#+"
9393
9494commentLineStart :: Monad m => OrgParser m ()
95−commentLineStart = try $ skipSpaces <* string "# "
95+commentLineStart = try $
96+ -- the first char after '#' must be a plain space character or a newline
97+ skipSpaces <* string "#" <* lookAhead (oneOf " \n")
9698
9799exampleLineStart :: Monad m => OrgParser m ()
98100exampleLineStart = () <$ try (skipSpaces *> string ": ")
test/Tests/Readers/Org/Block.hs+11−1
@@ -73,13 +73,23 @@ tests =
7373 "----- em and en dash" =?>
7474 para "\8212\8211 em and en dash"
7575
76− , "Comment Block" =:
76+ , testGroup "Comments"
77+ [ "Comment Block" =:
7778 T.unlines [ "#+BEGIN_COMMENT"
7879 , "stuff"
7980 , "bla"
8081 , "#+END_COMMENT"] =?>
8182 (mempty::Blocks)
8283
84+ , "Comment line" =:
85+ T.unlines [ "# this is a comment" ] =?>
86+ (mempty :: Blocks)
87+
88+ , "Empty comment line" =:
89+ T.unlines [ " #" ] =?>
90+ (mempty :: Blocks)
91+ ]
92+
8393 , testGroup "Blocks and fragments"
8494 [ "HTML block" =:
8595 T.unlines [ "#+BEGIN_HTML"