git.iko.soy/typeable/pandoc
on master help sign in
Org reader: fix parsing of empty comment lines
9090830Albert Krewinkel
src/Text/Pandoc/Readers/Org/BlockStarts.hs+3−1
@@ -92,7 +92,9 @@ metaLineStart :: Monad m => OrgParser m ()
92metaLineStart = try $ skipSpaces <* string "#+"
92metaLineStart = try $ skipSpaces <* string "#+"
93
93
94commentLineStart :: Monad m => OrgParser m ()
94commentLineStart :: 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")
96
98
97exampleLineStart :: Monad m => OrgParser m ()
99exampleLineStart :: Monad m => OrgParser m ()
98exampleLineStart = () <$ try (skipSpaces *> string ": ")
100exampleLineStart = () <$ try (skipSpaces *> string ": ")
test/Tests/Readers/Org/Block.hs+11−1
@@ -73,13 +73,23 @@ tests =
73 "----- em and en dash" =?>
73 "----- em and en dash" =?>
74 para "\8212\8211 em and en dash"
74 para "\8212\8211 em and en dash"
75
75
76+ , testGroup "Comments"
76− , "Comment Block" =:
77+ [ "Comment Block" =:
77 T.unlines [ "#+BEGIN_COMMENT"
78 T.unlines [ "#+BEGIN_COMMENT"
78 , "stuff"
79 , "stuff"
79 , "bla"
80 , "bla"
80 , "#+END_COMMENT"] =?>
81 , "#+END_COMMENT"] =?>
81 (mempty::Blocks)
82 (mempty::Blocks)
82
83
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+
83 , testGroup "Blocks and fragments"
93 , testGroup "Blocks and fragments"
84 [ "HTML block" =:
94 [ "HTML block" =:
85 T.unlines [ "#+BEGIN_HTML"
95 T.unlines [ "#+BEGIN_HTML"