git.iko.soy/typeable/pandoc
on master help sign in
Org reader: respect `email` export option
0568aa5Albert Krewinkel
src/Text/Pandoc/Readers/Org/ExportSettings.hs+1−1
@@ -60,7 +60,7 @@ exportSetting = choice
60 , complementableListSetting "d" (\val es -> es { exportDrawers = val })
60 , complementableListSetting "d" (\val es -> es { exportDrawers = val })
61 , ignoredSetting "date"
61 , ignoredSetting "date"
62 , ignoredSetting "e"
62 , ignoredSetting "e"
63− , ignoredSetting "email"
63+ , booleanSetting "email" (\val es -> es { exportWithEmail = val })
64 , ignoredSetting "f"
64 , ignoredSetting "f"
65 , integerSetting "H" (\val es -> es { exportHeadlineLevels = val })
65 , integerSetting "H" (\val es -> es { exportHeadlineLevels = val })
66 , ignoredSetting "inline"
66 , ignoredSetting "inline"
src/Text/Pandoc/Readers/Org/Meta.hs+4−4
@@ -53,8 +53,11 @@ import Network.HTTP ( urlEncode )
53metaExport :: OrgParser (F Meta)
53metaExport :: OrgParser (F Meta)
54metaExport = do
54metaExport = do
55 st <- getState
55 st <- getState
56+ let settings = orgStateExportSettings st
56− let withAuthor = extractExportOption exportWithAuthor st
57+ let withAuthor = exportWithAuthor settings
58+ let withEmail = exportWithEmail settings
57 return $ (if withAuthor then id else removeMeta "author")
59 return $ (if withAuthor then id else removeMeta "author")
60+ . (if withEmail then id else removeMeta "email")
58 <$> orgStateMeta st
61 <$> orgStateMeta st
59
62
60removeMeta :: String -> Meta -> Meta
63removeMeta :: String -> Meta -> Meta
@@ -62,9 +65,6 @@ removeMeta key meta' =
62 let metaMap = unMeta meta'
65 let metaMap = unMeta meta'
63 in Meta $ M.delete key metaMap
66 in Meta $ M.delete key metaMap
64
67
65−extractExportOption :: (ExportSettings -> a) -> OrgParserState -> a
66−extractExportOption ex = ex . orgStateExportSettings
67−
68-- | Parse and handle a single line containing meta information
68-- | Parse and handle a single line containing meta information
69-- The order, in which blocks are tried, makes sure that we're not looking at
69-- The order, in which blocks are tried, makes sure that we're not looking at
70-- the beginning of a block, so we don't need to check for it
70-- the beginning of a block, so we don't need to check for it
src/Text/Pandoc/Readers/Org/ParserState.hs+2
@@ -164,6 +164,7 @@ data ExportSettings = ExportSettings
164 , exportSpecialStrings :: Bool -- ^ Parse ellipses and dashes smartly
164 , exportSpecialStrings :: Bool -- ^ Parse ellipses and dashes smartly
165 , exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts
165 , exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts
166 , exportWithAuthor :: Bool -- ^ Include author in final meta-data
166 , exportWithAuthor :: Bool -- ^ Include author in final meta-data
167+ , exportWithEmail :: Bool -- ^ Include email in final meta-data
167 }
168 }
168
169
169instance Default ExportSettings where
170instance Default ExportSettings where
@@ -179,6 +180,7 @@ defaultExportSettings = ExportSettings
179 , exportSpecialStrings = True
180 , exportSpecialStrings = True
180 , exportSubSuperscripts = True
181 , exportSubSuperscripts = True
181 , exportWithAuthor = True
182 , exportWithAuthor = True
183+ , exportWithEmail = True
182 }
184 }
183
185
184
186
tests/Tests/Readers/Org.hs+6
@@ -674,6 +674,12 @@ tests =
674 , "#+AUTHOR: ShyGuy"
674 , "#+AUTHOR: ShyGuy"
675 ] =?>
675 ] =?>
676 Pandoc nullMeta mempty
676 Pandoc nullMeta mempty
677+
678+ , "disable email export" =:
679+ unlines [ "#+OPTIONS: email:nil"
680+ , "#+email: no-mail-please@example.com"
681+ ] =?>
682+ Pandoc nullMeta mempty
677 ]
683 ]
678 ]
684 ]
679
685