diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2015-05-23 14:20:17 +0200 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2015-05-23 14:23:16 +0200 |
commit | 385dcf5b99331d392422062586d936af87ee0e46 (patch) | |
tree | faaa1e31fdd096c2b071e49fab32f814a6442a91 /src/Text/Pandoc | |
parent | d8e4a8bc10bfd97d81ec0166fd786742fe3a2370 (diff) | |
download | pandoc-385dcf5b99331d392422062586d936af87ee0e46.tar.gz |
Org reader: drop trees with a :noexport: tag
Trees having a `:noexport:` tag set are not exported. This mirrors
default Emacs Org-Mode behavior.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/Org.hs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Org.hs b/src/Text/Pandoc/Readers/Org.hs index dd8da30c2..65b8d972c 100644 --- a/src/Text/Pandoc/Readers/Org.hs +++ b/src/Text/Pandoc/Readers/Org.hs @@ -84,13 +84,21 @@ dropCommentTrees [] = [] dropCommentTrees blks@(b:bs) = maybe blks (flip dropUntilHeaderAboveLevel bs) $ commentHeaderLevel b --- | Return the level of a header starting a comment tree and Nothing --- otherwise. +-- | Return the level of a header starting a comment or :noexport: tree and +-- Nothing otherwise. commentHeaderLevel :: Block -> Maybe Int commentHeaderLevel blk = case blk of - (Header level _ ((Str "COMMENT"):_)) -> Just level - _ -> Nothing + (Header level _ ((Str "COMMENT"):_)) -> Just level + (Header level _ title) | hasNoExportTag title -> Just level + _ -> Nothing + where + hasNoExportTag :: [Inline] -> Bool + hasNoExportTag = any isNoExportTag + + isNoExportTag :: Inline -> Bool + isNoExportTag (Span ("", ["tag"], [("data-tag-name", "noexport")]) []) = True + isNoExportTag _ = False -- | Drop blocks until a header on or above the given level is seen dropUntilHeaderAboveLevel :: Int -> [Block] -> [Block] |