@@ -1,5 +1,6 @@
1{-# LANGUAGE FlexibleContexts #-}
1{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE RecordWildCards #-}
2{-# LANGUAGE RecordWildCards #-}
3+{-# OPTIONS_GHC -fno-warn-overlapping-patterns #-}
4Copyright (C) 2014-2016 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
5Copyright (C) 2014-2016 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
@@ -52,6 +53,7 @@ import Data.Char ( isSpace, toLower, toUpper)
52import Data.List ( foldl', intersperse, isPrefixOf )
53import Data.List ( foldl', intersperse, isPrefixOf )
53import qualified Data.Map as M
54import qualified Data.Map as M
54import Data.Maybe ( fromMaybe, isNothing )
55import Data.Maybe ( fromMaybe, isNothing )
56+import qualified Data.Sequence as S
55import Network.HTTP ( urlEncode )
57import Network.HTTP ( urlEncode )
@@ -132,7 +134,24 @@ headline lvl = try $ do
133-- | Convert an Org mode headline (i.e. a document tree) into pandoc's Blocks
135-- | Convert an Org mode headline (i.e. a document tree) into pandoc's Blocks
134headlineToBlocks :: Headline -> OrgParser Blocks
136headlineToBlocks :: Headline -> OrgParser Blocks
135−headlineToBlocks (Headline {..}) = do
137+headlineToBlocks hdln@(Headline {..}) =
139+ _ | any isNoExportTag headlineTags -> return mempty
140+ _ | isCommentTitle headlineText -> return mempty
141+ _ -> headlineToHeader hdln
143+isNoExportTag :: Tag -> Bool
144+isNoExportTag = (== toTag "noexport")
146+-- | Check if the title starts with COMMENT.
147+-- FIXME: This accesses builder internals not intended for use in situations
148+-- as these. Replace once keyword parsing is supported.
149+isCommentTitle :: Inlines -> Bool
150+isCommentTitle xs = (B.Many . S.take 1 . B.unMany) xs == B.str "COMMENT"
151+isCommentTitle _ = False
153+headlineToHeader :: Headline -> OrgParser Blocks
154+headlineToHeader (Headline {..}) = do
136 let text = tagTitle headlineText headlineTags
155 let text = tagTitle headlineText headlineTags
137 let propAttr = propertiesToAttr headlineProperties
156 let propAttr = propertiesToAttr headlineProperties
138 attr <- registerHeader propAttr headlineText
157 attr <- registerHeader propAttr headlineText