diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2016-08-29 14:10:58 +0200 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2016-08-29 14:33:18 +0200 |
commit | 117d3f4d92d5096cfa51305db6d2fa261ef87d24 (patch) | |
tree | 4762cdde72958d0b5903af9aafe3084b6c002c9f /src/Text/Pandoc/Readers/Org/Meta.hs | |
parent | ad625782b170f4cbbef206bc6ea736c082cb38d7 (diff) | |
download | pandoc-117d3f4d92d5096cfa51305db6d2fa261ef87d24.tar.gz |
Org reader: respect `author` export option
The `author` option controls whether the author should be included in
the final markup. Setting `#+OPTIONS: author:nil` will drop the author
from the final meta-data output.
Diffstat (limited to 'src/Text/Pandoc/Readers/Org/Meta.hs')
-rw-r--r-- | src/Text/Pandoc/Readers/Org/Meta.hs | 17 |
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 |