{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
module Text.Pandoc.App.Opt (
Opt(..)
, OptInfo(..)
, LineEnding (..)
, IpynbOutput (..)
, DefaultsState (..)
, defaultOpts
, applyDefaults
, fullDefaultsPath
) where
import Control.Monad.Except (throwError)
import Control.Monad.Trans (MonadIO, liftIO)
import Control.Monad ((>=>), foldM)
import Control.Monad.State.Strict (StateT, modify, gets)
import System.FilePath ( addExtension, (</>), takeExtension, takeDirectory )
import System.Directory ( canonicalizePath )
import Data.Char (toLower)
import Data.Maybe (fromMaybe)
import GHC.Generics hiding (Meta)
import Text.Pandoc.Filter (Filter (..))
import Text.Pandoc.Logging (Verbosity (WARNING), LogMessage(..))
import Text.Pandoc.Options (TopLevelDivision (TopLevelDefault),
TrackChanges (AcceptChanges),
WrapOption (WrapAuto), HTMLMathMethod (PlainMath),
ReferenceLocation (EndOfDocument),
ObfuscationMethod (NoObfuscation),
CiteMethod (Citeproc))
import Text.Pandoc.Class (readFileStrict, fileExists, setVerbosity, report,
PandocMonad(lookupEnv), getUserDataDir)
import Text.Pandoc.Error (PandocError (PandocParseError, PandocSomeError))
import Data.Containers.ListUtils (nubOrd)
import Text.Pandoc.Data (defaultUserDataDir)
import qualified Text.Pandoc.Parsing as P
import Text.Pandoc.Readers.Metadata (yamlMap)
import Text.Pandoc.Class.PandocPure
import Text.DocTemplates (Context(..))
import Data.Text (Text, unpack)
import Data.Default (def)
import qualified Data.Text as T
import qualified Data.Map as M
import qualified Data.ByteString.Char8 as B8
import Text.Pandoc.Definition (Meta(..), MetaValue(..))
import Data.Aeson (defaultOptions, Options(..), Result(..),
genericToJSON, fromJSON, camelTo2)
import Data.Aeson.TH (deriveJSON)
import Control.Applicative ((<|>))
import Data.Yaml
data LineEnding = LF | CRLF | Native deriving (Int -> LineEnding -> ShowS
[LineEnding] -> ShowS
LineEnding -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [LineEnding] -> ShowS
$cshowList :: [LineEnding] -> ShowS
show :: LineEnding -> FilePath
$cshow :: LineEnding -> FilePath
showsPrec :: Int -> LineEnding -> ShowS
$cshowsPrec :: Int -> LineEnding -> ShowS
Show, forall x. Rep LineEnding x -> LineEnding
forall x. LineEnding -> Rep LineEnding x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LineEnding x -> LineEnding
$cfrom :: forall x. LineEnding -> Rep LineEnding x
Generic)
$(deriveJSON
defaultOptions{ constructorTagModifier = map toLower } ''LineEnding)
data IpynbOutput =
IpynbOutputAll
| IpynbOutputNone
| IpynbOutputBest
deriving (Int -> IpynbOutput -> ShowS
[IpynbOutput] -> ShowS
IpynbOutput -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [IpynbOutput] -> ShowS
$cshowList :: [IpynbOutput] -> ShowS
show :: IpynbOutput -> FilePath
$cshow :: IpynbOutput -> FilePath
showsPrec :: Int -> IpynbOutput -> ShowS
$cshowsPrec :: Int -> IpynbOutput -> ShowS
Show, forall x. Rep IpynbOutput x -> IpynbOutput
forall x. IpynbOutput -> Rep IpynbOutput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IpynbOutput x -> IpynbOutput
$cfrom :: forall x. IpynbOutput -> Rep IpynbOutput x
Generic)
$(deriveJSON
defaultOptions{ fieldLabelModifier = map toLower . drop 11 } ''IpynbOutput)
data OptInfo =
BashCompletion
| ListInputFormats
| ListOutputFormats
| ListExtensions (Maybe Text)
| ListHighlightLanguages
| ListHighlightStyles
| PrintDefaultTemplate (Maybe FilePath) Text
| PrintDefaultDataFile (Maybe FilePath) Text
| PrintHighlightStyle (Maybe FilePath) Text
| VersionInfo
| Help
| OptError PandocError
deriving (Int -> OptInfo -> ShowS
[OptInfo] -> ShowS
OptInfo -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [OptInfo] -> ShowS
$cshowList :: [OptInfo] -> ShowS
show :: OptInfo -> FilePath
$cshow :: OptInfo -> FilePath
showsPrec :: Int -> OptInfo -> ShowS
$cshowsPrec :: Int -> OptInfo -> ShowS
Show, forall x. Rep OptInfo x -> OptInfo
forall x. OptInfo -> Rep OptInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OptInfo x -> OptInfo
$cfrom :: forall x. OptInfo -> Rep OptInfo x
Generic)
data Opt = Opt
{ Opt -> Int
optTabStop :: Int
, Opt -> Bool
optPreserveTabs :: Bool
, Opt -> Bool
optStandalone :: Bool
, Opt -> Maybe Text
optFrom :: Maybe Text
, Opt -> Maybe Text
optTo :: Maybe Text
, Opt -> Bool
optTableOfContents :: Bool
, Opt -> Int
optShiftHeadingLevelBy :: Int
, Opt -> Maybe FilePath
optTemplate :: Maybe FilePath
, Opt -> Context Text
optVariables :: Context Text
, Opt -> Meta
optMetadata :: Meta
, Opt -> [FilePath]
optMetadataFiles :: [FilePath]
, Opt -> Maybe FilePath
optOutputFile :: Maybe FilePath
, Opt -> Maybe [FilePath]
optInputFiles :: Maybe [FilePath]
, Opt -> Bool
optNumberSections :: Bool
, Opt -> [Int]
optNumberOffset :: [Int]
, Opt -> Bool
optSectionDivs :: Bool
, Opt -> Bool
optIncremental :: Bool
, Opt -> Bool
optSelfContained :: Bool
, Opt -> Bool
optEmbedResources :: Bool
, Opt -> Bool
optHtmlQTags :: Bool
, Opt -> Maybe Text
optHighlightStyle :: Maybe Text
, Opt -> [FilePath]
optSyntaxDefinitions :: [FilePath]
, Opt -> TopLevelDivision
optTopLevelDivision :: TopLevelDivision
, Opt -> HTMLMathMethod
optHTMLMathMethod :: HTMLMathMethod
, Opt -> Maybe FilePath
optAbbreviations :: Maybe FilePath
, Opt -> Maybe FilePath
optReferenceDoc :: Maybe FilePath
, Opt -> Int
optSplitLevel :: Int
, Opt -> Maybe Text
optChunkTemplate :: Maybe Text
, Opt -> FilePath
optEpubSubdirectory :: String
, Opt -> Maybe FilePath
optEpubMetadata :: Maybe FilePath
, Opt -> [FilePath]
optEpubFonts :: [FilePath]
, Opt -> Maybe FilePath
optEpubCoverImage :: Maybe FilePath
, Opt -> Bool
optEpubTitlePage :: Bool
, Opt -> Int
optTOCDepth :: Int
, Opt -> Bool
optDumpArgs :: Bool
, Opt -> Bool
optIgnoreArgs :: Bool
, Opt -> Verbosity
optVerbosity :: Verbosity
, Opt -> Bool
optTrace :: Bool
, Opt -> Maybe FilePath
optLogFile :: Maybe FilePath
, Opt -> Bool
optFailIfWarnings :: Bool
, Opt -> Bool
optReferenceLinks :: Bool
, Opt -> ReferenceLocation
optReferenceLocation :: ReferenceLocation
, Opt -> Int
optDpi :: Int
, Opt -> WrapOption
optWrap :: WrapOption
, Opt -> Int
optColumns :: Int
, Opt -> [Filter]
optFilters :: [Filter]
, Opt -> ObfuscationMethod
optEmailObfuscation :: ObfuscationMethod
, Opt -> Text
optIdentifierPrefix :: Text
, Opt -> [Text]
optIndentedCodeClasses :: [Text]
, Opt -> Maybe FilePath
optDataDir :: Maybe FilePath
, Opt -> CiteMethod
optCiteMethod :: CiteMethod
, Opt -> Bool
optListings :: Bool
, Opt -> Maybe FilePath
optPdfEngine :: Maybe String
, Opt -> [FilePath]
optPdfEngineOpts :: [String]
, Opt -> Maybe Int
optSlideLevel :: Maybe Int
, :: Bool
, Opt -> Bool
optListTables :: Bool
, Opt -> Bool
optAscii :: Bool
, Opt -> Text
optDefaultImageExtension :: Text
, :: Maybe FilePath
, Opt -> TrackChanges
optTrackChanges :: TrackChanges
, Opt -> Bool
optFileScope :: Bool
, Opt -> Maybe Text
optTitlePrefix :: Maybe Text
, Opt -> [FilePath]
optCss :: [FilePath]
, Opt -> IpynbOutput
optIpynbOutput :: IpynbOutput
, Opt -> [FilePath]
optIncludeBeforeBody :: [FilePath]
, Opt -> [FilePath]
optIncludeAfterBody :: [FilePath]
, :: [FilePath]
, Opt -> [FilePath]
optResourcePath :: [FilePath]
, :: [(Text, Text)]
, Opt -> Bool
optNoCheckCertificate :: Bool
, Opt -> LineEnding
optEol :: LineEnding
, :: Bool
, Opt -> Maybe FilePath
optCSL :: Maybe FilePath
, Opt -> [FilePath]
optBibliography :: [FilePath]
, Opt -> Maybe FilePath
optCitationAbbreviations :: Maybe FilePath
, Opt -> Bool
optSandbox :: Bool
} deriving (forall x. Rep Opt x -> Opt
forall x. Opt -> Rep Opt x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Opt x -> Opt
$cfrom :: forall x. Opt -> Rep Opt x
Generic, Int -> Opt -> ShowS
[Opt] -> ShowS
Opt -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Opt] -> ShowS
$cshowList :: [Opt] -> ShowS
show :: Opt -> FilePath
$cshow :: Opt -> FilePath
showsPrec :: Int -> Opt -> ShowS
$cshowsPrec :: Int -> Opt -> ShowS
Show)
instance FromJSON Opt where
parseJSON :: Value -> Parser Opt
parseJSON = forall a. FilePath -> (Object -> Parser a) -> Value -> Parser a
withObject FilePath
"Opt" forall a b. (a -> b) -> a -> b
$ \Object
o ->
Int
-> Bool
-> Bool
-> Maybe Text
-> Maybe Text
-> Bool
-> Int
-> Maybe FilePath
-> Context Text
-> Meta
-> [FilePath]
-> Maybe FilePath
-> Maybe [FilePath]
-> Bool
-> [Int]
-> Bool
-> Bool
-> Bool
-> Bool
-> Bool
-> Maybe Text
-> [FilePath]
-> TopLevelDivision
-> HTMLMathMethod
-> Maybe FilePath
-> Maybe FilePath
-> Int
-> Maybe Text
-> FilePath
-> Maybe FilePath
-> [FilePath]
-> Maybe FilePath
-> Bool
-> Int
-> Bool
-> Bool
-> Verbosity
-> Bool
-> Maybe FilePath
-> Bool
-> Bool
-> ReferenceLocation
-> Int
-> WrapOption
-> Int
-> [Filter]
-> ObfuscationMethod
-> Text
-> [Text]
-> Maybe FilePath
-> CiteMethod
-> Bool
-> Maybe FilePath
-> [FilePath]
-> Maybe Int
-> Bool
-> Bool
-> Bool
-> Text
-> Maybe FilePath
-> TrackChanges
-> Bool
-> Maybe Text
-> [FilePath]
-> IpynbOutput
-> [FilePath]
-> [FilePath]
-> [FilePath]
-> [FilePath]
-> [(Text, Text)]
-> Bool
-> LineEnding
-> Bool
-> Maybe FilePath
-> [FilePath]
-> Maybe FilePath
-> Bool
-> Opt
Opt
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"tab-stop" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Int
optTabStop Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"preserve-tabs" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optPreserveTabs Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"standalone" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optStandalone Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"from"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"to"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"table-of-contents" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optTableOfContents Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"shift-heading-level-by" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Int
optShiftHeadingLevelBy Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"template"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"variables" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Context Text
optVariables Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"metadata" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Meta
optMetadata Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"metadata-files" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [FilePath]
optMetadataFiles Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"output-file"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"input-files"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"number-sections" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optNumberSections Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"number-offset" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [Int]
optNumberOffset Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"section-divs" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optSectionDivs Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"incremental" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optIncremental Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"self-contained" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optSelfContained Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"embed-resources" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optEmbedResources Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"html-q-tags" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optHtmlQTags Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"highlight-style"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"syntax-definitions" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [FilePath]
optSyntaxDefinitions Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"top-level-division" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> TopLevelDivision
optTopLevelDivision Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"html-math-method" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> HTMLMathMethod
optHTMLMathMethod Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"abbreviations"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"reference-doc"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"split-level") forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"epub-chapter-level"))
forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Int
optSplitLevel Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"chunk-template"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"epub-subdirectory" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> FilePath
optEpubSubdirectory Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"epub-metadata"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"epub-fonts" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [FilePath]
optEpubFonts Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"epub-cover-image"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"epub-title-page" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optEpubTitlePage Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"toc-depth" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Int
optTOCDepth Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"dump-args" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optDumpArgs Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"ignore-args" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optIgnoreArgs Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"verbosity" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Verbosity
optVerbosity Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"trace" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optTrace Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"log-file"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"fail-if-warnings" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optFailIfWarnings Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"reference-links" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optReferenceLinks Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"reference-location" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> ReferenceLocation
optReferenceLocation Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"dpi" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Int
optDpi Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"wrap" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> WrapOption
optWrap Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"columns" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Int
optColumns Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"filters" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [Filter]
optFilters Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"email-obfuscation" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> ObfuscationMethod
optEmailObfuscation Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"identifier-prefix" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Text
optIdentifierPrefix Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"indented-code-classes" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [Text]
optIndentedCodeClasses Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"data-dir"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"cite-method" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> CiteMethod
optCiteMethod Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"listings" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optListings Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"pdf-engine"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"pdf-engine-opts" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [FilePath]
optPdfEngineOpts Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"slide-level"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"setext-headers" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optSetextHeaders Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"list-tables" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optListTables Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"ascii" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optAscii Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"default-image-extension" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Text
optDefaultImageExtension Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"extract-media"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"track-changes" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> TrackChanges
optTrackChanges Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"file-scope" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optFileScope Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"title-prefix" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Maybe Text
optTitlePrefix Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"css" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [FilePath]
optCss Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"ipynb-output" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> IpynbOutput
optIpynbOutput Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"include-before-body" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [FilePath]
optIncludeBeforeBody Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"include-after-body" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [FilePath]
optIncludeAfterBody Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"include-in-header" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [FilePath]
optIncludeInHeader Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"resource-path" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [FilePath]
optResourcePath Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"request-headers" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [(Text, Text)]
optRequestHeaders Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"no-check-certificate" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optNoCheckCertificate Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"eol" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> LineEnding
optEol Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"strip-comments" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optStripComments Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"csl"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"bibliography" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> [FilePath]
optBibliography Opt
defaultOpts
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"citation-abbreviations"
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"sandbox" forall a. Parser (Maybe a) -> a -> Parser a
.!= Opt -> Bool
optSandbox Opt
defaultOpts
instance ToJSON Opt where
toJSON :: Opt -> Value
toJSON = forall a.
(Generic a, GToJSON' Value Zero (Rep a)) =>
Options -> a -> Value
genericToJSON Options
defaultOptions{
fieldLabelModifier :: ShowS
fieldLabelModifier = Char -> ShowS
camelTo2 Char
'-' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Int -> [a] -> [a]
drop Int
3,
omitNothingFields :: Bool
omitNothingFields = Bool
True }
instance FromJSON (Opt -> Opt) where
parseJSON :: Value -> Parser (Opt -> Opt)
parseJSON (Object Object
m) =
case forall a. FromJSON a => Value -> Result a
fromJSON (Object -> Value
Object Object
m) of
Error FilePath
err' -> forall (m :: * -> *) a. MonadFail m => FilePath -> m a
fail FilePath
err'
Success (Map Text Value
m' :: M.Map Text Value) -> forall (m :: * -> *) a b.
Monad m =>
(a -> m (b -> b)) -> [a] -> m (b -> b)
chain (Text, Value) -> Parser (Opt -> Opt)
doOpt (forall k a. Map k a -> [(k, a)]
M.toList Map Text Value
m')
parseJSON Value
_ = forall (m :: * -> *) a. MonadFail m => FilePath -> m a
fail FilePath
"Expected a mapping"
data DefaultsState = DefaultsState
{
DefaultsState -> Maybe FilePath
curDefaults :: Maybe FilePath
, DefaultsState -> [[FilePath]]
inheritanceGraph :: [[FilePath]]
} deriving (Int -> DefaultsState -> ShowS
[DefaultsState] -> ShowS
DefaultsState -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [DefaultsState] -> ShowS
$cshowList :: [DefaultsState] -> ShowS
show :: DefaultsState -> FilePath
$cshow :: DefaultsState -> FilePath
showsPrec :: Int -> DefaultsState -> ShowS
$cshowsPrec :: Int -> DefaultsState -> ShowS
Show)
instance (PandocMonad m, MonadIO m)
=> FromJSON (Opt -> StateT DefaultsState m Opt) where
parseJSON :: Value -> Parser (Opt -> StateT DefaultsState m Opt)
parseJSON (Object Object
o) =
case forall a. FromJSON a => Value -> Result a
fromJSON (Object -> Value
Object Object
o) of
Error FilePath
err' -> forall (m :: * -> *) a. MonadFail m => FilePath -> m a
fail FilePath
err'
Success (Map Text Value
opts :: M.Map Text Value) -> do
Maybe FilePath
dataDir <- case forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Text
"data-dir" Map Text Value
opts of
Maybe Value
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
Just Value
v -> forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
Opt -> StateT DefaultsState m Opt
f <- forall (m :: * -> *).
Monad m =>
[(Text, Value)] -> Parser (Opt -> StateT DefaultsState m Opt)
parseOptions (forall k a. Map k a -> [(k, a)]
M.toList Map Text Value
opts)
case forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Text
"defaults" Map Text Value
opts of
Just Value
v -> do
Opt -> StateT DefaultsState m Opt
g <- forall (m :: * -> *).
(PandocMonad m, MonadIO m) =>
Value
-> Maybe FilePath -> Parser (Opt -> StateT DefaultsState m Opt)
parseDefaults Value
v Maybe FilePath
dataDir
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Opt -> StateT DefaultsState m Opt
g forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> Opt -> StateT DefaultsState m Opt
f forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> forall (m :: * -> *).
(PandocMonad m, MonadIO m) =>
Opt -> StateT DefaultsState m Opt
resolveVarsInOpt
Maybe Value
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Opt -> StateT DefaultsState m Opt
f forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> forall (m :: * -> *).
(PandocMonad m, MonadIO m) =>
Opt -> StateT DefaultsState m Opt
resolveVarsInOpt
parseJSON Value
_ = forall (m :: * -> *) a. MonadFail m => FilePath -> m a
fail FilePath
"Expected a mapping"
resolveVarsInOpt :: forall m. (PandocMonad m, MonadIO m)
=> Opt -> StateT DefaultsState m Opt
resolveVarsInOpt :: forall (m :: * -> *).
(PandocMonad m, MonadIO m) =>
Opt -> StateT DefaultsState m Opt
resolveVarsInOpt
opt :: Opt
opt@Opt
{ optTemplate :: Opt -> Maybe FilePath
optTemplate = Maybe FilePath
oTemplate
, optMetadataFiles :: Opt -> [FilePath]
optMetadataFiles = [FilePath]
oMetadataFiles
, optOutputFile :: Opt -> Maybe FilePath
optOutputFile = Maybe FilePath
oOutputFile
, optInputFiles :: Opt -> Maybe [FilePath]
optInputFiles = Maybe [FilePath]
oInputFiles
, optSyntaxDefinitions :: Opt -> [FilePath]
optSyntaxDefinitions = [FilePath]
oSyntaxDefinitions
, optAbbreviations :: Opt -> Maybe FilePath
optAbbreviations = Maybe FilePath
oAbbreviations
, optReferenceDoc :: Opt -> Maybe FilePath
optReferenceDoc = Maybe FilePath
oReferenceDoc
, optEpubMetadata :: Opt -> Maybe FilePath
optEpubMetadata = Maybe FilePath
oEpubMetadata
, optEpubFonts :: Opt -> [FilePath]
optEpubFonts = [FilePath]
oEpubFonts
, optEpubCoverImage :: Opt -> Maybe FilePath
optEpubCoverImage = Maybe FilePath
oEpubCoverImage
, optLogFile :: Opt -> Maybe FilePath
optLogFile = Maybe FilePath
oLogFile
, optFilters :: Opt -> [Filter]
optFilters = [Filter]
oFilters
, optDataDir :: Opt -> Maybe FilePath
optDataDir = Maybe FilePath
oDataDir
, optExtractMedia :: Opt -> Maybe FilePath
optExtractMedia = Maybe FilePath
oExtractMedia
, optCss :: Opt -> [FilePath]
optCss = [FilePath]
oCss
, optIncludeBeforeBody :: Opt -> [FilePath]
optIncludeBeforeBody = [FilePath]
oIncludeBeforeBody
, optIncludeAfterBody :: Opt -> [FilePath]
optIncludeAfterBody = [FilePath]
oIncludeAfterBody
, optIncludeInHeader :: Opt -> [FilePath]
optIncludeInHeader = [FilePath]
oIncludeInHeader
, optResourcePath :: Opt -> [FilePath]
optResourcePath = [FilePath]
oResourcePath
, optCSL :: Opt -> Maybe FilePath
optCSL = Maybe FilePath
oCSL
, optBibliography :: Opt -> [FilePath]
optBibliography = [FilePath]
oBibliography
, optCitationAbbreviations :: Opt -> Maybe FilePath
optCitationAbbreviations = Maybe FilePath
oCitationAbbreviations
, optPdfEngine :: Opt -> Maybe FilePath
optPdfEngine = Maybe FilePath
oPdfEngine
, optHighlightStyle :: Opt -> Maybe Text
optHighlightStyle = Maybe Text
oHighlightStyle
}
= do
Maybe FilePath
oTemplate' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars Maybe FilePath
oTemplate
[FilePath]
oMetadataFiles' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars [FilePath]
oMetadataFiles
Maybe FilePath
oOutputFile' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars Maybe FilePath
oOutputFile
Maybe [FilePath]
oInputFiles' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars) Maybe [FilePath]
oInputFiles
[FilePath]
oSyntaxDefinitions' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars [FilePath]
oSyntaxDefinitions
Maybe FilePath
oAbbreviations' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars Maybe FilePath
oAbbreviations
Maybe FilePath
oReferenceDoc' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars Maybe FilePath
oReferenceDoc
Maybe FilePath
oEpubMetadata' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars Maybe FilePath
oEpubMetadata
[FilePath]
oEpubFonts' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars [FilePath]
oEpubFonts
Maybe FilePath
oEpubCoverImage' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars Maybe FilePath
oEpubCoverImage
Maybe FilePath
oLogFile' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars Maybe FilePath
oLogFile
[Filter]
oFilters' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Filter -> StateT DefaultsState m Filter
resolveVarsInFilter [Filter]
oFilters
Maybe FilePath
oDataDir' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars Maybe FilePath
oDataDir
Maybe FilePath
oExtractMedia' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars Maybe FilePath
oExtractMedia
[FilePath]
oCss' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars [FilePath]
oCss
[FilePath]
oIncludeBeforeBody' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars [FilePath]
oIncludeBeforeBody
[FilePath]
oIncludeAfterBody' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars [FilePath]
oIncludeAfterBody
[FilePath]
oIncludeInHeader' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars [FilePath]
oIncludeInHeader
[FilePath]
oResourcePath' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars [FilePath]
oResourcePath
Maybe FilePath
oCSL' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars Maybe FilePath
oCSL
[FilePath]
oBibliography' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars [FilePath]
oBibliography
Maybe FilePath
oCitationAbbreviations' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars Maybe FilePath
oCitationAbbreviations
Maybe FilePath
oPdfEngine' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars Maybe FilePath
oPdfEngine
Maybe Text
oHighlightStyle' <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap FilePath -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> StateT DefaultsState m FilePath
resolveVars forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> FilePath
T.unpack) Maybe Text
oHighlightStyle
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optTemplate :: Maybe FilePath
optTemplate = Maybe FilePath
oTemplate'
, optMetadataFiles :: [FilePath]
optMetadataFiles = [FilePath]
oMetadataFiles'
, optOutputFile :: Maybe FilePath
optOutputFile = Maybe FilePath
oOutputFile'
, optInputFiles :: Maybe [FilePath]
optInputFiles = Maybe [FilePath]
oInputFiles'
, optSyntaxDefinitions :: [FilePath]
optSyntaxDefinitions = [FilePath]
oSyntaxDefinitions'
, optAbbreviations :: Maybe FilePath
optAbbreviations = Maybe FilePath
oAbbreviations'
, optReferenceDoc :: Maybe FilePath
optReferenceDoc = Maybe FilePath
oReferenceDoc'
, optEpubMetadata :: Maybe FilePath
optEpubMetadata = Maybe FilePath
oEpubMetadata'
, optEpubFonts :: [FilePath]
optEpubFonts = [FilePath]
oEpubFonts'
, optEpubCoverImage :: Maybe FilePath
optEpubCoverImage = Maybe FilePath
oEpubCoverImage'
, optLogFile :: Maybe FilePath
optLogFile = Maybe FilePath
oLogFile'
, optFilters :: [Filter]
optFilters = [Filter]
oFilters'
, optDataDir :: Maybe FilePath
optDataDir = Maybe FilePath
oDataDir'
, optExtractMedia :: Maybe FilePath
optExtractMedia = Maybe FilePath
oExtractMedia'
, optCss :: [FilePath]
optCss = [FilePath]
oCss'
, optIncludeBeforeBody :: [FilePath]
optIncludeBeforeBody = [FilePath]
oIncludeBeforeBody'
, optIncludeAfterBody :: [FilePath]
optIncludeAfterBody = [FilePath]
oIncludeAfterBody'
, optIncludeInHeader :: [FilePath]
optIncludeInHeader = [FilePath]
oIncludeInHeader'
, optResourcePath :: [FilePath]
optResourcePath = [FilePath]
oResourcePath'
, optCSL :: Maybe FilePath
optCSL = Maybe FilePath
oCSL'
, optBibliography :: [FilePath]
optBibliography = [FilePath]
oBibliography'
, optCitationAbbreviations :: Maybe FilePath
optCitationAbbreviations = Maybe FilePath
oCitationAbbreviations'
, optPdfEngine :: Maybe FilePath
optPdfEngine = Maybe FilePath
oPdfEngine'
, optHighlightStyle :: Maybe Text
optHighlightStyle = Maybe Text
oHighlightStyle'
}
where
resolveVars :: FilePath -> StateT DefaultsState m FilePath
resolveVars :: FilePath -> StateT DefaultsState m FilePath
resolveVars [] = forall (m :: * -> *) a. Monad m => a -> m a
return []
resolveVars (Char
'$':Char
'{':FilePath
xs) =
let (FilePath
ys, FilePath
zs) = forall a. (a -> Bool) -> [a] -> ([a], [a])
break (forall a. Eq a => a -> a -> Bool
==Char
'}') FilePath
xs
in if forall (t :: * -> *) a. Foldable t => t a -> Bool
null FilePath
zs
then forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Char
'$'forall a. a -> [a] -> [a]
:Char
'{'forall a. a -> [a] -> [a]
:FilePath
xs
else do
FilePath
val <- FilePath -> StateT DefaultsState m FilePath
lookupEnv' FilePath
ys
(FilePath
val forall a. [a] -> [a] -> [a]
++) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FilePath -> StateT DefaultsState m FilePath
resolveVars (forall a. Int -> [a] -> [a]
drop Int
1 FilePath
zs)
resolveVars (Char
c:FilePath
cs) = (Char
cforall a. a -> [a] -> [a]
:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FilePath -> StateT DefaultsState m FilePath
resolveVars FilePath
cs
lookupEnv' :: String -> StateT DefaultsState m String
lookupEnv' :: FilePath -> StateT DefaultsState m FilePath
lookupEnv' FilePath
"." = do
Maybe FilePath
mbCurDefaults <- forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets DefaultsState -> Maybe FilePath
curDefaults
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall (m :: * -> *) a. Monad m => a -> m a
return FilePath
"")
(forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShowS
takeDirectory forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> IO FilePath
canonicalizePath)
Maybe FilePath
mbCurDefaults
lookupEnv' FilePath
"USERDATA" = do
Maybe FilePath
mbodatadir <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FilePath -> StateT DefaultsState m FilePath
resolveVars Maybe FilePath
oDataDir
Maybe FilePath
mbdatadir <- forall (m :: * -> *). PandocMonad m => m (Maybe FilePath)
getUserDataDir
FilePath
defdatadir <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO FilePath
defaultUserDataDir
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a -> a
fromMaybe FilePath
defdatadir (Maybe FilePath
mbodatadir forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe FilePath
mbdatadir)
lookupEnv' FilePath
v = do
Maybe FilePath
mbval <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> FilePath
T.unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => Text -> m (Maybe Text)
lookupEnv (FilePath -> Text
T.pack FilePath
v)
case Maybe FilePath
mbval of
Maybe FilePath
Nothing -> do
forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
report forall a b. (a -> b) -> a -> b
$ Text -> LogMessage
EnvironmentVariableUndefined (FilePath -> Text
T.pack FilePath
v)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty
Just FilePath
x -> forall (m :: * -> *) a. Monad m => a -> m a
return FilePath
x
resolveVarsInFilter :: Filter -> StateT DefaultsState m Filter
resolveVarsInFilter (JSONFilter FilePath
fp) =
FilePath -> Filter
JSONFilter forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FilePath -> StateT DefaultsState m FilePath
resolveVars FilePath
fp
resolveVarsInFilter (LuaFilter FilePath
fp) =
FilePath -> Filter
LuaFilter forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FilePath -> StateT DefaultsState m FilePath
resolveVars FilePath
fp
resolveVarsInFilter Filter
CiteprocFilter = forall (m :: * -> *) a. Monad m => a -> m a
return Filter
CiteprocFilter
parseDefaults :: (PandocMonad m, MonadIO m)
=> Value
-> Maybe FilePath
-> Parser (Opt -> StateT DefaultsState m Opt)
parseDefaults :: forall (m :: * -> *).
(PandocMonad m, MonadIO m) =>
Value
-> Maybe FilePath -> Parser (Opt -> StateT DefaultsState m Opt)
parseDefaults Value
n Maybe FilePath
dataDir = Value -> Parser [FilePath]
parseDefsNames Value
n forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[FilePath]
ds -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ \Opt
o -> do
FilePath
defsParent <- forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a -> a
fromMaybe FilePath
"" forall b c a. (b -> c) -> (a -> b) -> a -> c
. DefaultsState -> Maybe FilePath
curDefaults
[FilePath]
defsChildren <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (m :: * -> *).
(PandocMonad m, MonadIO m) =>
Maybe FilePath -> FilePath -> m FilePath
fullDefaultsPath Maybe FilePath
dataDir) [FilePath]
ds
[[FilePath]]
defsGraph <- forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
gets DefaultsState -> [[FilePath]]
inheritanceGraph
let defsGraphExp :: [[FilePath]]
defsGraphExp = forall a. Ord a => [[a]] -> [a] -> a -> [[a]]
expand [[FilePath]]
defsGraph [FilePath]
defsChildren FilePath
defsParent
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall a b. (a -> b) -> a -> b
$ \DefaultsState
defsState -> DefaultsState
defsState{ inheritanceGraph :: [[FilePath]]
inheritanceGraph = [[FilePath]]
defsGraphExp }
if forall a. Ord a => [[a]] -> Bool
cyclic [[FilePath]]
defsGraphExp
then forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError forall a b. (a -> b) -> a -> b
$
Text -> PandocError
PandocSomeError forall a b. (a -> b) -> a -> b
$ FilePath -> Text
T.pack forall a b. (a -> b) -> a -> b
$
FilePath
"Error: Circular defaults file reference in " forall a. [a] -> [a] -> [a]
++
FilePath
"'" forall a. [a] -> [a] -> [a]
++ FilePath
defsParent forall a. [a] -> [a] -> [a]
++ FilePath
"'"
else forall (t :: * -> *) (m :: * -> *) b a.
(Foldable t, Monad m) =>
(b -> a -> m b) -> b -> t a -> m b
foldM forall (m :: * -> *).
(PandocMonad m, MonadIO m) =>
Opt -> FilePath -> StateT DefaultsState m Opt
applyDefaults Opt
o [FilePath]
defsChildren
where parseDefsNames :: Value -> Parser [FilePath]
parseDefsNames Value
x = (forall a. FromJSON a => Value -> Parser a
parseJSON Value
x forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
xs -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
xs)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (forall a. FromJSON a => Value -> Parser a
parseJSON Value
x forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x' -> forall (m :: * -> *) a. Monad m => a -> m a
return [Text -> FilePath
unpack Text
x'])
parseOptions :: Monad m
=> [(Text, Value)]
-> Parser (Opt -> StateT DefaultsState m Opt)
parseOptions :: forall (m :: * -> *).
Monad m =>
[(Text, Value)] -> Parser (Opt -> StateT DefaultsState m Opt)
parseOptions [(Text, Value)]
ns = do
Opt -> Opt
f <- forall (m :: * -> *) a b.
Monad m =>
(a -> m (b -> b)) -> [a] -> m (b -> b)
chain (Text, Value) -> Parser (Opt -> Opt)
doOpt' [(Text, Value)]
ns
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. Opt -> Opt
f
chain :: Monad m => (a -> m (b -> b)) -> [a] -> m (b -> b)
chain :: forall (m :: * -> *) a b.
Monad m =>
(a -> m (b -> b)) -> [a] -> m (b -> b)
chain a -> m (b -> b)
f = forall (t :: * -> *) (m :: * -> *) b a.
(Foldable t, Monad m) =>
(b -> a -> m b) -> b -> t a -> m b
foldM forall {a}. (a -> b) -> a -> m (a -> b)
g forall a. a -> a
id
where g :: (a -> b) -> a -> m (a -> b)
g a -> b
o a
n = a -> m (b -> b)
f a
n forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \b -> b
o' -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ b -> b
o' forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> b
o
doOpt' :: (Text, Value) -> Parser (Opt -> Opt)
doOpt' :: (Text, Value) -> Parser (Opt -> Opt)
doOpt' (Text
k,Value
v) = do
case Text
k of
Text
"defaults" -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. a -> a
id
Text
_ -> (Text, Value) -> Parser (Opt -> Opt)
doOpt (Text
k,Value
v)
doOpt :: (Text, Value) -> Parser (Opt -> Opt)
doOpt :: (Text, Value) -> Parser (Opt -> Opt)
doOpt (Text
k,Value
v) = do
case Text
k of
Text
"tab-stop" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optTabStop :: Int
optTabStop = Int
x })
Text
"preserve-tabs" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optPreserveTabs :: Bool
optPreserveTabs = Bool
x })
Text
"standalone" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optStandalone :: Bool
optStandalone = Bool
x })
Text
"table-of-contents" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optTableOfContents :: Bool
optTableOfContents = Bool
x })
Text
"toc" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optTableOfContents :: Bool
optTableOfContents = Bool
x })
Text
"from" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optFrom :: Maybe Text
optFrom = Maybe Text
x })
Text
"reader" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optFrom :: Maybe Text
optFrom = Maybe Text
x })
Text
"to" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optTo :: Maybe Text
optTo = Maybe Text
x })
Text
"writer" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optTo :: Maybe Text
optTo = Maybe Text
x })
Text
"shift-heading-level-by" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optShiftHeadingLevelBy :: Int
optShiftHeadingLevelBy = Int
x })
Text
"template" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optTemplate :: Maybe FilePath
optTemplate = Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
x })
Text
"variables" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Context Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optVariables :: Context Text
optVariables =
Context Text
x forall a. Semigroup a => a -> a -> a
<> Opt -> Context Text
optVariables Opt
o })
Text
"metadata" ->
Value -> Parser Meta
yamlToMeta Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Meta
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optMetadata :: Meta
optMetadata = Opt -> Meta
optMetadata Opt
o forall a. Semigroup a => a -> a -> a
<> Meta
x })
Text
"metadata-files" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optMetadataFiles :: [FilePath]
optMetadataFiles =
Opt -> [FilePath]
optMetadataFiles Opt
o forall a. Semigroup a => a -> a -> a
<>
forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
x })
Text
"metadata-file" ->
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optMetadataFiles :: [FilePath]
optMetadataFiles =
Opt -> [FilePath]
optMetadataFiles Opt
o forall a. Semigroup a => a -> a -> a
<>
forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
x }))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optMetadataFiles :: [FilePath]
optMetadataFiles =
Opt -> [FilePath]
optMetadataFiles Opt
o forall a. Semigroup a => a -> a -> a
<>[Text -> FilePath
unpack Text
x] }))
Text
"output-file" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optOutputFile :: Maybe FilePath
optOutputFile = Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
x })
Text
"input-files" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe [Text]
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optInputFiles :: Maybe [FilePath]
optInputFiles =
Opt -> Maybe [FilePath]
optInputFiles Opt
o forall a. Semigroup a => a -> a -> a
<>
(forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe [Text]
x) })
Text
"input-file" ->
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe [Text]
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optInputFiles :: Maybe [FilePath]
optInputFiles =
Opt -> Maybe [FilePath]
optInputFiles Opt
o forall a. Semigroup a => a -> a -> a
<>
(forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe [Text]
x) }))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optInputFiles :: Maybe [FilePath]
optInputFiles =
Opt -> Maybe [FilePath]
optInputFiles Opt
o forall a. Semigroup a => a -> a -> a
<>
((\Text
z -> [Text -> FilePath
unpack Text
z]) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
x)
}))
Text
"number-sections" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optNumberSections :: Bool
optNumberSections = Bool
x })
Text
"number-offset" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Int]
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optNumberOffset :: [Int]
optNumberOffset = [Int]
x })
Text
"section-divs" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optSectionDivs :: Bool
optSectionDivs = Bool
x })
Text
"incremental" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optIncremental :: Bool
optIncremental = Bool
x })
Text
"self-contained" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optSelfContained :: Bool
optSelfContained = Bool
x })
Text
"embed-resources" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optEmbedResources :: Bool
optEmbedResources = Bool
x })
Text
"html-q-tags" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optHtmlQTags :: Bool
optHtmlQTags = Bool
x })
Text
"highlight-style" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optHighlightStyle :: Maybe Text
optHighlightStyle = Maybe Text
x })
Text
"syntax-definition" ->
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optSyntaxDefinitions :: [FilePath]
optSyntaxDefinitions =
Opt -> [FilePath]
optSyntaxDefinitions Opt
o forall a. Semigroup a => a -> a -> a
<> forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
x }))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optSyntaxDefinitions :: [FilePath]
optSyntaxDefinitions =
Opt -> [FilePath]
optSyntaxDefinitions Opt
o forall a. Semigroup a => a -> a -> a
<> [Text -> FilePath
unpack Text
x] }))
Text
"syntax-definitions" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optSyntaxDefinitions :: [FilePath]
optSyntaxDefinitions =
Opt -> [FilePath]
optSyntaxDefinitions Opt
o forall a. Semigroup a => a -> a -> a
<> forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
x })
Text
"top-level-division" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \TopLevelDivision
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optTopLevelDivision :: TopLevelDivision
optTopLevelDivision = TopLevelDivision
x })
Text
"html-math-method" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \HTMLMathMethod
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optHTMLMathMethod :: HTMLMathMethod
optHTMLMathMethod = HTMLMathMethod
x })
Text
"abbreviations" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optAbbreviations :: Maybe FilePath
optAbbreviations = Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
x })
Text
"reference-doc" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optReferenceDoc :: Maybe FilePath
optReferenceDoc = Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
x })
Text
"epub-subdirectory" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optEpubSubdirectory :: FilePath
optEpubSubdirectory = Text -> FilePath
unpack Text
x })
Text
"epub-metadata" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optEpubMetadata :: Maybe FilePath
optEpubMetadata = Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
x })
Text
"epub-fonts" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optEpubFonts :: [FilePath]
optEpubFonts = Opt -> [FilePath]
optEpubFonts Opt
o forall a. Semigroup a => a -> a -> a
<>
forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
x })
Text
"epub-chapter-level" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optSplitLevel :: Int
optSplitLevel = Int
x })
Text
"split-level" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optSplitLevel :: Int
optSplitLevel = Int
x })
Text
"chunk-template" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optChunkTemplate :: Maybe Text
optChunkTemplate = forall a. a -> Maybe a
Just Text
x })
Text
"epub-cover-image" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optEpubCoverImage :: Maybe FilePath
optEpubCoverImage = Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
x })
Text
"epub-title-page" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optEpubTitlePage :: Bool
optEpubTitlePage = Bool
x })
Text
"toc-depth" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optTOCDepth :: Int
optTOCDepth = Int
x })
Text
"dump-args" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optDumpArgs :: Bool
optDumpArgs = Bool
x })
Text
"ignore-args" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optIgnoreArgs :: Bool
optIgnoreArgs = Bool
x })
Text
"verbosity" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Verbosity
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optVerbosity :: Verbosity
optVerbosity = Verbosity
x })
Text
"trace" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optTrace :: Bool
optTrace = Bool
x })
Text
"log-file" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optLogFile :: Maybe FilePath
optLogFile = Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
x })
Text
"fail-if-warnings" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optFailIfWarnings :: Bool
optFailIfWarnings = Bool
x })
Text
"reference-links" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optReferenceLinks :: Bool
optReferenceLinks = Bool
x })
Text
"reference-location" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ReferenceLocation
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optReferenceLocation :: ReferenceLocation
optReferenceLocation = ReferenceLocation
x })
Text
"dpi" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optDpi :: Int
optDpi = Int
x })
Text
"wrap" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \WrapOption
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optWrap :: WrapOption
optWrap = WrapOption
x })
Text
"columns" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optColumns :: Int
optColumns = Int
x })
Text
"filters" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Filter]
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optFilters :: [Filter]
optFilters = Opt -> [Filter]
optFilters Opt
o forall a. Semigroup a => a -> a -> a
<> [Filter]
x })
Text
"citeproc" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x ->
if Bool
x
then forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optFilters :: [Filter]
optFilters = Filter
CiteprocFilter forall a. a -> [a] -> [a]
: Opt -> [Filter]
optFilters Opt
o })
else forall (m :: * -> *) a. Monad m => a -> m a
return forall a. a -> a
id
Text
"email-obfuscation" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ObfuscationMethod
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optEmailObfuscation :: ObfuscationMethod
optEmailObfuscation = ObfuscationMethod
x })
Text
"identifier-prefix" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optIdentifierPrefix :: Text
optIdentifierPrefix = Text
x })
Text
"indented-code-classes" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optIndentedCodeClasses :: [Text]
optIndentedCodeClasses = [Text]
x })
Text
"data-dir" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optDataDir :: Maybe FilePath
optDataDir = Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
x })
Text
"cite-method" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CiteMethod
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optCiteMethod :: CiteMethod
optCiteMethod = CiteMethod
x })
Text
"listings" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optListings :: Bool
optListings = Bool
x })
Text
"pdf-engine" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optPdfEngine :: Maybe FilePath
optPdfEngine = Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
x })
Text
"pdf-engine-opts" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optPdfEngineOpts :: [FilePath]
optPdfEngineOpts = forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
x })
Text
"pdf-engine-opt" ->
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optPdfEngineOpts :: [FilePath]
optPdfEngineOpts = forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
x }))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optPdfEngineOpts :: [FilePath]
optPdfEngineOpts = [Text -> FilePath
unpack Text
x] }))
Text
"slide-level" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Int
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optSlideLevel :: Maybe Int
optSlideLevel = Maybe Int
x })
Text
"markdown-headings" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o ->
case Text -> Text
T.toLower Text
x of
Text
"atx" -> Opt
o{ optSetextHeaders :: Bool
optSetextHeaders = Bool
False }
Text
"setext" -> Opt
o{ optSetextHeaders :: Bool
optSetextHeaders = Bool
True }
Text
_ -> Opt
o)
Text
"list-tables" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optListTables :: Bool
optListTables = Bool
x })
Text
"ascii" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optAscii :: Bool
optAscii = Bool
x })
Text
"default-image-extension" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optDefaultImageExtension :: Text
optDefaultImageExtension = Text
x })
Text
"extract-media" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optExtractMedia :: Maybe FilePath
optExtractMedia = Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
x })
Text
"track-changes" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \TrackChanges
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optTrackChanges :: TrackChanges
optTrackChanges = TrackChanges
x })
Text
"file-scope" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optFileScope :: Bool
optFileScope = Bool
x })
Text
"title-prefix" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optTitlePrefix :: Maybe Text
optTitlePrefix = Maybe Text
x,
optStandalone :: Bool
optStandalone = Bool
True })
Text
"css" ->
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optCss :: [FilePath]
optCss = Opt -> [FilePath]
optCss Opt
o forall a. Semigroup a => a -> a -> a
<>
forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
x }))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optCss :: [FilePath]
optCss = Opt -> [FilePath]
optCss Opt
o forall a. Semigroup a => a -> a -> a
<>
[Text -> FilePath
unpack Text
x] }))
Text
"bibliography" ->
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o ->
Opt
o{ optBibliography :: [FilePath]
optBibliography = Opt -> [FilePath]
optBibliography Opt
o forall a. Semigroup a => a -> a -> a
<>
forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
x }))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o ->
Opt
o{ optBibliography :: [FilePath]
optBibliography = Opt -> [FilePath]
optBibliography Opt
o forall a. Semigroup a => a -> a -> a
<>
[Text -> FilePath
unpack Text
x] }))
Text
"csl" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optCSL :: Maybe FilePath
optCSL = Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
x })
Text
"citation-abbreviations" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Maybe Text
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optCitationAbbreviations :: Maybe FilePath
optCitationAbbreviations =
Text -> FilePath
unpack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
x })
Text
"ipynb-output" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \IpynbOutput
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optIpynbOutput :: IpynbOutput
optIpynbOutput = IpynbOutput
x })
Text
"include-before-body" ->
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optIncludeBeforeBody :: [FilePath]
optIncludeBeforeBody =
Opt -> [FilePath]
optIncludeBeforeBody Opt
o forall a. Semigroup a => a -> a -> a
<> forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
x }))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optIncludeBeforeBody :: [FilePath]
optIncludeBeforeBody =
Opt -> [FilePath]
optIncludeBeforeBody Opt
o forall a. Semigroup a => a -> a -> a
<> [Text -> FilePath
unpack Text
x] }))
Text
"include-after-body" ->
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optIncludeAfterBody :: [FilePath]
optIncludeAfterBody =
Opt -> [FilePath]
optIncludeAfterBody Opt
o forall a. Semigroup a => a -> a -> a
<> forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
x }))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optIncludeAfterBody :: [FilePath]
optIncludeAfterBody =
Opt -> [FilePath]
optIncludeAfterBody Opt
o forall a. Semigroup a => a -> a -> a
<> [Text -> FilePath
unpack Text
x] }))
Text
"include-in-header" ->
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optIncludeInHeader :: [FilePath]
optIncludeInHeader =
Opt -> [FilePath]
optIncludeInHeader Opt
o forall a. Semigroup a => a -> a -> a
<> forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
x }))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Text
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optIncludeInHeader :: [FilePath]
optIncludeInHeader =
Opt -> [FilePath]
optIncludeInHeader Opt
o forall a. Semigroup a => a -> a -> a
<> [Text -> FilePath
unpack Text
x] }))
Text
"resource-path" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Text]
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optResourcePath :: [FilePath]
optResourcePath = forall a b. (a -> b) -> [a] -> [b]
map Text -> FilePath
unpack [Text]
x forall a. Semigroup a => a -> a -> a
<>
Opt -> [FilePath]
optResourcePath Opt
o })
Text
"request-headers" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[(Text, Text)]
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optRequestHeaders :: [(Text, Text)]
optRequestHeaders = [(Text, Text)]
x })
Text
"no-check-certificate" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x ->
forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optNoCheckCertificate :: Bool
optNoCheckCertificate = Bool
x })
Text
"eol" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \LineEnding
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o{ optEol :: LineEnding
optEol = LineEnding
x })
Text
"strip-comments" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o { optStripComments :: Bool
optStripComments = Bool
x })
Text
"sandbox" ->
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Bool
x -> forall (m :: * -> *) a. Monad m => a -> m a
return (\Opt
o -> Opt
o { optSandbox :: Bool
optSandbox = Bool
x })
Text
_ -> forall (m :: * -> *) a. MonadFail m => FilePath -> m a
fail forall a b. (a -> b) -> a -> b
$ FilePath
"Unknown option " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> FilePath
show Text
k
defaultOpts :: Opt
defaultOpts :: Opt
defaultOpts = Opt
{ optTabStop :: Int
optTabStop = Int
4
, optPreserveTabs :: Bool
optPreserveTabs = Bool
False
, optStandalone :: Bool
optStandalone = Bool
False
, optFrom :: Maybe Text
optFrom = forall a. Maybe a
Nothing
, optTo :: Maybe Text
optTo = forall a. Maybe a
Nothing
, optTableOfContents :: Bool
optTableOfContents = Bool
False
, optShiftHeadingLevelBy :: Int
optShiftHeadingLevelBy = Int
0
, optTemplate :: Maybe FilePath
optTemplate = forall a. Maybe a
Nothing
, optVariables :: Context Text
optVariables = forall a. Monoid a => a
mempty
, optMetadata :: Meta
optMetadata = forall a. Monoid a => a
mempty
, optMetadataFiles :: [FilePath]
optMetadataFiles = []
, optOutputFile :: Maybe FilePath
optOutputFile = forall a. Maybe a
Nothing
, optInputFiles :: Maybe [FilePath]
optInputFiles = forall a. Maybe a
Nothing
, optNumberSections :: Bool
optNumberSections = Bool
False
, optNumberOffset :: [Int]
optNumberOffset = [Int
0,Int
0,Int
0,Int
0,Int
0,Int
0]
, optSectionDivs :: Bool
optSectionDivs = Bool
False
, optIncremental :: Bool
optIncremental = Bool
False
, optSelfContained :: Bool
optSelfContained = Bool
False
, optEmbedResources :: Bool
optEmbedResources = Bool
False
, optHtmlQTags :: Bool
optHtmlQTags = Bool
False
, optHighlightStyle :: Maybe Text
optHighlightStyle = forall a. a -> Maybe a
Just Text
"pygments"
, optSyntaxDefinitions :: [FilePath]
optSyntaxDefinitions = []
, optTopLevelDivision :: TopLevelDivision
optTopLevelDivision = TopLevelDivision
TopLevelDefault
, optHTMLMathMethod :: HTMLMathMethod
optHTMLMathMethod = HTMLMathMethod
PlainMath
, optAbbreviations :: Maybe FilePath
optAbbreviations = forall a. Maybe a
Nothing
, optReferenceDoc :: Maybe FilePath
optReferenceDoc = forall a. Maybe a
Nothing
, optSplitLevel :: Int
optSplitLevel = Int
1
, optChunkTemplate :: Maybe Text
optChunkTemplate = forall a. Maybe a
Nothing
, optEpubSubdirectory :: FilePath
optEpubSubdirectory = FilePath
"EPUB"
, optEpubMetadata :: Maybe FilePath
optEpubMetadata = forall a. Maybe a
Nothing
, optEpubFonts :: [FilePath]
optEpubFonts = []
, optEpubCoverImage :: Maybe FilePath
optEpubCoverImage = forall a. Maybe a
Nothing
, optEpubTitlePage :: Bool
optEpubTitlePage = Bool
True
, optTOCDepth :: Int
optTOCDepth = Int
3
, optDumpArgs :: Bool
optDumpArgs = Bool
False
, optIgnoreArgs :: Bool
optIgnoreArgs = Bool
False
, optVerbosity :: Verbosity
optVerbosity = Verbosity
WARNING
, optTrace :: Bool
optTrace = Bool
False
, optLogFile :: Maybe FilePath
optLogFile = forall a. Maybe a
Nothing
, optFailIfWarnings :: Bool
optFailIfWarnings = Bool
False
, optReferenceLinks :: Bool
optReferenceLinks = Bool
False
, optReferenceLocation :: ReferenceLocation
optReferenceLocation = ReferenceLocation
EndOfDocument
, optDpi :: Int
optDpi = Int
96
, optWrap :: WrapOption
optWrap = WrapOption
WrapAuto
, optColumns :: Int
optColumns = Int
72
, optFilters :: [Filter]
optFilters = []
, optEmailObfuscation :: ObfuscationMethod
optEmailObfuscation = ObfuscationMethod
NoObfuscation
, optIdentifierPrefix :: Text
optIdentifierPrefix = Text
""
, optIndentedCodeClasses :: [Text]
optIndentedCodeClasses = []
, optDataDir :: Maybe FilePath
optDataDir = forall a. Maybe a
Nothing
, optCiteMethod :: CiteMethod
optCiteMethod = CiteMethod
Citeproc
, optListings :: Bool
optListings = Bool
False
, optPdfEngine :: Maybe FilePath
optPdfEngine = forall a. Maybe a
Nothing
, optPdfEngineOpts :: [FilePath]
optPdfEngineOpts = []
, optSlideLevel :: Maybe Int
optSlideLevel = forall a. Maybe a
Nothing
, optSetextHeaders :: Bool
optSetextHeaders = Bool
False
, optListTables :: Bool
optListTables = Bool
False
, optAscii :: Bool
optAscii = Bool
False
, optDefaultImageExtension :: Text
optDefaultImageExtension = Text
""
, optExtractMedia :: Maybe FilePath
optExtractMedia = forall a. Maybe a
Nothing
, optTrackChanges :: TrackChanges
optTrackChanges = TrackChanges
AcceptChanges
, optFileScope :: Bool
optFileScope = Bool
False
, optTitlePrefix :: Maybe Text
optTitlePrefix = forall a. Maybe a
Nothing
, optCss :: [FilePath]
optCss = []
, optIpynbOutput :: IpynbOutput
optIpynbOutput = IpynbOutput
IpynbOutputBest
, optIncludeBeforeBody :: [FilePath]
optIncludeBeforeBody = []
, optIncludeAfterBody :: [FilePath]
optIncludeAfterBody = []
, optIncludeInHeader :: [FilePath]
optIncludeInHeader = []
, optResourcePath :: [FilePath]
optResourcePath = [FilePath
"."]
, optRequestHeaders :: [(Text, Text)]
optRequestHeaders = []
, optNoCheckCertificate :: Bool
optNoCheckCertificate = Bool
False
, optEol :: LineEnding
optEol = LineEnding
Native
, optStripComments :: Bool
optStripComments = Bool
False
, optCSL :: Maybe FilePath
optCSL = forall a. Maybe a
Nothing
, optBibliography :: [FilePath]
optBibliography = []
, optCitationAbbreviations :: Maybe FilePath
optCitationAbbreviations = forall a. Maybe a
Nothing
, optSandbox :: Bool
optSandbox = Bool
False
}
yamlToMeta :: Value -> Parser Meta
yamlToMeta :: Value -> Parser Meta
yamlToMeta (Object Object
o) =
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall (m :: * -> *) a. MonadFail m => FilePath -> m a
fail forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> FilePath
show) forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall {b}.
Default b =>
ParsecT
Sources ParserState PandocPure (Future b (Map Text MetaValue))
-> Either PandocError Meta
runEverything (forall (m :: * -> *) st.
(PandocMonad m, HasLastStrPosition st) =>
ParsecT Sources st m (Future st MetaValue)
-> Object -> ParsecT Sources st m (Future st (Map Text MetaValue))
yamlMap forall {st}.
ParsecT Sources st PandocPure (Future ParserState MetaValue)
pMetaString Object
o)
where
pMetaString :: ParsecT Sources st PandocPure (Future ParserState MetaValue)
pMetaString = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> MetaValue
MetaString forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
P.manyChar forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
P.anyChar
runEverything :: ParsecT
Sources ParserState PandocPure (Future b (Map Text MetaValue))
-> Either PandocError Meta
runEverything ParsecT
Sources ParserState PandocPure (Future b (Map Text MetaValue))
p =
forall a. PandocPure a -> Either PandocError a
runPure (forall (m :: * -> *) t st a.
(Monad m, ToSources t) =>
ParsecT Sources st m a -> st -> t -> m (Either PandocError a)
P.readWithM ParsecT
Sources ParserState PandocPure (Future b (Map Text MetaValue))
p (forall a. Default a => a
def :: P.ParserState) (Text
"" :: Text))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Map Text MetaValue -> Meta
Meta forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> b -> a -> c
flip forall s a. Future s a -> s -> a
P.runF forall a. Default a => a
def)
yamlToMeta Value
_ = forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty
applyDefaults :: (PandocMonad m, MonadIO m)
=> Opt
-> FilePath
-> StateT DefaultsState m Opt
applyDefaults :: forall (m :: * -> *).
(PandocMonad m, MonadIO m) =>
Opt -> FilePath -> StateT DefaultsState m Opt
applyDefaults Opt
opt FilePath
file = do
forall (m :: * -> *). PandocMonad m => Verbosity -> m ()
setVerbosity forall a b. (a -> b) -> a -> b
$ Opt -> Verbosity
optVerbosity Opt
opt
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify forall a b. (a -> b) -> a -> b
$ \DefaultsState
defsState -> DefaultsState
defsState{ curDefaults :: Maybe FilePath
curDefaults = forall a. a -> Maybe a
Just FilePath
file }
ByteString
inp <- forall (m :: * -> *). PandocMonad m => FilePath -> m ByteString
readFileStrict FilePath
file
case forall a. FromJSON a => ByteString -> Either ParseException a
decodeEither' ([ByteString] -> ByteString
B8.unlines forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
takeWhile (forall a. Eq a => a -> a -> Bool
/= ByteString
"...") forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> [ByteString]
B8.lines forall a b. (a -> b) -> a -> b
$ ByteString
inp) of
Right Opt -> StateT DefaultsState m Opt
f -> Opt -> StateT DefaultsState m Opt
f Opt
opt
Left ParseException
err' -> forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError forall a b. (a -> b) -> a -> b
$
Text -> PandocError
PandocParseError
forall a b. (a -> b) -> a -> b
$ FilePath -> Text
T.pack forall a b. (a -> b) -> a -> b
$ ParseException -> FilePath
Data.Yaml.prettyPrintParseException ParseException
err'
fullDefaultsPath :: (PandocMonad m, MonadIO m)
=> Maybe FilePath
-> FilePath
-> m FilePath
fullDefaultsPath :: forall (m :: * -> *).
(PandocMonad m, MonadIO m) =>
Maybe FilePath -> FilePath -> m FilePath
fullDefaultsPath Maybe FilePath
dataDir FilePath
file = do
let fp :: FilePath
fp = if forall (t :: * -> *) a. Foldable t => t a -> Bool
null (ShowS
takeExtension FilePath
file)
then FilePath -> ShowS
addExtension FilePath
file FilePath
"yaml"
else FilePath
file
FilePath
defaultDataDir <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO FilePath
defaultUserDataDir
let defaultFp :: FilePath
defaultFp = forall a. a -> Maybe a -> a
fromMaybe FilePath
defaultDataDir Maybe FilePath
dataDir FilePath -> ShowS
</> FilePath
"defaults" FilePath -> ShowS
</> FilePath
fp
Bool
fpExists <- forall (m :: * -> *). PandocMonad m => FilePath -> m Bool
fileExists FilePath
fp
if Bool
fpExists
then forall (m :: * -> *) a. Monad m => a -> m a
return FilePath
fp
else do
Bool
defaultFpExists <- forall (m :: * -> *). PandocMonad m => FilePath -> m Bool
fileExists FilePath
defaultFp
if Bool
defaultFpExists
then forall (m :: * -> *) a. Monad m => a -> m a
return FilePath
defaultFp
else forall (m :: * -> *) a. Monad m => a -> m a
return FilePath
fp
expand :: Ord a => [[a]] -> [a] -> a -> [[a]]
expand :: forall a. Ord a => [[a]] -> [a] -> a -> [[a]]
expand [] [a]
ns a
n = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\a
x -> a
x forall a. a -> [a] -> [a]
: [a
n]) [a]
ns
expand [[a]]
ps [a]
ns a
n = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (forall {a}. Eq a => a -> [a] -> [a] -> [[a]]
ext a
n [a]
ns) [[a]]
ps
where
ext :: a -> [a] -> [a] -> [[a]]
ext a
x [a]
xs [a]
p = case [a]
p of
(a
l : [a]
_) | a
x forall a. Eq a => a -> a -> Bool
== a
l -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. a -> [a] -> [a]
: [a]
p) [a]
xs
[a]
_ -> [[a]
p]
cyclic :: Ord a => [[a]] -> Bool
cyclic :: forall a. Ord a => [[a]] -> Bool
cyclic = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any forall {a}. Ord a => [a] -> Bool
hasDuplicate
where
hasDuplicate :: [a] -> Bool
hasDuplicate [a]
xs = forall (t :: * -> *) a. Foldable t => t a -> Int
length (forall a. Ord a => [a] -> [a]
nubOrd [a]
xs) forall a. Eq a => a -> a -> Bool
/= forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
xs