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:
Albert Krewinkel 2017-05-31 21:26:07 +02:00
parent 33a1e4ae1a
commit e1a0666689
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
4 changed files with 14 additions and 2 deletions

View file

@ -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

View file

@ -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"

View file

@ -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
}

View file

@ -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"
]
]