From 0568aa5cad5ca5501dc0565b0e341fc5393f67e2 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Mon, 29 Aug 2016 14:10:58 +0200 Subject: 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. --- src/Text/Pandoc/Readers/Org/ExportSettings.hs | 2 +- src/Text/Pandoc/Readers/Org/Meta.hs | 8 ++++---- src/Text/Pandoc/Readers/Org/ParserState.hs | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/Org/ExportSettings.hs b/src/Text/Pandoc/Readers/Org/ExportSettings.hs index b539a8000..6233a6104 100644 --- a/src/Text/Pandoc/Readers/Org/ExportSettings.hs +++ b/src/Text/Pandoc/Readers/Org/ExportSettings.hs @@ -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" diff --git a/src/Text/Pandoc/Readers/Org/Meta.hs b/src/Text/Pandoc/Readers/Org/Meta.hs index 4d74713d6..a20c25e09 100644 --- a/src/Text/Pandoc/Readers/Org/Meta.hs +++ b/src/Text/Pandoc/Readers/Org/Meta.hs @@ -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 diff --git a/src/Text/Pandoc/Readers/Org/ParserState.hs b/src/Text/Pandoc/Readers/Org/ParserState.hs index 661ccc4ea..4c3aa298c 100644 --- a/src/Text/Pandoc/Readers/Org/ParserState.hs +++ b/src/Text/Pandoc/Readers/Org/ParserState.hs @@ -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 } -- cgit v1.2.3