Org reader: respect export option for tags
Tags are appended to headlines by default, but will be omitted when the `tags` export option is set to nil. Closes: #3713
This commit is contained in:
parent
33a1e4ae1a
commit
e1a0666689
4 changed files with 14 additions and 2 deletions
|
@ -220,12 +220,16 @@ headlineToHeaderWithContents hdln@(Headline {..}) = do
|
|||
headlineToHeader :: Monad m => Headline -> OrgParser m Blocks
|
||||
headlineToHeader (Headline {..}) = do
|
||||
exportTodoKeyword <- getExportSetting exportWithTodoKeywords
|
||||
exportTags <- getExportSetting exportWithTags
|
||||
let todoText = if exportTodoKeyword
|
||||
then case headlineTodoMarker of
|
||||
Just kw -> todoKeywordToInlines kw <> B.space
|
||||
Nothing -> mempty
|
||||
else mempty
|
||||
let text = todoText <> headlineText <> tagsToInlines headlineTags
|
||||
let text = todoText <> headlineText <>
|
||||
if exportTags
|
||||
then tagsToInlines headlineTags
|
||||
else mempty
|
||||
let propAttr = propertiesToAttr headlineProperties
|
||||
attr <- registerHeader propAttr headlineText
|
||||
return $ B.headerWith attr headlineLevel text
|
||||
|
|
|
@ -71,7 +71,7 @@ exportSetting = choice
|
|||
, ignoredSetting "pri"
|
||||
, ignoredSetting "prop"
|
||||
, ignoredSetting "stat"
|
||||
, ignoredSetting "tags"
|
||||
, booleanSetting "tags" (\val es -> es { exportWithTags = val })
|
||||
, ignoredSetting "tasks"
|
||||
, ignoredSetting "tex"
|
||||
, ignoredSetting "timestamp"
|
||||
|
|
|
@ -240,6 +240,7 @@ data ExportSettings = ExportSettings
|
|||
, exportWithAuthor :: Bool -- ^ Include author in final meta-data
|
||||
, exportWithCreator :: Bool -- ^ Include creator in final meta-data
|
||||
, exportWithEmail :: Bool -- ^ Include email in final meta-data
|
||||
, exportWithTags :: Bool -- ^ Keep tags as part of headlines
|
||||
, exportWithTodoKeywords :: Bool -- ^ Keep TODO keywords in headers
|
||||
}
|
||||
|
||||
|
@ -258,5 +259,6 @@ defaultExportSettings = ExportSettings
|
|||
, exportWithAuthor = True
|
||||
, exportWithCreator = True
|
||||
, exportWithEmail = True
|
||||
, exportWithTags = True
|
||||
, exportWithTodoKeywords = True
|
||||
}
|
||||
|
|
|
@ -794,6 +794,12 @@ tests =
|
|||
, "** DONE todo export"
|
||||
] =?>
|
||||
headerWith ("todo-export", [], []) 2 "todo export"
|
||||
|
||||
, "remove tags from headlines" =:
|
||||
unlines [ "#+OPTIONS: tags:nil"
|
||||
, "* Headline :hello:world:"
|
||||
] =?>
|
||||
headerWith ("headline", [], mempty) 1 "Headline"
|
||||
]
|
||||
]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue