git.iko.soy/typeable/pandoc
on master help sign in
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.

commit0568aa5cad5ca5501dc0565b0e341fc5393f67e2 authorAlbert Krewinkel <albert@zeitkraut.de> dateMon 29 Aug 2016, 14:10 (10 years ago) parent117d3f4
4 files changed+13−5
src/Text/Pandoc/Readers/Org/ExportSettings.hs+1−1 src/Text/Pandoc/Readers/Org/Meta.hs+4−4 src/Text/Pandoc/Readers/Org/ParserState.hs+2 tests/Tests/Readers/Org.hs+6
src/Text/Pandoc/Readers/Org/ExportSettings.hs+1−1
@@ -60,7 +60,7 @@ exportSetting = choice
6060 , complementableListSetting "d" (\val es -> es { exportDrawers = val })
6161 , ignoredSetting "date"
6262 , ignoredSetting "e"
63− , ignoredSetting "email"
63+ , booleanSetting "email" (\val es -> es { exportWithEmail = val })
6464 , ignoredSetting "f"
6565 , integerSetting "H" (\val es -> es { exportHeadlineLevels = val })
6666 , ignoredSetting "inline"
src/Text/Pandoc/Readers/Org/Meta.hs+4−4
@@ -53,8 +53,11 @@ import Network.HTTP ( urlEncode )
5353metaExport :: OrgParser (F Meta)
5454metaExport = do
5555 st <- getState
56− let withAuthor = extractExportOption exportWithAuthor st
56+ let settings = orgStateExportSettings st
57+ let withAuthor = exportWithAuthor settings
58+ let withEmail = exportWithEmail settings
5759 return $ (if withAuthor then id else removeMeta "author")
60+ . (if withEmail then id else removeMeta "email")
5861 <$> orgStateMeta st
5962
6063removeMeta :: String -> Meta -> Meta
@@ -62,9 +65,6 @@ removeMeta key meta' =
6265 let metaMap = unMeta meta'
6366 in Meta $ M.delete key metaMap
6467
65−extractExportOption :: (ExportSettings -> a) -> OrgParserState -> a
66−extractExportOption ex = ex . orgStateExportSettings
67−
6868-- | Parse and handle a single line containing meta information
6969-- The order, in which blocks are tried, makes sure that we're not looking at
7070-- 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
164164 , exportSpecialStrings :: Bool -- ^ Parse ellipses and dashes smartly
165165 , exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts
166166 , exportWithAuthor :: Bool -- ^ Include author in final meta-data
167+ , exportWithEmail :: Bool -- ^ Include email in final meta-data
167168 }
168169
169170instance Default ExportSettings where
@@ -179,6 +180,7 @@ defaultExportSettings = ExportSettings
179180 , exportSpecialStrings = True
180181 , exportSubSuperscripts = True
181182 , exportWithAuthor = True
183+ , exportWithEmail = True
182184 }
183185
184186
tests/Tests/Readers/Org.hs+6
@@ -674,6 +674,12 @@ tests =
674674 , "#+AUTHOR: ShyGuy"
675675 ] =?>
676676 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
677683 ]
678684 ]
679685