Org reader: respect email export option

The `email` option controls whether the email meta-field should be
included in the final markup. Setting `#+OPTIONS: email:nil` will drop
the email field from the final meta-data output.
This commit is contained in:
Albert Krewinkel 2016-08-29 14:10:58 +02:00
parent 117d3f4d92
commit 0568aa5cad
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
4 changed files with 13 additions and 5 deletions

View file

@ -60,7 +60,7 @@ exportSetting = choice
, complementableListSetting "d" (\val es -> es { exportDrawers = val })
, ignoredSetting "date"
, ignoredSetting "e"
, ignoredSetting "email"
, booleanSetting "email" (\val es -> es { exportWithEmail = val })
, ignoredSetting "f"
, integerSetting "H" (\val es -> es { exportHeadlineLevels = val })
, ignoredSetting "inline"

View file

@ -53,8 +53,11 @@ import Network.HTTP ( urlEncode )
metaExport :: OrgParser (F Meta)
metaExport = do
st <- getState
let withAuthor = extractExportOption exportWithAuthor st
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")
<$> orgStateMeta st
removeMeta :: String -> Meta -> Meta
@ -62,9 +65,6 @@ removeMeta key meta' =
let metaMap = unMeta meta'
in Meta $ M.delete key metaMap
extractExportOption :: (ExportSettings -> a) -> OrgParserState -> a
extractExportOption ex = ex . orgStateExportSettings
-- | Parse and handle a single line containing meta information
-- The order, in which blocks are tried, makes sure that we're not looking at
-- the beginning of a block, so we don't need to check for it

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
, exportWithEmail :: Bool -- ^ Include email in final meta-data
}
instance Default ExportSettings where
@ -179,6 +180,7 @@ defaultExportSettings = ExportSettings
, exportSpecialStrings = True
, exportSubSuperscripts = True
, exportWithAuthor = True
, exportWithEmail = True
}

View file

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