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
This commit is contained in:
parent
bef124c98c
commit
909083090a
2 changed files with 14 additions and 2 deletions
|
@ -92,7 +92,9 @@ metaLineStart :: Monad m => OrgParser m ()
|
|||
metaLineStart = try $ skipSpaces <* string "#+"
|
||||
|
||||
commentLineStart :: Monad m => OrgParser m ()
|
||||
commentLineStart = try $ skipSpaces <* string "# "
|
||||
commentLineStart = try $
|
||||
-- the first char after '#' must be a plain space character or a newline
|
||||
skipSpaces <* string "#" <* lookAhead (oneOf " \n")
|
||||
|
||||
exampleLineStart :: Monad m => OrgParser m ()
|
||||
exampleLineStart = () <$ try (skipSpaces *> string ": ")
|
||||
|
|
|
@ -73,13 +73,23 @@ tests =
|
|||
"----- em and en dash" =?>
|
||||
para "\8212\8211 em and en dash"
|
||||
|
||||
, "Comment Block" =:
|
||||
, testGroup "Comments"
|
||||
[ "Comment Block" =:
|
||||
T.unlines [ "#+BEGIN_COMMENT"
|
||||
, "stuff"
|
||||
, "bla"
|
||||
, "#+END_COMMENT"] =?>
|
||||
(mempty::Blocks)
|
||||
|
||||
, "Comment line" =:
|
||||
T.unlines [ "# this is a comment" ] =?>
|
||||
(mempty :: Blocks)
|
||||
|
||||
, "Empty comment line" =:
|
||||
T.unlines [ " #" ] =?>
|
||||
(mempty :: Blocks)
|
||||
]
|
||||
|
||||
, testGroup "Blocks and fragments"
|
||||
[ "HTML block" =:
|
||||
T.unlines [ "#+BEGIN_HTML"
|
||||
|
|
Loading…
Add table
Reference in a new issue