git.iko.soy/typeable/pandoc
on master help sign in
Fix function dropping subtrees tagged :noexport:

Continue scanning for comment subtrees beyond only the first block. Note to self: when writing an recursive function, don't forget to, you know, actually recurse. Shout to @mrvdb for noticing this. This fixes #2628.

commitb3b00da43d5727b050b8647dff3b9600c275a1a0 authorAlbert Krewinkel <albert@zeitkraut.de> dateThu 7 Jan 2016, 19:56 (11 years ago) parenta5efd2a
2 files changed+14−2
src/Text/Pandoc/Readers/Org.hs+4−2 tests/Tests/Readers/Org.hs+10
src/Text/Pandoc/Readers/Org.hs+4−2
@@ -87,8 +87,10 @@ parseOrg = do
8787-- | Drop COMMENT headers and the document tree below those headers.
8888dropCommentTrees :: [Block] -> [Block]
8989dropCommentTrees [] = []
90−dropCommentTrees blks@(b:bs) =
91− maybe blks (flip dropUntilHeaderAboveLevel bs) $ commentHeaderLevel b
90+dropCommentTrees (b:bs) =
91+ maybe (b:dropCommentTrees bs)
92+ (dropCommentTrees . flip dropUntilHeaderAboveLevel bs)
93+ (commentHeaderLevel b)
9294
9395-- | Return the level of a header starting a comment or :noexport: tree and
9496-- Nothing otherwise.
tests/Tests/Readers/Org.hs+10
@@ -569,6 +569,16 @@ tests =
569569 ] =?>
570570 (mempty::Blocks)
571571
572+ , "Subtree with :noexport:" =:
573+ unlines [ "* Exported"
574+ , "** This isn't exported :noexport:"
575+ , "*** This neither"
576+ , "** But this is"
577+ ] =?>
578+ mconcat [ headerWith ("exported", [], []) 1 "Exported"
579+ , headerWith ("but-this-is", [], []) 2 "But this is"
580+ ]
581+
572582 , "Paragraph starting with an asterisk" =:
573583 "*five" =?>
574584 para "*five"