aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2016-01-07 19:56:44 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2016-01-07 19:56:44 +0100
commitb3b00da43d5727b050b8647dff3b9600c275a1a0 (patch)
tree0949711540970547afcbb068c5c51e988f3ed7f4
parenta5efd2af11849b6fa55b40d188cc9925bfa4ab9f (diff)
downloadpandoc-b3b00da43d5727b050b8647dff3b9600c275a1a0.tar.gz
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.
-rw-r--r--src/Text/Pandoc/Readers/Org.hs6
-rw-r--r--tests/Tests/Readers/Org.hs10
2 files changed, 14 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs
index 99a6927e2..c7906618c 100644
--- a/src/Text/Pandoc/Readers/Org.hs
+++ b/src/Text/Pandoc/Readers/Org.hs
@@ -87,8 +87,10 @@ parseOrg = do
-- | Drop COMMENT headers and the document tree below those headers.
dropCommentTrees :: [Block] -> [Block]
dropCommentTrees [] = []
-dropCommentTrees blks@(b:bs) =
- maybe blks (flip dropUntilHeaderAboveLevel bs) $ commentHeaderLevel b
+dropCommentTrees (b:bs) =
+ maybe (b:dropCommentTrees bs)
+ (dropCommentTrees . flip dropUntilHeaderAboveLevel bs)
+ (commentHeaderLevel b)
-- | Return the level of a header starting a comment or :noexport: tree and
-- Nothing otherwise.
diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs
index 2bde26f0f..bb3bffe22 100644
--- a/tests/Tests/Readers/Org.hs
+++ b/tests/Tests/Readers/Org.hs
@@ -569,6 +569,16 @@ tests =
] =?>
(mempty::Blocks)
+ , "Subtree with :noexport:" =:
+ unlines [ "* Exported"
+ , "** This isn't exported :noexport:"
+ , "*** This neither"
+ , "** But this is"
+ ] =?>
+ mconcat [ headerWith ("exported", [], []) 1 "Exported"
+ , headerWith ("but-this-is", [], []) 2 "But this is"
+ ]
+
, "Paragraph starting with an asterisk" =:
"*five" =?>
para "*five"