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