summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Org/Meta.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Readers/Org/Meta.hs')
-rw-r--r--src/Text/Pandoc/Readers/Org/Meta.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Meta.hs b/src/Text/Pandoc/Readers/Org/Meta.hs
index 51fd2c9d8..4d74713d6 100644
--- a/src/Text/Pandoc/Readers/Org/Meta.hs
+++ b/src/Text/Pandoc/Readers/Org/Meta.hs
@@ -29,6 +29,7 @@ Parsers for Org-mode meta declarations.
-}
module Text.Pandoc.Readers.Org.Meta
( metaLine
+ , metaExport
) where
import Text.Pandoc.Readers.Org.BlockStarts
@@ -48,6 +49,22 @@ import Data.List ( intersperse )
import qualified Data.Map as M
import Network.HTTP ( urlEncode )
+-- | Returns the current meta, respecting export options.
+metaExport :: OrgParser (F Meta)
+metaExport = do
+ st <- getState
+ let withAuthor = extractExportOption exportWithAuthor st
+ return $ (if withAuthor then id else removeMeta "author")
+ <$> orgStateMeta st
+
+removeMeta :: String -> Meta -> Meta
+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