Org reader: respect creator export option

The `creator` option controls whether the creator meta-field should be
included in the final markup.  Setting `#+OPTIONS: creator:nil` will
drop the creator field from the final meta-data output.

Org-mode recognizes the special value `comment` for this field, causing
the creator to be included in a comment.  This is difficult to translate
to Pandoc internals and is hence interpreted the same as other truish
values (i.e. the meta field is kept if it's present).
This commit is contained in:
Albert Krewinkel 2016-08-29 14:10:58 +02:00
parent 0568aa5cad
commit 88313c0b93
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
4 changed files with 14 additions and 5 deletions

View file

@ -56,7 +56,9 @@ exportSetting = choice
, archivedTreeSetting "arch" (\val es -> es { exportArchivedTrees = val })
, booleanSetting "author" (\val es -> es { exportWithAuthor = val })
, ignoredSetting "c"
, ignoredSetting "creator"
-- org-mode allows the special value `comment` for creator, which we'll
-- interpret as true as it doesn't make sense in the context of Pandoc.
, booleanSetting "creator" (\val es -> es { exportWithCreator = val })
, complementableListSetting "d" (\val es -> es { exportDrawers = val })
, ignoredSetting "date"
, ignoredSetting "e"

View file

@ -54,10 +54,9 @@ metaExport :: OrgParser (F Meta)
metaExport = do
st <- getState
let settings = orgStateExportSettings st
let withAuthor = exportWithAuthor settings
let withEmail = exportWithEmail settings
return $ (if withAuthor then id else removeMeta "author")
. (if withEmail then id else removeMeta "email")
return $ (if exportWithAuthor settings then id else removeMeta "author")
. (if exportWithCreator settings then id else removeMeta "creator")
. (if exportWithEmail settings then id else removeMeta "email")
<$> orgStateMeta st
removeMeta :: String -> Meta -> Meta

View file

@ -164,6 +164,7 @@ data ExportSettings = ExportSettings
, exportSpecialStrings :: Bool -- ^ Parse ellipses and dashes smartly
, exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts
, exportWithAuthor :: Bool -- ^ Include author in final meta-data
, exportWithCreator :: Bool -- ^ Include creator in final meta-data
, exportWithEmail :: Bool -- ^ Include email in final meta-data
}
@ -180,6 +181,7 @@ defaultExportSettings = ExportSettings
, exportSpecialStrings = True
, exportSubSuperscripts = True
, exportWithAuthor = True
, exportWithCreator = True
, exportWithEmail = True
}

View file

@ -675,6 +675,12 @@ tests =
] =?>
Pandoc nullMeta mempty
, "disable creator export" =:
unlines [ "#+OPTIONS: creator:nil"
, "#+creator: The Architect"
] =?>
Pandoc nullMeta mempty
, "disable email export" =:
unlines [ "#+OPTIONS: email:nil"
, "#+email: no-mail-please@example.com"