@@ -137,27 +137,43 @@ headlineToBlocks :: Headline -> OrgParser Blocks
137headlineToBlocks hdln@(Headline {..}) =
137headlineToBlocks hdln@(Headline {..}) =
138 case () of
138 case () of
139 _ | any isNoExportTag headlineTags -> return mempty
139 _ | any isNoExportTag headlineTags -> return mempty
140+ _ | any isArchiveTag headlineTags -> archivedHeadlineToBlocks hdln
140 _ | isCommentTitle headlineText -> return mempty
141 _ | isCommentTitle headlineText -> return mempty
141− _ -> headlineToHeader hdln
142+ _ -> headlineToHeaderWithContents hdln
143isNoExportTag :: Tag -> Bool
144isNoExportTag :: Tag -> Bool
144isNoExportTag = (== toTag "noexport")
145isNoExportTag = (== toTag "noexport")
147+isArchiveTag :: Tag -> Bool
148+isArchiveTag = (== toTag "ARCHIVE")
146-- | Check if the title starts with COMMENT.
150-- | Check if the title starts with COMMENT.
147-- FIXME: This accesses builder internals not intended for use in situations
151-- FIXME: This accesses builder internals not intended for use in situations
148−-- as these. Replace once keyword parsing is supported.
152+-- like these. Replace once keyword parsing is supported.
149isCommentTitle :: Inlines -> Bool
153isCommentTitle :: Inlines -> Bool
150isCommentTitle xs = (B.Many . S.take 1 . B.unMany) xs == B.str "COMMENT"
154isCommentTitle xs = (B.Many . S.take 1 . B.unMany) xs == B.str "COMMENT"
151isCommentTitle _ = False
155isCommentTitle _ = False
157+archivedHeadlineToBlocks :: Headline -> OrgParser Blocks
158+archivedHeadlineToBlocks hdln = do
159+ archivedTreesOption <- getExportSetting exportArchivedTrees
160+ case archivedTreesOption of
161+ ArchivedTreesNoExport -> return mempty
162+ ArchivedTreesExport -> headlineToHeaderWithContents hdln
163+ ArchivedTreesHeadlineOnly -> headlineToHeader hdln
165+headlineToHeaderWithContents :: Headline -> OrgParser Blocks
166+headlineToHeaderWithContents hdln@(Headline {..}) = do
167+ header <- headlineToHeader hdln
168+ childrenBlocks <- mconcat <$> sequence (map headlineToBlocks headlineChildren)
169+ return $ header <> headlineContents <> childrenBlocks
153headlineToHeader :: Headline -> OrgParser Blocks
171headlineToHeader :: Headline -> OrgParser Blocks
154headlineToHeader (Headline {..}) = do
172headlineToHeader (Headline {..}) = do
155 let text = tagTitle headlineText headlineTags
173 let text = tagTitle headlineText headlineTags
156 let propAttr = propertiesToAttr headlineProperties
174 let propAttr = propertiesToAttr headlineProperties
157 attr <- registerHeader propAttr headlineText
175 attr <- registerHeader propAttr headlineText
158− let header = B.headerWith attr headlineLevel text
176+ return $ B.headerWith attr headlineLevel text
159− childrenBlocks <- mconcat <$> sequence (map headlineToBlocks headlineChildren)
160− return $ header <> headlineContents <> childrenBlocks
162propertiesToAttr :: Properties -> Attr
178propertiesToAttr :: Properties -> Attr
163propertiesToAttr properties =
179propertiesToAttr properties =
@@ -629,7 +645,7 @@ exportSetting = choice
629 , ignoredSetting ":"
645 , ignoredSetting ":"
630 , ignoredSetting "<"
646 , ignoredSetting "<"
631 , ignoredSetting "\\n"
647 , ignoredSetting "\\n"
632− , ignoredSetting "arch"
648+ , archivedTreeSetting "arch" setExportArchivedTrees
633 , ignoredSetting "author"
649 , ignoredSetting "author"
634 , ignoredSetting "c"
650 , ignoredSetting "c"
635 , ignoredSetting "creator"
651 , ignoredSetting "creator"
@@ -673,6 +689,27 @@ elispBoolean = try $ do
673 "()" -> False
689 "()" -> False
674 _ -> True
690 _ -> True
692+archivedTreeSetting :: String
693+ -> ExportSettingSetter ArchivedTreesOption
695+archivedTreeSetting settingIdentifier setter = try $ do
696+ string settingIdentifier
698+ value <- archivedTreesHeadlineSetting <|> archivedTreesBoolean
699+ updateState $ modifyExportSettings setter value
701+ archivedTreesHeadlineSetting = try $ do
703+ lookAhead (newline <|> spaceChar)
704+ return ArchivedTreesHeadlineOnly
706+ archivedTreesBoolean = try $ do
707+ exportBool <- elispBoolean
710+ then ArchivedTreesExport
711+ else ArchivedTreesNoExport
676-- | A list or a complement list (i.e. a list starting with `not`).
713-- | A list or a complement list (i.e. a list starting with `not`).
677complementableListSetting :: String
714complementableListSetting :: String
678 -> ExportSettingSetter (Either [String] [String])
715 -> ExportSettingSetter (Either [String] [String])