{-# LANGUAGE CPP #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-}
module Text.Pandoc.App.CommandLineOptions (
parseOptions
, parseOptionsFromArgs
, handleOptInfo
, options
, engines
, setVariable
) where
import Control.Monad.Trans
import Control.Monad.State.Strict
import Data.Containers.ListUtils (nubOrd)
import Data.Aeson.Encode.Pretty (encodePretty', Config(..), keyOrder,
defConfig, Indent(..), NumberFormat(..))
import Data.Bifunctor (second)
import Data.Char (toLower)
import Data.List (intercalate, sort, foldl')
#ifdef _WINDOWS
import Data.List (isPrefixOf)
#endif
import Data.Maybe (fromMaybe, isJust)
import Data.Text (Text)
import Safe (tailDef)
import Skylighting (Syntax (..), defaultSyntaxMap)
import System.Console.GetOpt
import System.Environment (getArgs, getProgName)
import System.Exit (exitSuccess)
import System.FilePath
import System.IO (stdout)
import Text.DocTemplates (Context (..), ToContext (toVal), Val (..))
import Text.Pandoc
import Text.Pandoc.Builder (setMeta)
import Text.Pandoc.App.Opt (Opt (..), LineEnding (..), IpynbOutput (..),
DefaultsState (..), applyDefaults,
fullDefaultsPath, OptInfo(..))
import Text.Pandoc.Filter (Filter (..))
import Text.Pandoc.Highlighting (highlightingStyles, lookupHighlightingStyle)
import Text.Pandoc.Scripting (ScriptingEngine (..), customTemplate)
import Text.Pandoc.Shared (safeStrRead)
import Text.Printf
import qualified Control.Exception as E
import Control.Monad.Except (ExceptT(..), runExceptT, throwError)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as B
import qualified Data.Map as M
import qualified Data.Set as Set
import qualified Data.Text as T
import qualified Text.Pandoc.UTF8 as UTF8
parseOptions :: [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
-> Opt -> IO (Either OptInfo Opt)
parseOptions :: [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
-> Opt -> IO (Either OptInfo Opt)
parseOptions [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
options' Opt
defaults = do
[String]
rawArgs <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO [String]
getArgs
String
prg <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO String
getProgName
[OptDescr (Opt -> ExceptT OptInfo IO Opt)]
-> Opt -> String -> [String] -> IO (Either OptInfo Opt)
parseOptionsFromArgs [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
options' Opt
defaults String
prg [String]
rawArgs
parseOptionsFromArgs
:: [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
-> Opt -> String -> [String] -> IO (Either OptInfo Opt)
parseOptionsFromArgs :: [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
-> Opt -> String -> [String] -> IO (Either OptInfo Opt)
parseOptionsFromArgs [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
options' Opt
defaults String
prg [String]
rawArgs = do
let ([Opt -> ExceptT OptInfo IO Opt]
actions, [String]
args, [String]
unrecognizedOpts, [String]
errors) =
forall a.
ArgOrder a
-> [OptDescr a] -> [String] -> ([a], [String], [String], [String])
getOpt' forall a. ArgOrder a
Permute [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
options' ([String] -> [String]
preprocessArgs [String]
rawArgs)
let unknownOptionErrors :: [String]
unknownOptionErrors =
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (String -> [String] -> [String]
handleUnrecognizedOption forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
takeWhile (forall a. Eq a => a -> a -> Bool
/= Char
'=')) []
[String]
unrecognizedOpts
let mbArgs :: Maybe [String]
mbArgs = case [String]
args of
[] -> forall a. Maybe a
Nothing
[String]
xs -> forall a. a -> Maybe a
Just [String]
xs
let adjustOpts :: Opt -> Opt
adjustOpts Opt
opts =
Opt
opts{ optInputFiles :: Maybe [String]
optInputFiles =
forall a b. (a -> b) -> [a] -> [b]
map String -> String
normalizePath forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Opt -> Maybe [String]
optInputFiles Opt
opts forall a. Semigroup a => a -> a -> a
<> Maybe [String]
mbArgs)
, optStandalone :: Bool
optStandalone =
Opt -> Bool
optStandalone Opt
opts Bool -> Bool -> Bool
||
forall a. Maybe a -> Bool
isJust (Opt -> Maybe String
optTemplate Opt
opts) Bool -> Bool -> Bool
||
Opt -> Bool
optSelfContained Opt
opts Bool -> Bool -> Bool
||
Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null (Opt -> [String]
optIncludeInHeader Opt
opts)) Bool -> Bool -> Bool
||
Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null (Opt -> [String]
optIncludeBeforeBody Opt
opts)) Bool -> Bool -> Bool
||
Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null (Opt -> [String]
optIncludeAfterBody Opt
opts)) }
if (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [String]
errors Bool -> Bool -> Bool
&& forall (t :: * -> *) a. Foldable t => t a -> Bool
null [String]
unknownOptionErrors)
then
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT forall a b. (a -> b) -> a -> b
$ Opt -> Opt
adjustOpts forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
(>>=) (forall (m :: * -> *) a. Monad m => a -> m a
return Opt
defaults) [Opt -> ExceptT OptInfo IO Opt]
actions)
else forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a b. a -> Either a b
Left forall a b. (a -> b) -> a -> b
$ PandocError -> OptInfo
OptError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall a b. (a -> b) -> a -> b
$
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String]
errors forall a. [a] -> [a] -> [a]
++ [String] -> String
unlines [String]
unknownOptionErrors forall a. [a] -> [a] -> [a]
++
(String
"Try " forall a. [a] -> [a] -> [a]
++ String
prg forall a. [a] -> [a] -> [a]
++ String
" --help for more information.")
handleOptInfo :: ScriptingEngine -> OptInfo -> IO ()
handleOptInfo :: ScriptingEngine -> OptInfo -> IO ()
handleOptInfo ScriptingEngine
engine OptInfo
info = forall e a. Exception e => (e -> IO a) -> IO a -> IO a
E.handle (forall a. Either PandocError a -> IO a
handleError forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. a -> Either a b
Left) forall a b. (a -> b) -> a -> b
$ do
case OptInfo
info of
OptInfo
BashCompletion -> do
[String]
datafiles <- IO [String]
getDataFileNames
String
tpl <- forall a. PandocIO a -> IO a
runIOorExplode forall a b. (a -> b) -> a -> b
$
ByteString -> String
UTF8.toString forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
forall (m :: * -> *). PandocMonad m => String -> m ByteString
readDefaultDataFile String
"bash_completion.tpl"
let optnames :: OptDescr a -> [String]
optnames (Option String
shorts [String]
longs ArgDescr a
_ String
_) =
forall a b. (a -> b) -> [a] -> [b]
map (\Char
c -> [Char
'-',Char
c]) String
shorts forall a. [a] -> [a] -> [a]
++
forall a b. (a -> b) -> [a] -> [b]
map (String
"--" forall a. [a] -> [a] -> [a]
++) [String]
longs
let allopts :: String
allopts = [String] -> String
unwords (forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall {a}. OptDescr a -> [String]
optnames [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
options)
Handle -> Text -> IO ()
UTF8.hPutStrLn Handle
stdout forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall a b. (a -> b) -> a -> b
$ forall r. PrintfType r => String -> r
printf String
tpl String
allopts
(Text -> String
T.unpack forall a b. (a -> b) -> a -> b
$ [Text] -> Text
T.unwords [Text]
readersNames)
(Text -> String
T.unpack forall a b. (a -> b) -> a -> b
$ [Text] -> Text
T.unwords [Text]
writersNames)
(Text -> String
T.unpack forall a b. (a -> b) -> a -> b
$ [Text] -> Text
T.unwords forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [(Text, Style)]
highlightingStyles)
([String] -> String
unwords [String]
datafiles)
OptInfo
ListInputFormats -> forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Handle -> Text -> IO ()
UTF8.hPutStrLn Handle
stdout) [Text]
readersNames
OptInfo
ListOutputFormats -> forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Handle -> Text -> IO ()
UTF8.hPutStrLn Handle
stdout) [Text]
writersNames
ListExtensions Maybe Text
mbfmt -> do
let formatName :: Text
formatName = forall a. a -> Maybe a -> a
fromMaybe Text
"markdown" Maybe Text
mbfmt
let allExts :: Extensions
allExts = Text -> Extensions
getAllExtensions Text
formatName
if Text
formatName forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem`
(forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst (forall (m :: * -> *). PandocMonad m => [(Text, Reader m)]
readers :: [(Text, Reader PandocPure)]) forall a. [a] -> [a] -> [a]
++
forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst (forall (m :: * -> *). PandocMonad m => [(Text, Writer m)]
writers :: [(Text, Writer PandocPure)]))
then forall e a. Exception e => e -> IO a
E.throwIO forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError forall a b. (a -> b) -> a -> b
$ Text
formatName forall a. Semigroup a => a -> a -> a
<>
Text
" is not a recognized reader or writer format"
else do
let defExts :: Extensions
defExts = Text -> Extensions
getDefaultExtensions Text
formatName
let showExt :: Extension -> String
showExt Extension
x =
(if Extension -> Extensions -> Bool
extensionEnabled Extension
x Extensions
defExts
then Char
'+'
else if Extension -> Extensions -> Bool
extensionEnabled Extension
x Extensions
allExts
then Char
'-'
else Char
' ') forall a. a -> [a] -> [a]
: forall a. Int -> [a] -> [a]
drop Int
4 (forall a. Show a => a -> String
show Extension
x)
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Handle -> Text -> IO ()
UTF8.hPutStrLn Handle
stdout forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. Extension -> String
showExt)
(Extensions -> [Extension]
extensionsToList Extensions
allExts)
OptInfo
ListHighlightLanguages -> do
let langs :: [String]
langs = [ Text -> String
T.unpack (Text -> Text
T.toLower (Syntax -> Text
sShortname Syntax
s))
| Syntax
s <- forall k a. Map k a -> [a]
M.elems SyntaxMap
defaultSyntaxMap
, Syntax -> Text
sShortname Syntax
s forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem`
[String -> Text
T.pack String
"Alert", String -> Text
T.pack String
"Alert_indent"]
]
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Handle -> Text -> IO ()
UTF8.hPutStrLn Handle
stdout forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack) (forall a. Ord a => [a] -> [a]
sort [String]
langs)
OptInfo
ListHighlightStyles -> do
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Handle -> Text -> IO ()
UTF8.hPutStrLn Handle
stdout forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst) [(Text, Style)]
highlightingStyles
PrintDefaultTemplate Maybe String
mbout Text
fmt -> do
let write :: Text -> IO ()
write = forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Handle -> Text -> IO ()
UTF8.hPutStr Handle
stdout) (String -> Text -> IO ()
UTF8.writeFile) Maybe String
mbout
Either PandocError Text
templ <- forall a. PandocIO a -> IO (Either PandocError a)
runIO forall a b. (a -> b) -> a -> b
$
case String -> (String, String)
splitExtension (Text -> String
T.unpack Text
fmt) of
(String
_, String
"") -> do
forall (m :: * -> *). PandocMonad m => Maybe String -> m ()
setUserDataDir forall a. Maybe a
Nothing
forall (m :: * -> *). PandocMonad m => Text -> m Text
getDefaultTemplate Text
fmt
(String, String)
_ -> do
CustomComponents PandocIO
components <- ScriptingEngine
-> forall (m :: * -> *).
(PandocMonad m, MonadIO m) =>
String -> m (CustomComponents m)
engineLoadCustom ScriptingEngine
engine (Text -> String
T.unpack Text
fmt)
case forall (m :: * -> *). CustomComponents m -> Maybe Text
customTemplate CustomComponents PandocIO
components of
Just Text
t -> forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
t
Maybe Text
Nothing -> forall a e. Exception e => e -> a
E.throw forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocNoTemplateError Text
fmt
case Either PandocError Text
templ of
Right Text
t
| Text -> Bool
T.null Text
t ->
forall e a. Exception e => e -> IO a
E.throwIO forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocCouldNotFindDataFileError forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack
(String
"templates/default." forall a. [a] -> [a] -> [a]
++ Text -> String
T.unpack Text
fmt)
| Bool
otherwise -> Text -> IO ()
write Text
t
Left PandocError
e -> forall e a. Exception e => e -> IO a
E.throwIO PandocError
e
PrintDefaultDataFile Maybe String
mbout Text
f -> do
let write :: ByteString -> IO ()
write = forall b a. b -> (a -> b) -> Maybe a -> b
maybe ByteString -> IO ()
BS.putStr String -> ByteString -> IO ()
BS.writeFile Maybe String
mbout
forall a. PandocIO a -> IO a
runIOorExplode forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). PandocMonad m => String -> m ByteString
readDefaultDataFile (Text -> String
T.unpack Text
f) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> IO ()
write
PrintHighlightStyle Maybe String
mbout Text
styleName -> do
let write :: ByteString -> IO ()
write = forall b a. b -> (a -> b) -> Maybe a -> b
maybe ByteString -> IO ()
B.putStr String -> ByteString -> IO ()
B.writeFile Maybe String
mbout
Style
sty <- forall a. PandocIO a -> IO a
runIOorExplode forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). PandocMonad m => String -> m Style
lookupHighlightingStyle (Text -> String
T.unpack Text
styleName)
ByteString -> IO ()
write forall a b. (a -> b) -> a -> b
$ forall a. ToJSON a => Config -> a -> ByteString
encodePretty'
Config
defConfig{confIndent :: Indent
confIndent = Int -> Indent
Spaces Int
4
,confCompare :: Text -> Text -> Ordering
confCompare = [Text] -> Text -> Text -> Ordering
keyOrder
(forall a b. (a -> b) -> [a] -> [b]
map String -> Text
T.pack
[String
"text-color"
,String
"background-color"
,String
"line-number-color"
,String
"line-number-background-color"
,String
"bold"
,String
"italic"
,String
"underline"
,String
"text-styles"])
,confNumFormat :: NumberFormat
confNumFormat = NumberFormat
Generic
,confTrailingNewline :: Bool
confTrailingNewline = Bool
True} Style
sty
OptInfo
VersionInfo -> do
String
prg <- IO String
getProgName
String
defaultDatadir <- IO String
defaultUserDataDir
Handle -> Text -> IO ()
UTF8.hPutStrLn Handle
stdout
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack
forall a b. (a -> b) -> a -> b
$ String
prg forall a. [a] -> [a] -> [a]
++ String
" " forall a. [a] -> [a] -> [a]
++ Text -> String
T.unpack Text
pandocVersionText forall a. [a] -> [a] -> [a]
++
String
compileInfo forall a. [a] -> [a] -> [a]
++
String
"\nUser data directory: " forall a. [a] -> [a] -> [a]
++ String
defaultDatadir forall a. [a] -> [a] -> [a]
++
(Char
'\n'forall a. a -> [a] -> [a]
:String
copyrightMessage)
OptInfo
Help -> do
String
prg <- IO String
getProgName
Handle -> Text -> IO ()
UTF8.hPutStr Handle
stdout (String -> Text
T.pack forall a b. (a -> b) -> a -> b
$ String -> [OptDescr (Opt -> ExceptT OptInfo IO Opt)] -> String
usageMessage String
prg [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
options)
OptError PandocError
e -> forall e a. Exception e => e -> IO a
E.throwIO PandocError
e
forall a. IO a
exitSuccess
latexEngines :: [String]
latexEngines :: [String]
latexEngines = [String
"pdflatex", String
"lualatex", String
"xelatex", String
"latexmk", String
"tectonic"]
htmlEngines :: [String]
htmlEngines :: [String]
htmlEngines = [String
"wkhtmltopdf", String
"weasyprint", String
"pagedjs-cli", String
"prince"]
engines :: [(Text, String)]
engines :: [(Text, String)]
engines = forall a b. (a -> b) -> [a] -> [b]
map (Text
"html",) [String]
htmlEngines forall a. [a] -> [a] -> [a]
++
forall a b. (a -> b) -> [a] -> [b]
map (Text
"html5",) [String]
htmlEngines forall a. [a] -> [a] -> [a]
++
forall a b. (a -> b) -> [a] -> [b]
map (Text
"latex",) [String]
latexEngines forall a. [a] -> [a] -> [a]
++
forall a b. (a -> b) -> [a] -> [b]
map (Text
"beamer",) [String]
latexEngines forall a. [a] -> [a] -> [a]
++
[ (Text
"ms", String
"pdfroff")
, (Text
"typst", String
"typst")
, (Text
"context", String
"context")
]
pdfEngines :: [String]
pdfEngines :: [String]
pdfEngines = forall a. Ord a => [a] -> [a]
nubOrd forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [(Text, String)]
engines
preprocessArgs :: [String] -> [String]
preprocessArgs :: [String] -> [String]
preprocessArgs [] = []
preprocessArgs (String
"--":[String]
xs) = String
"--" forall a. a -> [a] -> [a]
: [String]
xs
preprocessArgs ((Char
'-':Char
c:Char
d:String
cs):[String]
xs)
| Char -> Bool
isShortBooleanOpt Char
c
, case Char -> Char
toLower forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Char
dforall a. a -> [a] -> [a]
:String
cs) of
String
"true" -> Bool
True
String
"false" -> Bool
True
String
_ -> Bool
False
= (Char
'-'forall a. a -> [a] -> [a]
:Char
cforall a. a -> [a] -> [a]
:Char
dforall a. a -> [a] -> [a]
:String
cs) forall a. a -> [a] -> [a]
: [String] -> [String]
preprocessArgs [String]
xs
| Char -> Bool
isShortBooleanOpt Char
c
, Char -> Bool
isShortOpt Char
d = String -> [String]
splitArg (Char
cforall a. a -> [a] -> [a]
:Char
dforall a. a -> [a] -> [a]
:String
cs) forall a. [a] -> [a] -> [a]
++ [String] -> [String]
preprocessArgs [String]
xs
preprocessArgs (String
x:[String]
xs) = String
x forall a. a -> [a] -> [a]
: [String] -> [String]
preprocessArgs [String]
xs
isShortBooleanOpt :: Char -> Bool
isShortBooleanOpt :: Char -> Bool
isShortBooleanOpt = (forall a. Ord a => a -> Set a -> Bool
`Set.member` Set Char
shortBooleanOpts)
where
shortBooleanOpts :: Set Char
shortBooleanOpts =
forall a. Ord a => [a] -> Set a
Set.fromList [Char
c | Option [Char
c] [String]
_ (OptArg Maybe String -> Opt -> ExceptT OptInfo IO Opt
_ String
"true|false") String
_ <- [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
options]
isShortOpt :: Char -> Bool
isShortOpt :: Char -> Bool
isShortOpt = (forall a. Ord a => a -> Set a -> Bool
`Set.member` Set Char
shortOpts)
where
shortOpts :: Set Char
shortOpts = forall a. Ord a => [a] -> Set a
Set.fromList forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [String
cs | Option String
cs [String]
_ ArgDescr (Opt -> ExceptT OptInfo IO Opt)
_ String
_ <- [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
options]
splitArg :: String -> [String]
splitArg :: String -> [String]
splitArg (Char
c:Char
d:String
cs)
| Char -> Bool
isShortBooleanOpt Char
c
, Char -> Bool
isShortOpt Char
d
= [Char
'-',Char
c] forall a. a -> [a] -> [a]
: String -> [String]
splitArg (Char
dforall a. a -> [a] -> [a]
:String
cs)
splitArg (Char
c:String
cs) = [Char
'-'forall a. a -> [a] -> [a]
:Char
cforall a. a -> [a] -> [a]
:String
cs]
splitArg [] = []
options :: [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
options :: [OptDescr (Opt -> ExceptT OptInfo IO Opt)]
options =
[ forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"fr" [String
"from",String
"read"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optFrom :: Maybe Text
optFrom = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack String
arg })
String
"FORMAT")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"tw" [String
"to",String
"write"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optTo :: Maybe Text
optTo = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack String
arg })
String
"FORMAT")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"o" [String
"output"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optOutputFile :: Maybe String
optOutputFile =
forall a. a -> Maybe a
Just (String -> String
normalizePath String
arg) })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"data-dir"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optDataDir :: Maybe String
optDataDir =
forall a. a -> Maybe a
Just (String -> String
normalizePath String
arg) })
String
"DIRECTORY")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"M" [String
"metadata"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> do
let (String
key, String
val) = String -> (String, String)
splitField String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optMetadata :: Meta
optMetadata = String -> String -> Meta -> Meta
addMeta String
key String
val forall a b. (a -> b) -> a -> b
$
Opt -> Meta
optMetadata Opt
opt })
String
"KEY[:VALUE]")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"metadata-file"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optMetadataFiles :: [String]
optMetadataFiles =
Opt -> [String]
optMetadataFiles Opt
opt forall a. [a] -> [a] -> [a]
++ [String -> String
normalizePath String
arg] })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"d" [String
"defaults"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> do
Either PandocError Opt
res <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. PandocIO a -> IO (Either PandocError a)
runIO forall a b. (a -> b) -> a -> b
$ do
let defsState :: DefaultsState
defsState =
DefaultsState { curDefaults :: Maybe String
curDefaults = forall a. Maybe a
Nothing,
inheritanceGraph :: [[String]]
inheritanceGraph = [] }
String
fp <- forall (m :: * -> *).
(PandocMonad m, MonadIO m) =>
Maybe String -> String -> m String
fullDefaultsPath (Opt -> Maybe String
optDataDir Opt
opt) String
arg
forall (m :: * -> *) s a. Monad m => StateT s m a -> s -> m a
evalStateT (forall (m :: * -> *).
(PandocMonad m, MonadIO m) =>
Opt -> String -> StateT DefaultsState m Opt
applyDefaults Opt
opt String
fp) DefaultsState
defsState
case Either PandocError Opt
res of
Left PandocError
e -> forall a. PandocError -> ExceptT OptInfo IO a
optError PandocError
e
Right Opt
x -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
x
)
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"file-scope"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--file-scope" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optFileScope :: Bool
optFileScope = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"sandbox"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--sandbox" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optSandbox :: Bool
optSandbox = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"s" [String
"standalone"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--standalone/-s" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optStandalone :: Bool
optStandalone = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"template"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optTemplate :: Maybe String
optTemplate = forall a. a -> Maybe a
Just (String -> String
normalizePath String
arg) })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"V" [String
"variable"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> do
let (String
key, String
val) = String -> (String, String)
splitField String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optVariables :: Context Text
optVariables =
Text -> Text -> Context Text -> Context Text
setVariable (String -> Text
T.pack String
key) (String -> Text
T.pack String
val) forall a b. (a -> b) -> a -> b
$
Opt -> Context Text
optVariables Opt
opt })
String
"KEY[:VALUE]")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"wrap"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
case String
arg of
String
"auto" -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optWrap :: WrapOption
optWrap = WrapOption
WrapAuto }
String
"none" -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optWrap :: WrapOption
optWrap = WrapOption
WrapNone }
String
"preserve" -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optWrap :: WrapOption
optWrap = WrapOption
WrapPreserve }
String
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"--wrap must be auto, none, or preserve")
String
"auto|none|preserve")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"ascii"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--ascii" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optAscii :: Bool
optAscii = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"toc", String
"table-of-contents"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--toc/--table-of-contents" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optTableOfContents :: Bool
optTableOfContents = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"toc-depth"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
case forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
safeStrRead String
arg of
Just Int
t | Int
t forall a. Ord a => a -> a -> Bool
>= Int
1 Bool -> Bool -> Bool
&& Int
t forall a. Ord a => a -> a -> Bool
<= Int
6 ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optTOCDepth :: Int
optTOCDepth = Int
t }
Maybe Int
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"Argument of --toc-depth must be a number 1-6")
String
"NUMBER")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"N" [String
"number-sections"]
(forall a. a -> ArgDescr a
NoArg
(\Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optNumberSections :: Bool
optNumberSections = Bool
True }))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"number-offset"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
case forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
safeStrRead (String
"[" forall a. Semigroup a => a -> a -> a
<> String
arg forall a. Semigroup a => a -> a -> a
<> String
"]") of
Just [Int]
ns -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optNumberOffset :: [Int]
optNumberOffset = [Int]
ns,
optNumberSections :: Bool
optNumberSections = Bool
True }
Maybe [Int]
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"could not parse argument of --number-offset")
String
"NUMBERS")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"top-level-division"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
case String
arg of
String
"section" -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optTopLevelDivision :: TopLevelDivision
optTopLevelDivision =
TopLevelDivision
TopLevelSection }
String
"chapter" -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optTopLevelDivision :: TopLevelDivision
optTopLevelDivision =
TopLevelDivision
TopLevelChapter }
String
"part" -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optTopLevelDivision :: TopLevelDivision
optTopLevelDivision =
TopLevelDivision
TopLevelPart }
String
"default" -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optTopLevelDivision :: TopLevelDivision
optTopLevelDivision =
TopLevelDivision
TopLevelDefault }
String
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError forall a b. (a -> b) -> a -> b
$
Text
"Argument of --top-level division must be " forall a. Semigroup a => a -> a -> a
<>
Text
"section, chapter, part, or default" )
String
"section|chapter|part")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"extract-media"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optExtractMedia :: Maybe String
optExtractMedia =
forall a. a -> Maybe a
Just (String -> String
normalizePath String
arg) })
String
"PATH")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"resource-path"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optResourcePath :: [String]
optResourcePath =
String -> [String]
splitSearchPath String
arg forall a. [a] -> [a] -> [a]
++
Opt -> [String]
optResourcePath Opt
opt })
String
"SEARCHPATH")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"H" [String
"include-in-header"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optIncludeInHeader :: [String]
optIncludeInHeader =
Opt -> [String]
optIncludeInHeader Opt
opt forall a. [a] -> [a] -> [a]
++
[String -> String
normalizePath String
arg] })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"B" [String
"include-before-body"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optIncludeBeforeBody :: [String]
optIncludeBeforeBody =
Opt -> [String]
optIncludeBeforeBody Opt
opt forall a. [a] -> [a] -> [a]
++
[String -> String
normalizePath String
arg] })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"A" [String
"include-after-body"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optIncludeAfterBody :: [String]
optIncludeAfterBody =
Opt -> [String]
optIncludeAfterBody Opt
opt forall a. [a] -> [a] -> [a]
++
[String -> String
normalizePath String
arg] })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"no-highlight"]
(forall a. a -> ArgDescr a
NoArg
(\Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optHighlightStyle :: Maybe Text
optHighlightStyle = forall a. Maybe a
Nothing }))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"highlight-style"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optHighlightStyle :: Maybe Text
optHighlightStyle = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$
String -> Text
T.pack forall a b. (a -> b) -> a -> b
$ String -> String
normalizePath String
arg })
String
"STYLE|FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"syntax-definition"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optSyntaxDefinitions :: [String]
optSyntaxDefinitions = String -> String
normalizePath String
arg forall a. a -> [a] -> [a]
:
Opt -> [String]
optSyntaxDefinitions Opt
opt })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"dpi"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
case forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
safeStrRead String
arg of
Just Int
t | Int
t forall a. Ord a => a -> a -> Bool
> Int
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optDpi :: Int
optDpi = Int
t }
Maybe Int
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"Argument of --dpi must be a number greater than 0")
String
"NUMBER")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"eol"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
case Char -> Char
toLower forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String
arg of
String
"crlf" -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optEol :: LineEnding
optEol = LineEnding
CRLF }
String
"lf" -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optEol :: LineEnding
optEol = LineEnding
LF }
String
"native" -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optEol :: LineEnding
optEol = LineEnding
Native }
String
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"Argument of --eol must be crlf, lf, or native")
String
"crlf|lf|native")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"columns"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
case forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
safeStrRead String
arg of
Just Int
t | Int
t forall a. Ord a => a -> a -> Bool
> Int
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optColumns :: Int
optColumns = Int
t }
Maybe Int
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"Argument of --columns must be a number greater than 0")
String
"NUMBER")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"p" [String
"preserve-tabs"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--preserve-tabs/-p" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optPreserveTabs :: Bool
optPreserveTabs = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"tab-stop"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
case forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
safeStrRead String
arg of
Just Int
t | Int
t forall a. Ord a => a -> a -> Bool
> Int
0 -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optTabStop :: Int
optTabStop = Int
t }
Maybe Int
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"Argument of --tab-stop must be a number greater than 0")
String
"NUMBER")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"pdf-engine"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> do
let b :: String
b = String -> String
takeBaseName String
arg
if String
b forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [String]
pdfEngines
then forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optPdfEngine :: Maybe String
optPdfEngine = forall a. a -> Maybe a
Just String
arg }
else forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$
Text -> PandocError
PandocOptionError forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall a b. (a -> b) -> a -> b
$
String
"Argument of --pdf-engine must be one of "
forall a. [a] -> [a] -> [a]
++ forall a. [a] -> [[a]] -> [a]
intercalate String
", " [String]
pdfEngines)
String
"PROGRAM")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"pdf-engine-opt"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> do
let oldArgs :: [String]
oldArgs = Opt -> [String]
optPdfEngineOpts Opt
opt
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optPdfEngineOpts :: [String]
optPdfEngineOpts = [String]
oldArgs forall a. [a] -> [a] -> [a]
++ [String
arg]})
String
"STRING")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"reference-doc"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optReferenceDoc :: Maybe String
optReferenceDoc = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ String -> String
normalizePath String
arg })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"self-contained"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
String -> String -> ExceptT OptInfo IO ()
deprecatedOption String
"--self-contained" String
"use --embed-resources --standalone"
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--self-contained" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optSelfContained :: Bool
optSelfContained = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"embed-resources"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--embed-resources" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optEmbedResources :: Bool
optEmbedResources = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"request-header"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> do
let (String
key, String
val) = String -> (String, String)
splitField String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optRequestHeaders :: [(Text, Text)]
optRequestHeaders =
(String -> Text
T.pack String
key, String -> Text
T.pack String
val) forall a. a -> [a] -> [a]
: Opt -> [(Text, Text)]
optRequestHeaders Opt
opt })
String
"NAME:VALUE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"no-check-certificate"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--no-check-certificate" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optNoCheckCertificate :: Bool
optNoCheckCertificate = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"abbreviations"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optAbbreviations :: Maybe String
optAbbreviations =
forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ String -> String
normalizePath String
arg })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"indented-code-classes"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optIndentedCodeClasses :: [Text]
optIndentedCodeClasses = Text -> [Text]
T.words forall a b. (a -> b) -> a -> b
$
(Char -> Char) -> Text -> Text
T.map (\Char
c -> if Char
c forall a. Eq a => a -> a -> Bool
== Char
',' then Char
' ' else Char
c) forall a b. (a -> b) -> a -> b
$
String -> Text
T.pack String
arg })
String
"STRING")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"default-image-extension"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optDefaultImageExtension :: Text
optDefaultImageExtension = String -> Text
T.pack String
arg })
String
"extension")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"F" [String
"filter"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optFilters :: [Filter]
optFilters =
Opt -> [Filter]
optFilters Opt
opt forall a. [a] -> [a] -> [a]
++ [String -> Filter
JSONFilter (String -> String
normalizePath String
arg)] })
String
"PROGRAM")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"L" [String
"lua-filter"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optFilters :: [Filter]
optFilters =
Opt -> [Filter]
optFilters Opt
opt forall a. [a] -> [a] -> [a]
++ [String -> Filter
LuaFilter (String -> String
normalizePath String
arg)] })
String
"SCRIPTPATH")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"shift-heading-level-by"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
case forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
safeStrRead String
arg of
Just Int
t ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optShiftHeadingLevelBy :: Int
optShiftHeadingLevelBy = Int
t }
Maybe Int
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"Argument of --shift-heading-level-by must be an integer")
String
"NUMBER")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"base-header-level"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> do
String -> String -> ExceptT OptInfo IO ()
deprecatedOption String
"--base-header-level"
String
"Use --shift-heading-level-by instead."
case forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
safeStrRead String
arg of
Just Int
t | Int
t forall a. Ord a => a -> a -> Bool
> Int
0 Bool -> Bool -> Bool
&& Int
t forall a. Ord a => a -> a -> Bool
< Int
6 ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optShiftHeadingLevelBy :: Int
optShiftHeadingLevelBy = Int
t forall a. Num a => a -> a -> a
- Int
1 }
Maybe Int
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"Argument of --base-header-level must be 1-5")
String
"NUMBER")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"track-changes"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> do
TrackChanges
action <- case String
arg of
String
"accept" -> forall (m :: * -> *) a. Monad m => a -> m a
return TrackChanges
AcceptChanges
String
"reject" -> forall (m :: * -> *) a. Monad m => a -> m a
return TrackChanges
RejectChanges
String
"all" -> forall (m :: * -> *) a. Monad m => a -> m a
return TrackChanges
AllChanges
String
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack
String
"Argument of --track-changes must be accept, reject, or all"
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optTrackChanges :: TrackChanges
optTrackChanges = TrackChanges
action })
String
"accept|reject|all")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"strip-comments"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--strip-comments" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optStripComments :: Bool
optStripComments = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"reference-links"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--reference-links" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optReferenceLinks :: Bool
optReferenceLinks = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"reference-location"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> do
ReferenceLocation
action <- case String
arg of
String
"block" -> forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceLocation
EndOfBlock
String
"section" -> forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceLocation
EndOfSection
String
"document" -> forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceLocation
EndOfDocument
String
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack
String
"Argument of --reference-location must be block, section, or document"
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optReferenceLocation :: ReferenceLocation
optReferenceLocation = ReferenceLocation
action })
String
"block|section|document")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"markdown-headings"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> do
Bool
headingFormat <- case String
arg of
String
"setext" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
True
String
"atx" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure Bool
False
String
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack
String
"Argument of --markdown-headings must be setext or atx"
forall (f :: * -> *) a. Applicative f => a -> f a
pure Opt
opt { optSetextHeaders :: Bool
optSetextHeaders = Bool
headingFormat }
)
String
"setext|atx")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"list-tables"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--list-tables" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optListTables :: Bool
optListTables = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"listings"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--listings" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optListings :: Bool
optListings = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"i" [String
"incremental"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--incremental/-i" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optIncremental :: Bool
optIncremental = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"slide-level"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
case forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
safeStrRead String
arg of
Just Int
t | Int
t forall a. Ord a => a -> a -> Bool
>= Int
0 Bool -> Bool -> Bool
&& Int
t forall a. Ord a => a -> a -> Bool
<= Int
6 ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optSlideLevel :: Maybe Int
optSlideLevel = forall a. a -> Maybe a
Just Int
t }
Maybe Int
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"Argument of --slide-level must be a number between 0 and 6")
String
"NUMBER")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"section-divs"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--section-divs" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optSectionDivs :: Bool
optSectionDivs = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"html-q-tags"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--html-q-tags" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optHtmlQTags :: Bool
optHtmlQTags = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"email-obfuscation"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> do
ObfuscationMethod
method <- case String
arg of
String
"references" -> forall (m :: * -> *) a. Monad m => a -> m a
return ObfuscationMethod
ReferenceObfuscation
String
"javascript" -> forall (m :: * -> *) a. Monad m => a -> m a
return ObfuscationMethod
JavascriptObfuscation
String
"none" -> forall (m :: * -> *) a. Monad m => a -> m a
return ObfuscationMethod
NoObfuscation
String
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack
String
"Argument of --email-obfuscation must be references, javascript, or none"
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optEmailObfuscation :: ObfuscationMethod
optEmailObfuscation = ObfuscationMethod
method })
String
"none|javascript|references")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"id-prefix"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optIdentifierPrefix :: Text
optIdentifierPrefix = String -> Text
T.pack String
arg })
String
"STRING")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"T" [String
"title-prefix"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt {
optVariables :: Context Text
optVariables =
Text -> Text -> Context Text -> Context Text
setVariable Text
"title-prefix" (String -> Text
T.pack String
arg) forall a b. (a -> b) -> a -> b
$
Opt -> Context Text
optVariables Opt
opt,
optStandalone :: Bool
optStandalone = Bool
True })
String
"STRING")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"c" [String
"css"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optCss :: [String]
optCss = Opt -> [String]
optCss Opt
opt forall a. [a] -> [a] -> [a]
++ [String
arg] })
String
"URL")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"epub-subdirectory"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optEpubSubdirectory :: String
optEpubSubdirectory = String
arg })
String
"DIRNAME")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"epub-cover-image"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optVariables :: Context Text
optVariables =
Text -> Text -> Context Text -> Context Text
setVariable Text
"epub-cover-image"
(String -> Text
T.pack forall a b. (a -> b) -> a -> b
$ String -> String
normalizePath String
arg) forall a b. (a -> b) -> a -> b
$
Opt -> Context Text
optVariables Opt
opt })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"epub-title-page"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--epub-title-page" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optEpubTitlePage :: Bool
optEpubTitlePage = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"epub-metadata"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optEpubMetadata :: Maybe String
optEpubMetadata = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$
String -> String
normalizePath String
arg })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"epub-embed-font"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optEpubFonts :: [String]
optEpubFonts = String -> String
normalizePath String
arg forall a. a -> [a] -> [a]
:
Opt -> [String]
optEpubFonts Opt
opt })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"split-level"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
case forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
safeStrRead String
arg of
Just Int
t | Int
t forall a. Ord a => a -> a -> Bool
>= Int
1 Bool -> Bool -> Bool
&& Int
t forall a. Ord a => a -> a -> Bool
<= Int
6 ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optSplitLevel :: Int
optSplitLevel = Int
t }
Maybe Int
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"Argument of --split-level must be a number between 1 and 6")
String
"NUMBER")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"chunk-template"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optChunkTemplate :: Maybe Text
optChunkTemplate = forall a. a -> Maybe a
Just (String -> Text
T.pack String
arg) })
String
"PATHTEMPLATE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"epub-chapter-level"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> do
String -> String -> ExceptT OptInfo IO ()
deprecatedOption String
"--epub-chapter-level"
String
"use --split-level"
case forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
safeStrRead String
arg of
Just Int
t | Int
t forall a. Ord a => a -> a -> Bool
>= Int
1 Bool -> Bool -> Bool
&& Int
t forall a. Ord a => a -> a -> Bool
<= Int
6 ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optSplitLevel :: Int
optSplitLevel = Int
t }
Maybe Int
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"Argument of --epub-chapter-level must be a number between 1 and 6")
String
"NUMBER")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"ipynb-output"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
case String
arg of
String
"all" -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optIpynbOutput :: IpynbOutput
optIpynbOutput = IpynbOutput
IpynbOutputAll }
String
"best" -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optIpynbOutput :: IpynbOutput
optIpynbOutput = IpynbOutput
IpynbOutputBest }
String
"none" -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optIpynbOutput :: IpynbOutput
optIpynbOutput = IpynbOutput
IpynbOutputNone }
String
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"Argument of --ipynb-output must be all, none, or best")
String
"all|none|best")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"C" [String
"citeproc"]
(forall a. a -> ArgDescr a
NoArg
(\Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optFilters :: [Filter]
optFilters =
Opt -> [Filter]
optFilters Opt
opt forall a. [a] -> [a] -> [a]
++ [Filter
CiteprocFilter] }))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"bibliography"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optMetadata :: Meta
optMetadata =
String -> String -> Meta -> Meta
addMeta String
"bibliography"
(String -> String
normalizePath String
arg) forall a b. (a -> b) -> a -> b
$
Opt -> Meta
optMetadata Opt
opt })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"csl"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> do
case Text -> Meta -> Maybe MetaValue
lookupMeta (String -> Text
T.pack String
"csl") forall a b. (a -> b) -> a -> b
$ Opt -> Meta
optMetadata Opt
opt of
Just MetaValue
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError
Text
"--csl option can only be used once"
Maybe MetaValue
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optMetadata :: Meta
optMetadata = String -> String -> Meta -> Meta
addMeta String
"csl" (String -> String
normalizePath String
arg) forall a b. (a -> b) -> a -> b
$
Opt -> Meta
optMetadata Opt
opt })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"citation-abbreviations"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optMetadata :: Meta
optMetadata =
String -> String -> Meta -> Meta
addMeta String
"citation-abbreviations"
(String -> String
normalizePath String
arg) forall a b. (a -> b) -> a -> b
$ Opt -> Meta
optMetadata Opt
opt })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"natbib"]
(forall a. a -> ArgDescr a
NoArg
(\Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optCiteMethod :: CiteMethod
optCiteMethod = CiteMethod
Natbib }))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"biblatex"]
(forall a. a -> ArgDescr a
NoArg
(\Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optCiteMethod :: CiteMethod
optCiteMethod = CiteMethod
Biblatex }))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"mathml"]
(forall a. a -> ArgDescr a
NoArg
(\Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optHTMLMathMethod :: HTMLMathMethod
optHTMLMathMethod = HTMLMathMethod
MathML }))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"webtex"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
let url' :: String
url' = forall a. a -> Maybe a -> a
fromMaybe String
"https://latex.codecogs.com/png.latex?" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optHTMLMathMethod :: HTMLMathMethod
optHTMLMathMethod = Text -> HTMLMathMethod
WebTeX forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack String
url' })
String
"URL")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"mathjax"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
let url' :: Text
url' = forall b a. b -> (a -> b) -> Maybe a -> b
maybe Text
defaultMathJaxURL String -> Text
T.pack Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optHTMLMathMethod :: HTMLMathMethod
optHTMLMathMethod = Text -> HTMLMathMethod
MathJax Text
url'})
String
"URL")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"katex"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt
{ optHTMLMathMethod :: HTMLMathMethod
optHTMLMathMethod = Text -> HTMLMathMethod
KaTeX forall a b. (a -> b) -> a -> b
$
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Text
defaultKaTeXURL String -> Text
T.pack Maybe String
arg })
String
"URL")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"gladtex"]
(forall a. a -> ArgDescr a
NoArg
(\Opt
opt ->
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optHTMLMathMethod :: HTMLMathMethod
optHTMLMathMethod = HTMLMathMethod
GladTeX }))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"trace"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--trace" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optTrace :: Bool
optTrace = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"dump-args"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--dump-args" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optDumpArgs :: Bool
optDumpArgs = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"ignore-args"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--ignore-args" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optIgnoreArgs :: Bool
optIgnoreArgs = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"verbose"]
(forall a. a -> ArgDescr a
NoArg
(\Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optVerbosity :: Verbosity
optVerbosity = Verbosity
INFO }))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"quiet"]
(forall a. a -> ArgDescr a
NoArg
(\Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optVerbosity :: Verbosity
optVerbosity = Verbosity
ERROR }))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"fail-if-warnings"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg
(\Maybe String
arg Opt
opt -> do
Bool
boolValue <- Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
"--fail-if-warnings" Maybe String
arg
forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt { optFailIfWarnings :: Bool
optFailIfWarnings = Bool
boolValue })
String
"true|false")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"log"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opt -> forall (m :: * -> *) a. Monad m => a -> m a
return Opt
opt{ optLogFile :: Maybe String
optLogFile = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$
String -> String
normalizePath String
arg })
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"bash-completion"]
(forall a. a -> ArgDescr a
NoArg (\Opt
_ -> forall a. OptInfo -> ExceptT OptInfo IO a
optInfo OptInfo
BashCompletion))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"list-input-formats"]
(forall a. a -> ArgDescr a
NoArg (\Opt
_ -> forall a. OptInfo -> ExceptT OptInfo IO a
optInfo OptInfo
ListInputFormats))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"list-output-formats"]
(forall a. a -> ArgDescr a
NoArg (\Opt
_ -> forall a. OptInfo -> ExceptT OptInfo IO a
optInfo OptInfo
ListOutputFormats))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"list-extensions"]
(forall a. (Maybe String -> a) -> String -> ArgDescr a
OptArg (\Maybe String
arg Opt
_ -> forall a. OptInfo -> ExceptT OptInfo IO a
optInfo forall a b. (a -> b) -> a -> b
$ Maybe Text -> OptInfo
ListExtensions forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe String
arg)
String
"FORMAT")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"list-highlight-languages"]
(forall a. a -> ArgDescr a
NoArg (\Opt
_ -> forall a. OptInfo -> ExceptT OptInfo IO a
optInfo OptInfo
ListHighlightLanguages))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"list-highlight-styles"]
(forall a. a -> ArgDescr a
NoArg (\Opt
_ -> forall a. OptInfo -> ExceptT OptInfo IO a
optInfo OptInfo
ListHighlightStyles))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"D" [String
"print-default-template"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opts -> forall a. OptInfo -> ExceptT OptInfo IO a
optInfo forall a b. (a -> b) -> a -> b
$
Maybe String -> Text -> OptInfo
PrintDefaultTemplate (Opt -> Maybe String
optOutputFile Opt
opts) (String -> Text
T.pack String
arg))
String
"FORMAT")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"print-default-data-file"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opts -> forall a. OptInfo -> ExceptT OptInfo IO a
optInfo forall a b. (a -> b) -> a -> b
$
Maybe String -> Text -> OptInfo
PrintDefaultDataFile (Opt -> Maybe String
optOutputFile Opt
opts) (String -> Text
T.pack String
arg))
String
"FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"" [String
"print-highlight-style"]
(forall a. (String -> a) -> String -> ArgDescr a
ReqArg
(\String
arg Opt
opts ->
forall a. OptInfo -> ExceptT OptInfo IO a
optInfo forall a b. (a -> b) -> a -> b
$ Maybe String -> Text -> OptInfo
PrintHighlightStyle (Opt -> Maybe String
optOutputFile Opt
opts)
(String -> Text
T.pack String
arg))
String
"STYLE|FILE")
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"v" [String
"version"]
(forall a. a -> ArgDescr a
NoArg (\Opt
_ -> forall a. OptInfo -> ExceptT OptInfo IO a
optInfo OptInfo
VersionInfo))
String
""
, forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
Option String
"h" [String
"help"]
(forall a. a -> ArgDescr a
NoArg (\Opt
_ -> forall a. OptInfo -> ExceptT OptInfo IO a
optInfo OptInfo
Help))
String
""
]
optError :: PandocError -> ExceptT OptInfo IO a
optError :: forall a. PandocError -> ExceptT OptInfo IO a
optError = forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError forall b c a. (b -> c) -> (a -> b) -> a -> c
. PandocError -> OptInfo
OptError
optInfo :: OptInfo -> ExceptT OptInfo IO a
optInfo :: forall a. OptInfo -> ExceptT OptInfo IO a
optInfo = forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError
usageMessage :: String -> [OptDescr (Opt -> ExceptT OptInfo IO Opt)] -> String
usageMessage :: String -> [OptDescr (Opt -> ExceptT OptInfo IO Opt)] -> String
usageMessage String
programName = forall a. String -> [OptDescr a] -> String
usageInfo (String
programName forall a. [a] -> [a] -> [a]
++ String
" [OPTIONS] [FILES]")
copyrightMessage :: String
copyrightMessage :: String
copyrightMessage = forall a. [a] -> [[a]] -> [a]
intercalate String
"\n" [
String
"Copyright (C) 2006-2023 John MacFarlane. Web: https://pandoc.org",
String
"This is free software; see the source for copying conditions. There is no",
String
"warranty, not even for merchantability or fitness for a particular purpose." ]
compileInfo :: String
compileInfo :: String
compileInfo =
String
"\nCompiled with pandoc-types " forall a. [a] -> [a] -> [a]
++ VERSION_pandoc_types ++
String
", texmath " forall a. [a] -> [a] -> [a]
++ VERSION_texmath ++ ", skylighting " ++
VERSION_skylighting ++ ",\nciteproc " ++ VERSION_citeproc ++
", ipynb " ++ VERSION_ipynb
handleUnrecognizedOption :: String -> [String] -> [String]
handleUnrecognizedOption :: String -> [String] -> [String]
handleUnrecognizedOption String
"--smart" =
((String
"--smart/-S has been removed. Use +smart or -smart extension instead.\n" forall a. [a] -> [a] -> [a]
++
String
"For example: pandoc -f markdown+smart -t markdown-smart.") forall a. a -> [a] -> [a]
:)
handleUnrecognizedOption String
"--normalize" =
(String
"--normalize has been removed. Normalization is now automatic." forall a. a -> [a] -> [a]
:)
handleUnrecognizedOption String
"-S" = String -> [String] -> [String]
handleUnrecognizedOption String
"--smart"
handleUnrecognizedOption String
"--old-dashes" =
(String
"--old-dashes has been removed. Use +old_dashes extension instead." forall a. a -> [a] -> [a]
:)
handleUnrecognizedOption String
"--no-wrap" =
(String
"--no-wrap has been removed. Use --wrap=none instead." forall a. a -> [a] -> [a]
:)
handleUnrecognizedOption String
"--latex-engine" =
(String
"--latex-engine has been removed. Use --pdf-engine instead." forall a. a -> [a] -> [a]
:)
handleUnrecognizedOption String
"--latex-engine-opt" =
(String
"--latex-engine-opt has been removed. Use --pdf-engine-opt instead." forall a. a -> [a] -> [a]
:)
handleUnrecognizedOption String
"--chapters" =
(String
"--chapters has been removed. Use --top-level-division=chapter instead." forall a. a -> [a] -> [a]
:)
handleUnrecognizedOption String
"--reference-docx" =
(String
"--reference-docx has been removed. Use --reference-doc instead." forall a. a -> [a] -> [a]
:)
handleUnrecognizedOption String
"--reference-odt" =
(String
"--reference-odt has been removed. Use --reference-doc instead." forall a. a -> [a] -> [a]
:)
handleUnrecognizedOption String
"--parse-raw" =
(String
"--parse-raw/-R has been removed. Use +raw_html or +raw_tex extension.\n" forall a. a -> [a] -> [a]
:)
handleUnrecognizedOption String
"--epub-stylesheet" =
(String
"--epub-stylesheet has been removed. Use --css instead.\n" forall a. a -> [a] -> [a]
:)
handleUnrecognizedOption String
"-R" = String -> [String] -> [String]
handleUnrecognizedOption String
"--parse-raw"
handleUnrecognizedOption String
x =
((String
"Unknown option " forall a. [a] -> [a] -> [a]
++ String
x forall a. [a] -> [a] -> [a]
++ String
".") forall a. a -> [a] -> [a]
:)
readersNames :: [Text]
readersNames :: [Text]
readersNames = forall a. Ord a => [a] -> [a]
sort (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst (forall (m :: * -> *). PandocMonad m => [(Text, Reader m)]
readers :: [(Text, Reader PandocIO)]))
writersNames :: [Text]
writersNames :: [Text]
writersNames = forall a. Ord a => [a] -> [a]
sort
(Text
"pdf" forall a. a -> [a] -> [a]
: forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst (forall (m :: * -> *). PandocMonad m => [(Text, Writer m)]
writers :: [(Text, Writer PandocIO)]))
splitField :: String -> (String, String)
splitField :: String -> (String, String)
splitField = forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (forall a. [a] -> [a] -> [a]
tailDef String
"true") forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> ([a], [a])
break (\Char
c -> Char
c forall a. Eq a => a -> a -> Bool
== Char
':' Bool -> Bool -> Bool
|| Char
c forall a. Eq a => a -> a -> Bool
== Char
'=')
deprecatedOption :: String -> String -> ExceptT OptInfo IO ()
deprecatedOption :: String -> String -> ExceptT OptInfo IO ()
deprecatedOption String
o String
msg = do
Either PandocError ()
res <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall a. PandocIO a -> IO (Either PandocError a)
runIO (forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
report forall a b. (a -> b) -> a -> b
$ Text -> Text -> LogMessage
Deprecated (String -> Text
T.pack String
o) (String -> Text
T.pack String
msg))
case Either PandocError ()
res of
Right () -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
Left PandocError
e -> forall a. PandocError -> ExceptT OptInfo IO a
optError PandocError
e
setVariable :: Text -> Text -> Context Text -> Context Text
setVariable :: Text -> Text -> Context Text -> Context Text
setVariable Text
key Text
val (Context Map Text (Val Text)
ctx) = forall a. Map Text (Val a) -> Context a
Context forall a b. (a -> b) -> a -> b
$ forall k a.
Ord k =>
(Maybe a -> Maybe a) -> k -> Map k a -> Map k a
M.alter forall {a}. ToContext a Text => Maybe (Val a) -> Maybe (Val a)
go Text
key Map Text (Val Text)
ctx
where go :: Maybe (Val a) -> Maybe (Val a)
go Maybe (Val a)
Nothing = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a b. ToContext a b => b -> Val a
toVal Text
val
go (Just (ListVal [Val a]
xs)) = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. [Val a] -> Val a
ListVal forall a b. (a -> b) -> a -> b
$ [Val a]
xs forall a. [a] -> [a] -> [a]
++ [forall a b. ToContext a b => b -> Val a
toVal Text
val]
go (Just Val a
x) = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. [Val a] -> Val a
ListVal [Val a
x, forall a b. ToContext a b => b -> Val a
toVal Text
val]
addMeta :: String -> String -> Meta -> Meta
addMeta :: String -> String -> Meta -> Meta
addMeta String
k String
v Meta
meta =
case Text -> Meta -> Maybe MetaValue
lookupMeta Text
k' Meta
meta of
Maybe MetaValue
Nothing -> forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
setMeta Text
k' MetaValue
v' Meta
meta
Just (MetaList [MetaValue]
xs) ->
forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
setMeta Text
k' ([MetaValue] -> MetaValue
MetaList ([MetaValue]
xs forall a. [a] -> [a] -> [a]
++ [MetaValue
v'])) Meta
meta
Just MetaValue
x -> forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
setMeta Text
k' ([MetaValue] -> MetaValue
MetaList [MetaValue
x, MetaValue
v']) Meta
meta
where
v' :: MetaValue
v' = String -> MetaValue
readMetaValue String
v
k' :: Text
k' = String -> Text
T.pack String
k
readMetaValue :: String -> MetaValue
readMetaValue :: String -> MetaValue
readMetaValue String
s
| String
s forall a. Eq a => a -> a -> Bool
== String
"true" = Bool -> MetaValue
MetaBool Bool
True
| String
s forall a. Eq a => a -> a -> Bool
== String
"True" = Bool -> MetaValue
MetaBool Bool
True
| String
s forall a. Eq a => a -> a -> Bool
== String
"TRUE" = Bool -> MetaValue
MetaBool Bool
True
| String
s forall a. Eq a => a -> a -> Bool
== String
"false" = Bool -> MetaValue
MetaBool Bool
False
| String
s forall a. Eq a => a -> a -> Bool
== String
"False" = Bool -> MetaValue
MetaBool Bool
False
| String
s forall a. Eq a => a -> a -> Bool
== String
"FALSE" = Bool -> MetaValue
MetaBool Bool
False
| Bool
otherwise = Text -> MetaValue
MetaString forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack String
s
readBoolFromOptArg :: Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg :: Text -> Maybe String -> ExceptT OptInfo IO Bool
readBoolFromOptArg Text
opt = forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True) forall {f :: * -> *}.
(Functor f, Eq (f Char), IsString (f Char)) =>
f Char -> ExceptT OptInfo IO Bool
readBoolFromArg
where readBoolFromArg :: f Char -> ExceptT OptInfo IO Bool
readBoolFromArg f Char
arg = case Char -> Char
toLower forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f Char
arg of
f Char
"true" -> forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
f Char
"false" -> forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
f Char
_ -> forall a. PandocError -> ExceptT OptInfo IO a
optError forall a b. (a -> b) -> a -> b
$ Text -> PandocError
PandocOptionError forall a b. (a -> b) -> a -> b
$
Text
"Argument of " forall a. Semigroup a => a -> a -> a
<> Text
opt forall a. Semigroup a => a -> a -> a
<> Text
" must be either true or false"
normalizePath :: FilePath -> FilePath
#ifdef _WINDOWS
normalizePath fp =
if "\\\\" `isPrefixOf` fp && not ("\\\\?\\" `isPrefixOf` fp)
then "\\\\?\\UNC\\" ++ drop 2 fp
else fp
#else
normalizePath :: String -> String
normalizePath = forall a. a -> a
id
#endif