git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #2629 from tarleb/org-noexport-fix

Fix function dropping subtrees tagged :noexport:

commit9320d359a218a59e28b9a0f0d63e1c2f81ff1214 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 7 Jan 2016, 11:34 (11 years ago) parentd2dfaccb3b00da
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"