@@ -29,6 +29,7 @@ Parsers for org-mode headlines and document subtrees
2929module Text.Pandoc.Readers.Org.DocumentTree
3030 ( documentTree
3131 , headlineToBlocks
32+ , filterHeadlineTree
3233 ) where
3334
3435import Prelude
@@ -161,17 +162,18 @@ headlineToBlocks hdln = do
161162 let tags = headlineTags hdln
162163 let text = headlineText hdln
163164 let level = headlineLevel hdln
164− shouldNotExport <- hasDoNotExportTag tags
165165 case () of
166− _ | shouldNotExport -> return mempty
167166 _ | any isArchiveTag tags -> archivedHeadlineToBlocks hdln
168167 _ | isCommentTitle text -> return mempty
169168 _ | maxLevel <= level -> headlineToHeaderWithList hdln
170169 _ | otherwise -> headlineToHeaderWithContents hdln
171170
172−hasDoNotExportTag :: Monad m => [Tag] -> OrgParser m Bool
173−hasDoNotExportTag tags = containsExcludedTag . orgStateExcludedTags <$> getState
174− where containsExcludedTag s = any (`Set.member` s) tags
171+filterHeadlineTree :: Headline -> OrgParserState -> Headline
172+filterHeadlineTree hdln st =
173+ hdln { headlineChildren =
174+ [filterHeadlineTree childHdln st |
175+ childHdln <- headlineChildren hdln,
176+ not $ any (`Set.member` orgStateExcludedTags st) (headlineTags childHdln)] }
175177
176178isArchiveTag :: Tag -> Bool
177179isArchiveTag = (== toTag "ARCHIVE")