@@ -1,5 +1,6 @@
11{-# LANGUAGE FlexibleContexts #-}
22{-# LANGUAGE RecordWildCards #-}
3+{-# OPTIONS_GHC -fno-warn-overlapping-patterns #-}
34{-
45Copyright (C) 2014-2016 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
56
@@ -52,6 +53,7 @@ import Data.Char ( isSpace, toLower, toUpper)
5253import Data.List ( foldl', intersperse, isPrefixOf )
5354import qualified Data.Map as M
5455import Data.Maybe ( fromMaybe, isNothing )
56+import qualified Data.Sequence as S
5557import Network.HTTP ( urlEncode )
5658
5759--
@@ -132,7 +134,24 @@ headline lvl = try $ do
132134
133135-- | Convert an Org mode headline (i.e. a document tree) into pandoc's Blocks
134136headlineToBlocks :: Headline -> OrgParser Blocks
135−headlineToBlocks (Headline {..}) = do
137+headlineToBlocks hdln@(Headline {..}) =
138+ case () of
139+ _ | any isNoExportTag headlineTags -> return mempty
140+ _ | isCommentTitle headlineText -> return mempty
141+ _ -> headlineToHeader hdln
142+
143+isNoExportTag :: Tag -> Bool
144+isNoExportTag = (== toTag "noexport")
145+
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
152+
153+headlineToHeader :: Headline -> OrgParser Blocks
154+headlineToHeader (Headline {..}) = do
136155 let text = tagTitle headlineText headlineTags
137156 let propAttr = propertiesToAttr headlineProperties
138157 attr <- registerHeader propAttr headlineText