    {-# LANGUAGE CPP                 #-}
    {-# LANGUAGE ScopedTypeVariables #-}
    {-# LANGUAGE TupleSections       #-}
    {-# LANGUAGE OverloadedStrings   #-}
    {-# LANGUAGE FlexibleContexts    #-}
    {- |
       Module      : Text.Pandoc.App.CommandLineOptions
       Copyright   : Copyright (C) 2006-2020 John MacFarlane
       License     : GNU GPL, version 2 or above

       Maintainer  : John MacFarlane <jgm@berkeley@edu>
       Stability   : alpha
       Portability : portable

    Does a pandoc conversion based on command-line options.
    -}
    module Text.Pandoc.App.CommandLineOptions (
                parseOptions
              , options
              , engines
              , lookupHighlightStyle
              , setVariable
              ) where
    import Control.Monad
    import Control.Monad.Trans
    import Control.Monad.Except (throwError)
    import Data.Aeson.Encode.Pretty (encodePretty', Config(..), keyOrder,
             defConfig, Indent(..), NumberFormat(..))
    import Data.Bifunctor (second)
    import Data.Char (toLower)
    import Data.List (intercalate, sort)
    #ifdef _WINDOWS
    #if MIN_VERSION_base(4,12,0)
    import Data.List (isPrefixOf)
    #endif
    #endif
    import Data.Maybe (fromMaybe, isJust)
    import Data.Text (Text)
    import Safe (tailDef)
    import Skylighting (Style, Syntax (..), defaultSyntaxMap, parseTheme)
    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.App.Opt (Opt (..), LineEnding (..), IpynbOutput (..), addMeta)
    import Text.Pandoc.Filter (Filter (..))
    import Text.Pandoc.Highlighting (highlightingStyles)
    import Text.Pandoc.Shared (ordNub, elemText, safeStrRead, defaultUserDataDirs, findM)
    import Text.Printf

    #ifdef EMBED_DATA_FILES
    import Text.Pandoc.Data (dataFiles)
    #else
    import Paths_pandoc (getDataDir)
    import System.Directory (getDirectoryContents)
    #endif

    import qualified Control.Exception as E
    import qualified Data.ByteString as BS
    import qualified Data.ByteString.Lazy as B
    import qualified Data.Map as M
    import qualified Data.Text as T
    import qualified Data.YAML as Y
    import qualified Text.Pandoc.UTF8 as UTF8

    parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt
    parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt
    parseOptions options' :: [OptDescr (Opt -> IO Opt)]
    options' defaults :: Opt
    defaults = do
      [String]
    rawArgs <- (String -> String) -> [String] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map String -> String
    UTF8.decodeArg ([String] -> [String]) -> IO [String] -> IO [String]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> IO [String]
    getArgs
      String
    prg <- IO String
    getProgName

      let (actions :: [Opt -> IO Opt]
    actions, args :: [String]
    args, unrecognizedOpts :: [String]
    unrecognizedOpts, errors :: [String]
    errors) =
               ArgOrder (Opt -> IO Opt)
    -> [OptDescr (Opt -> IO Opt)]
    -> [String]
    -> ([Opt -> IO Opt], [String], [String], [String])
    forall a.
    ArgOrder a
    -> [OptDescr a] -> [String] -> ([a], [String], [String], [String])
    getOpt' ArgOrder (Opt -> IO Opt)
    forall a. ArgOrder a
    Permute [OptDescr (Opt -> IO Opt)]
    options' [String]
    rawArgs

      let unknownOptionErrors :: [String]
    unknownOptionErrors =
           (String -> [String] -> [String])
    -> [String] -> [String] -> [String]
    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
    /= '=')) []
           [String]
    unrecognizedOpts

      Bool -> IO () -> IO ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    unless ([String] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [String]
    errors Bool -> Bool -> Bool
    && [String] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [String]
    unknownOptionErrors) (IO () -> IO ()) -> IO () -> IO ()
    forall a b. (a -> b) -> a -> b
    $
         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
    $ 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]
    ++
            ("Try " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    prg String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ " --help for more information.")

      -- thread option data structure through all supplied option actions
      Opt
    opts <- (IO Opt -> (Opt -> IO Opt) -> IO Opt)
    -> IO Opt -> [Opt -> IO Opt] -> IO Opt
    forall (t :: * -> *) b a.
    Foldable t =>
    (b -> a -> b) -> b -> t a -> b
    foldl IO Opt -> (Opt -> IO Opt) -> IO Opt
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    (>>=) (Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    defaults) [Opt -> IO Opt]
    actions
      let mbArgs :: Maybe [String]
    mbArgs = case [String]
    args of
                     [] -> Maybe [String]
    forall a. Maybe a
    Nothing
                     xs :: [String]
    xs -> [String] -> Maybe [String]
    forall a. a -> Maybe a
    Just [String]
    xs
      Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Opt -> IO Opt) -> Opt -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Opt
    opts{ optInputFiles :: Maybe [String]
    optInputFiles =
                       (String -> String) -> [String] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map String -> String
    normalizePath ([String] -> [String]) -> Maybe [String] -> Maybe [String]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Opt -> Maybe [String]
    optInputFiles Opt
    opts Maybe [String] -> Maybe [String] -> Maybe [String]
    forall a. Semigroup a => a -> a -> a
    <> Maybe [String]
    mbArgs)
                   , optStandalone :: Bool
    optStandalone = -- certain other options imply standalone
                       Opt -> Bool
    optStandalone Opt
    opts Bool -> Bool -> Bool
    ||
                         Maybe String -> Bool
    forall a. Maybe a -> Bool
    isJust (Opt -> Maybe String
    optTemplate Opt
    opts) Bool -> Bool -> Bool
    ||
                         Opt -> Bool
    optSelfContained Opt
    opts Bool -> Bool -> Bool
    ||
                         Bool -> Bool
    not ([String] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null (Opt -> [String]
    optIncludeInHeader Opt
    opts)) Bool -> Bool -> Bool
    ||
                         Bool -> Bool
    not ([String] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null (Opt -> [String]
    optIncludeBeforeBody Opt
    opts)) Bool -> Bool -> Bool
    ||
                         Bool -> Bool
    not ([String] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null (Opt -> [String]
    optIncludeAfterBody Opt
    opts)) }

    latexEngines :: [String]
    latexEngines :: [String]
    latexEngines  = ["pdflatex", "lualatex", "xelatex", "latexmk", "tectonic"]

    htmlEngines :: [String]
    htmlEngines :: [String]
    htmlEngines  = ["wkhtmltopdf", "weasyprint", "prince"]

    engines :: [(Text, String)]
    engines :: [(Text, String)]
    engines = (String -> (Text, String)) -> [String] -> [(Text, String)]
    forall a b. (a -> b) -> [a] -> [b]
    map ("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 ("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 ("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 ("beamer",) [String]
    latexEngines [(Text, String)] -> [(Text, String)] -> [(Text, String)]
    forall a. [a] -> [a] -> [a]
    ++
              [ ("ms", "pdfroff")
              , ("context", "context")
              ]

    pdfEngines :: [String]
    pdfEngines :: [String]
    pdfEngines = [String] -> [String]
    forall a. Ord a => [a] -> [a]
    ordNub ([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

    -- | A list of functions, each transforming the options data structure
    --   in response to a command-line option.
    options :: [OptDescr (Opt -> IO Opt)]
    options :: [OptDescr (Opt -> IO Opt)]
    options =
        [ String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "fr" ["from","read"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optFrom :: Maybe Text
    optFrom =
                                                  Text -> Maybe Text
    forall a. a -> Maybe a
    Just (Text -> Text
    T.toLower (Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack String
    arg) })
                      "FORMAT")
                     ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "tw" ["to","write"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optTo :: Maybe Text
    optTo = Text -> Maybe Text
    forall a. a -> Maybe a
    Just (Text -> Maybe Text) -> Text -> Maybe Text
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack String
    arg })
                      "FORMAT")
                     ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "o" ["output"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optOutputFile :: Maybe String
    optOutputFile =
                                                 String -> Maybe String
    forall a. a -> Maybe a
    Just (String -> String
    normalizePath String
    arg) })
                      "FILE")
                     "" -- "Name of output file"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["data-dir"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optDataDir :: Maybe String
    optDataDir =
                                      String -> Maybe String
    forall a. a -> Maybe a
    Just (String -> String
    normalizePath String
    arg) })
                     "DIRECTORY") -- "Directory containing pandoc data files."
                    ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "M" ["metadata"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> do
                         let (key :: String
    key, val :: String
    val) = String -> (String, String)
    splitField String
    arg
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optMetadata :: Meta
    optMetadata = String -> String -> Meta -> Meta
    addMeta String
    key String
    val (Meta -> Meta) -> Meta -> Meta
    forall a b. (a -> b) -> a -> b
    $
                                                     Opt -> Meta
    optMetadata Opt
    opt })
                      "KEY[:VALUE]")
                     ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["metadata-file"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optMetadataFiles :: [String]
    optMetadataFiles =
                          Opt -> [String]
    optMetadataFiles Opt
    opt [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ [String -> String
    normalizePath String
    arg] })
                      "FILE")
                     ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "d" ["defaults"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> String -> IO Opt
    applyDefaults Opt
    opt String
    arg
                      )
                      "FILE")
                    ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["file-scope"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optFileScope :: Bool
    optFileScope = Bool
    True }))
                     "" -- "Parse input files before combining"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "s" ["standalone"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optStandalone :: Bool
    optStandalone = Bool
    True }))
                     "" -- "Include needed header and footer on output"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["template"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optTemplate :: Maybe String
    optTemplate = String -> Maybe String
    forall a. a -> Maybe a
    Just (String -> String
    normalizePath String
    arg) })
                      "FILE")
                     "" -- "Use custom template"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "V" ["variable"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> do
                         let (key :: String
    key, val :: String
    val) = String -> (String, String)
    splitField String
    arg
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optVariables :: Context Text
    optVariables =
                                      Text -> Text -> Context Text -> Context Text
    setVariable (String -> Text
    T.pack String
    key) (String -> Text
    T.pack String
    val) (Context Text -> Context Text) -> Context Text -> Context Text
    forall a b. (a -> b) -> a -> b
    $
                                        Opt -> Context Text
    optVariables Opt
    opt })
                      "KEY[:VALUE]")
                     ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["wrap"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                        case String
    arg of
                          "auto" -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optWrap :: WrapOption
    optWrap = WrapOption
    WrapAuto }
                          "none" -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optWrap :: WrapOption
    optWrap = WrapOption
    WrapNone }
                          "preserve" -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optWrap :: WrapOption
    optWrap = WrapOption
    WrapPreserve }
                          _      -> PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Text -> PandocError
    PandocOptionError
                                     "--wrap must be auto, none, or preserve")
                     "auto|none|preserve")
                     "" -- "Option for wrapping text in output"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["ascii"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optAscii :: Bool
    optAscii = Bool
    True }))
                     ""  -- "Prefer ASCII output"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["toc", "table-of-contents"]
                    ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                     (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optTableOfContents :: Bool
    optTableOfContents = Bool
    True }))
                   "" -- "Include table of contents"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["toc-depth"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                          case String -> Maybe Int
    forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
    safeStrRead String
    arg of
                               Just t :: Int
    t | Int
    t Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= 1 Bool -> Bool -> Bool
    && Int
    t Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    <= 6 ->
                                        Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optTOCDepth :: Int
    optTOCDepth = Int
    t }
                               _ -> PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Text -> PandocError
    PandocOptionError
                                    "TOC level must be a number 1-6")
                     "NUMBER")
                     "" -- "Number of levels to include in TOC"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "N" ["number-sections"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optNumberSections :: Bool
    optNumberSections = Bool
    True }))
                     "" -- "Number sections"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["number-offset"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                          case String -> Maybe [Int]
    forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
    safeStrRead ("[" String -> String -> String
    forall a. Semigroup a => a -> a -> a
    <> String
    arg String -> String -> String
    forall a. Semigroup a => a -> a -> a
    <> "]") of
                               Just ns :: [Int]
    ns -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optNumberOffset :: [Int]
    optNumberOffset = [Int]
    ns,
                                                       optNumberSections :: Bool
    optNumberSections = Bool
    True }
                               _      -> PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Text -> PandocError
    PandocOptionError
                                           "could not parse number-offset")
                     "NUMBERS")
                     "" -- "Starting number for sections, subsections, etc."

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["top-level-division"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                          case String
    arg of
                            "section" -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optTopLevelDivision :: TopLevelDivision
    optTopLevelDivision =
                                            TopLevelDivision
    TopLevelSection }
                            "chapter" -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optTopLevelDivision :: TopLevelDivision
    optTopLevelDivision =
                                            TopLevelDivision
    TopLevelChapter }
                            "part"    -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optTopLevelDivision :: TopLevelDivision
    optTopLevelDivision =
                                            TopLevelDivision
    TopLevelPart }
                            "default" -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optTopLevelDivision :: TopLevelDivision
    optTopLevelDivision =
                                            TopLevelDivision
    TopLevelDefault }
                            _ -> PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Text -> PandocError
    PandocOptionError (Text -> PandocError) -> Text -> PandocError
    forall a b. (a -> b) -> a -> b
    $
                                    "Top-level division must be " Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>
                                    "section,  chapter, part, or default" )
                       "section|chapter|part")
                     "" -- "Use top-level division type in LaTeX, ConTeXt, DocBook"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["extract-media"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                        Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optExtractMedia :: Maybe String
    optExtractMedia =
                                      String -> Maybe String
    forall a. a -> Maybe a
    Just (String -> String
    normalizePath String
    arg) })
                      "PATH")
                     "" -- "Directory to which to extract embedded media"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["resource-path"]
                    ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optResourcePath :: [String]
    optResourcePath =
                                       String -> [String]
    splitSearchPath String
    arg })
                       "SEARCHPATH")
                      "" -- "Paths to search for images and other resources"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "H" ["include-in-header"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optIncludeInHeader :: [String]
    optIncludeInHeader =
                                                 Opt -> [String]
    optIncludeInHeader Opt
    opt [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ [String
    arg] })
                      "FILE")
                     "" -- "File to include at end of header (implies -s)"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "B" ["include-before-body"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optIncludeBeforeBody :: [String]
    optIncludeBeforeBody =
                                                Opt -> [String]
    optIncludeBeforeBody Opt
    opt [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ [String
    arg] })
                      "FILE")
                     "" -- "File to include before document body"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "A" ["include-after-body"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optIncludeAfterBody :: [String]
    optIncludeAfterBody =
                                                Opt -> [String]
    optIncludeAfterBody Opt
    opt [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ [String
    arg] })
                      "FILE")
                     "" -- "File to include after document body"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["no-highlight"]
                    ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                     (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optHighlightStyle :: Maybe Text
    optHighlightStyle = Maybe Text
    forall a. Maybe a
    Nothing }))
                     "" -- "Don't highlight source code"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["highlight-style"]
                    ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                     (\arg :: String
    arg opt :: Opt
    opt ->
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optHighlightStyle :: Maybe Text
    optHighlightStyle = Text -> Maybe Text
    forall a. a -> Maybe a
    Just (Text -> Maybe Text) -> Text -> Maybe Text
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack String
    arg })
                     "STYLE|FILE")
                     "" -- "Style for highlighted code"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["syntax-definition"]
                    ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                     (\arg :: String
    arg opt :: Opt
    opt -> do
                       let tr :: b -> b -> [b] -> [b]
    tr c :: b
    c d :: b
    d = (b -> b) -> [b] -> [b]
    forall a b. (a -> b) -> [a] -> [b]
    map (\x :: b
    x -> if b
    x b -> b -> Bool
    forall a. Eq a => a -> a -> Bool
    == b
    c then b
    d else b
    x)
                       let arg' :: String
    arg' = case String
    arg of -- see #4836
                                       -- HXT confuses Windows path with URI
                                       _:':':'\\':_ ->
                                           "file:///" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ Char -> Char -> String -> String
    forall b. Eq b => b -> b -> [b] -> [b]
    tr '\\' '/' String
    arg
                                       _ -> String -> String
    normalizePath String
    arg
                       Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optSyntaxDefinitions :: [String]
    optSyntaxDefinitions = String
    arg' String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :
                                    Opt -> [String]
    optSyntaxDefinitions Opt
    opt })
                     "FILE")
                    "" -- "Syntax definition (xml) file"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["dpi"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                        case String -> Maybe Int
    forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
    safeStrRead String
    arg of
                             Just t :: Int
    t | Int
    t Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > 0 -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optDpi :: Int
    optDpi = Int
    t }
                             _              -> PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Text -> PandocError
    PandocOptionError
                                            "dpi must be a number greater than 0")
                      "NUMBER")
                     "" -- "Dpi (default 96)"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["eol"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: 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
                          "crlf"   -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optEol :: LineEnding
    optEol = LineEnding
    CRLF }
                          "lf"     -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optEol :: LineEnding
    optEol = LineEnding
    LF }
                          "native" -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optEol :: LineEnding
    optEol = LineEnding
    Native }
                          -- mac-syntax (cr) is not supported in ghc-base.
                          _      -> PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Text -> PandocError
    PandocOptionError
                                    "--eol must be crlf, lf, or native")
                      "crlf|lf|native")
                     "" -- "EOL (default OS-dependent)"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["columns"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                          case String -> Maybe Int
    forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
    safeStrRead String
    arg of
                               Just t :: Int
    t | Int
    t Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > 0 -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optColumns :: Int
    optColumns = Int
    t }
                               _              -> PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Text -> PandocError
    PandocOptionError
                                       "columns must be a number greater than 0")
                     "NUMBER")
                     "" -- "Length of line in characters"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "p" ["preserve-tabs"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optPreserveTabs :: Bool
    optPreserveTabs = Bool
    True }))
                     "" -- "Preserve tabs instead of converting to spaces"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["tab-stop"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                          case String -> Maybe Int
    forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
    safeStrRead String
    arg of
                               Just t :: Int
    t | Int
    t Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > 0 -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optTabStop :: Int
    optTabStop = Int
    t }
                               _              -> PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Text -> PandocError
    PandocOptionError
                                      "tab-stop must be a number greater than 0")
                      "NUMBER")
                     "" -- "Tab stop (default 4)"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["pdf-engine"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> do
                         let b :: String
    b = String -> String
    takeBaseName String
    arg
                         if String
    b String -> [String] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [String]
    pdfEngines
                            then Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optPdfEngine :: Maybe String
    optPdfEngine = String -> Maybe String
    forall a. a -> Maybe a
    Just String
    arg }
                            else PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> 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
    $ "pdf-engine must be one of "
                                   String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String -> [String] -> String
    forall a. [a] -> [[a]] -> [a]
    intercalate ", " [String]
    pdfEngines)
                      "PROGRAM")
                     "" -- "Name of program to use in generating PDF"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["pdf-engine-opt"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> do
                          let oldArgs :: [String]
    oldArgs = Opt -> [String]
    optPdfEngineOpts Opt
    opt
                          Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optPdfEngineOpts :: [String]
    optPdfEngineOpts = [String]
    oldArgs [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ [String
    arg]})
                      "STRING")
                     "" -- "Flags to pass to the PDF-engine, all instances of this option are accumulated and used"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["reference-doc"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                        Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optReferenceDoc :: Maybe String
    optReferenceDoc = String -> Maybe String
    forall a. a -> Maybe a
    Just String
    arg })
                      "FILE")
                     "" -- "Path of custom reference doc"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["self-contained"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optSelfContained :: Bool
    optSelfContained = Bool
    True }))
                     "" -- "Make slide shows include all the needed js and css"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["request-header"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> do
                         let (key :: String
    key, val :: String
    val) = String -> (String, String)
    splitField String
    arg
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optRequestHeaders :: [(Text, Text)]
    optRequestHeaders =
                           (String -> Text
    T.pack String
    key, String -> Text
    T.pack String
    val) (Text, Text) -> [(Text, Text)] -> [(Text, Text)]
    forall a. a -> [a] -> [a]
    : Opt -> [(Text, Text)]
    optRequestHeaders Opt
    opt })
                      "NAME:VALUE")
                     ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["abbreviations"]
                    ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                     (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optAbbreviations :: Maybe String
    optAbbreviations = String -> Maybe String
    forall a. a -> Maybe a
    Just String
    arg })
                    "FILE")
                    "" -- "Specify file for custom abbreviations"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["indented-code-classes"]
                      ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                       (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optIndentedCodeClasses :: [Text]
    optIndentedCodeClasses = Text -> [Text]
    T.words (Text -> [Text]) -> Text -> [Text]
    forall a b. (a -> b) -> a -> b
    $
                                                 (Char -> Char) -> Text -> Text
    T.map (\c :: Char
    c -> if Char
    c Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == ',' then ' ' else Char
    c) (Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $
                                                 String -> Text
    T.pack String
    arg })
                       "STRING")
                      "" -- "Classes (whitespace- or comma-separated) to use for indented code-blocks"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["default-image-extension"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optDefaultImageExtension :: Text
    optDefaultImageExtension = String -> Text
    T.pack String
    arg })
                       "extension")
                      "" -- "Default extension for extensionless images"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "F" ["filter"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optFilters :: [Filter]
    optFilters =
                          Opt -> [Filter]
    optFilters Opt
    opt [Filter] -> [Filter] -> [Filter]
    forall a. [a] -> [a] -> [a]
    ++ [String -> Filter
    JSONFilter (String -> String
    normalizePath String
    arg)] })
                      "PROGRAM")
                     "" -- "External JSON filter"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "L" ["lua-filter"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optFilters :: [Filter]
    optFilters =
                          Opt -> [Filter]
    optFilters Opt
    opt [Filter] -> [Filter] -> [Filter]
    forall a. [a] -> [a] -> [a]
    ++ [String -> Filter
    LuaFilter (String -> String
    normalizePath String
    arg)] })
                      "SCRIPTPATH")
                     "" -- "Lua filter"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["shift-heading-level-by"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                          case String -> Maybe Int
    forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
    safeStrRead String
    arg of
                               Just t :: Int
    t ->
                                   Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optShiftHeadingLevelBy :: Int
    optShiftHeadingLevelBy = Int
    t }
                               _              -> PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Text -> PandocError
    PandocOptionError
                                                   "shift-heading-level-by takes an integer argument")
                      "NUMBER")
                     "" -- "Shift heading level"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["base-header-level"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> do
                          String -> String -> IO ()
    deprecatedOption "--base-header-level"
                            "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 t :: Int
    t | Int
    t Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > 0 Bool -> Bool -> Bool
    && Int
    t Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < 6 ->
                                   Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optShiftHeadingLevelBy :: Int
    optShiftHeadingLevelBy = Int
    t Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - 1 }
                               _              -> PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Text -> PandocError
    PandocOptionError
                                                   "base-header-level must be 1-5")
                      "NUMBER")
                     "" -- "Headers base level"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["strip-empty-paragraphs"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> do
                          String -> String -> IO ()
    deprecatedOption "--strip-empty-paragraphs"
                            "Use +empty_paragraphs extension."
                          Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optStripEmptyParagraphs :: Bool
    optStripEmptyParagraphs = Bool
    True }))
                     "" -- "Strip empty paragraphs"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["track-changes"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> do
                         TrackChanges
    action <- case String
    arg of
                                "accept" -> TrackChanges -> IO TrackChanges
    forall (m :: * -> *) a. Monad m => a -> m a
    return TrackChanges
    AcceptChanges
                                "reject" -> TrackChanges -> IO TrackChanges
    forall (m :: * -> *) a. Monad m => a -> m a
    return TrackChanges
    RejectChanges
                                "all"    -> TrackChanges -> IO TrackChanges
    forall (m :: * -> *) a. Monad m => a -> m a
    return TrackChanges
    AllChanges
                                _        -> PandocError -> IO TrackChanges
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO TrackChanges) -> PandocError -> 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
                                   ("Unknown option for track-changes: " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    arg)
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optTrackChanges :: TrackChanges
    optTrackChanges = TrackChanges
    action })
                      "accept|reject|all")
                     "" -- "Accepting or reject MS Word track-changes.""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["strip-comments"]
                    ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                     (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optStripComments :: Bool
    optStripComments = Bool
    True }))
                   "" -- "Strip HTML comments"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["reference-links"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optReferenceLinks :: Bool
    optReferenceLinks = Bool
    True } ))
                     "" -- "Use reference links in parsing HTML"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["reference-location"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> do
                         ReferenceLocation
    action <- case String
    arg of
                                "block"    -> ReferenceLocation -> IO ReferenceLocation
    forall (m :: * -> *) a. Monad m => a -> m a
    return ReferenceLocation
    EndOfBlock
                                "section"  -> ReferenceLocation -> IO ReferenceLocation
    forall (m :: * -> *) a. Monad m => a -> m a
    return ReferenceLocation
    EndOfSection
                                "document" -> ReferenceLocation -> IO ReferenceLocation
    forall (m :: * -> *) a. Monad m => a -> m a
    return ReferenceLocation
    EndOfDocument
                                _        -> PandocError -> IO ReferenceLocation
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO ReferenceLocation)
    -> PandocError -> 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
                                   ("Unknown option for reference-location: " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    arg)
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optReferenceLocation :: ReferenceLocation
    optReferenceLocation = ReferenceLocation
    action })
                      "block|section|document")
                     "" -- "Accepting or reject MS Word track-changes.""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["atx-headers"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optSetextHeaders :: Bool
    optSetextHeaders = Bool
    False } ))
                     "" -- "Use atx-style headers for markdown"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["listings"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optListings :: Bool
    optListings = Bool
    True }))
                     "" -- "Use listings package for LaTeX code blocks"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "i" ["incremental"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optIncremental :: Bool
    optIncremental = Bool
    True }))
                     "" -- "Make list items display incrementally in Slidy/Slideous/S5"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["slide-level"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                          case String -> Maybe Int
    forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
    safeStrRead String
    arg of
                               Just t :: Int
    t | Int
    t Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= 1 Bool -> Bool -> Bool
    && Int
    t Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    <= 6 ->
                                        Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optSlideLevel :: Maybe Int
    optSlideLevel = Int -> Maybe Int
    forall a. a -> Maybe a
    Just Int
    t }
                               _      -> PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Text -> PandocError
    PandocOptionError
                                        "slide level must be a number between 1 and 6")
                     "NUMBER")
                     "" -- "Force header level for slides"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["section-divs"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optSectionDivs :: Bool
    optSectionDivs = Bool
    True }))
                     "" -- "Put sections in div tags in HTML"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["html-q-tags"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt ->
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optHtmlQTags :: Bool
    optHtmlQTags = Bool
    True }))
                     "" -- "Use <q> tags for quotes in HTML"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["email-obfuscation"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> do
                         ObfuscationMethod
    method <- case String
    arg of
                                "references" -> ObfuscationMethod -> IO ObfuscationMethod
    forall (m :: * -> *) a. Monad m => a -> m a
    return ObfuscationMethod
    ReferenceObfuscation
                                "javascript" -> ObfuscationMethod -> IO ObfuscationMethod
    forall (m :: * -> *) a. Monad m => a -> m a
    return ObfuscationMethod
    JavascriptObfuscation
                                "none"       -> ObfuscationMethod -> IO ObfuscationMethod
    forall (m :: * -> *) a. Monad m => a -> m a
    return ObfuscationMethod
    NoObfuscation
                                _            -> PandocError -> IO ObfuscationMethod
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO ObfuscationMethod)
    -> PandocError -> 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
                                   ("Unknown obfuscation method: " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    arg)
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optEmailObfuscation :: ObfuscationMethod
    optEmailObfuscation = ObfuscationMethod
    method })
                      "none|javascript|references")
                     "" -- "Method for obfuscating email in HTML"

         , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["id-prefix"]
                      ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                       (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optIdentifierPrefix :: Text
    optIdentifierPrefix = String -> Text
    T.pack String
    arg })
                       "STRING")
                      "" -- "Prefix to add to automatically generated HTML identifiers"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "T" ["title-prefix"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                        Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt {
                           optVariables :: Context Text
    optVariables =
                             Text -> Text -> Context Text -> Context Text
    setVariable "title-prefix" (String -> Text
    T.pack String
    arg) (Context Text -> Context Text) -> Context Text -> Context Text
    forall a b. (a -> b) -> a -> b
    $
                               Opt -> Context Text
    optVariables Opt
    opt,
                           optStandalone :: Bool
    optStandalone = Bool
    True })
                      "STRING")
                     "" -- "String to prefix to HTML window title"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "c" ["css"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optCss :: [String]
    optCss = Opt -> [String]
    optCss Opt
    opt [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ [String
    arg] })
                      -- add new link to end, so it is included in proper order
                      "URL")
                     "" -- "Link to CSS style sheet"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["epub-subdirectory"]
                 ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optEpubSubdirectory :: String
    optEpubSubdirectory = String
    arg })
                      "DIRNAME")
                     "" -- "Name of subdirectory for epub content in OCF container"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["epub-cover-image"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optVariables :: Context Text
    optVariables =
                           Text -> Text -> Context Text -> Context Text
    setVariable "epub-cover-image" (String -> Text
    T.pack String
    arg) (Context Text -> Context Text) -> Context Text -> Context Text
    forall a b. (a -> b) -> a -> b
    $
                             Opt -> Context Text
    optVariables Opt
    opt })
                      "FILE")
                     "" -- "Path of epub cover image"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["epub-metadata"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optEpubMetadata :: Maybe String
    optEpubMetadata = String -> Maybe String
    forall a. a -> Maybe a
    Just String
    arg })
                      "FILE")
                     "" -- "Path of epub metadata file"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["epub-embed-font"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optEpubFonts :: [String]
    optEpubFonts = String
    arg String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    : Opt -> [String]
    optEpubFonts Opt
    opt })
                      "FILE")
                     "" -- "Directory of fonts to embed"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["epub-chapter-level"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                          case String -> Maybe Int
    forall (m :: * -> *) a. (MonadPlus m, Read a) => String -> m a
    safeStrRead String
    arg of
                               Just t :: Int
    t | Int
    t Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= 1 Bool -> Bool -> Bool
    && Int
    t Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    <= 6 ->
                                        Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optEpubChapterLevel :: Int
    optEpubChapterLevel = Int
    t }
                               _      -> PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Text -> PandocError
    PandocOptionError
                                        "chapter level must be a number between 1 and 6")
                     "NUMBER")
                     "" -- "Header level at which to split chapters in EPUB"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["ipynb-output"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                        case String
    arg of
                          "all" -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optIpynbOutput :: IpynbOutput
    optIpynbOutput = IpynbOutput
    IpynbOutputAll }
                          "best" -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optIpynbOutput :: IpynbOutput
    optIpynbOutput = IpynbOutput
    IpynbOutputBest }
                          "none" -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optIpynbOutput :: IpynbOutput
    optIpynbOutput = IpynbOutput
    IpynbOutputNone }
                          _ -> PandocError -> IO Opt
    forall e a. Exception e => e -> IO a
    E.throwIO (PandocError -> IO Opt) -> PandocError -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ Text -> PandocError
    PandocOptionError
                                 "ipynb-output must be all, none, or best")
                     "all|none|best")
                     "" -- "Starting number for sections, subsections, etc."

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["bibliography"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optMetadata :: Meta
    optMetadata =
                                                String -> String -> Meta -> Meta
    addMeta "bibliography" String
    arg (Meta -> Meta) -> Meta -> Meta
    forall a b. (a -> b) -> a -> b
    $
                                                  Opt -> Meta
    optMetadata Opt
    opt })
                       "FILE")
                     ""

         , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["csl"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optMetadata :: Meta
    optMetadata =
                                       String -> String -> Meta -> Meta
    addMeta "csl" String
    arg (Meta -> Meta) -> Meta -> Meta
    forall a b. (a -> b) -> a -> b
    $ Opt -> Meta
    optMetadata Opt
    opt })
                       "FILE")
                     ""

         , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["citation-abbreviations"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt ->
                         Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optMetadata :: Meta
    optMetadata =
                                      String -> String -> Meta -> Meta
    addMeta "citation-abbreviations" String
    arg (Meta -> Meta) -> Meta -> Meta
    forall a b. (a -> b) -> a -> b
    $
                                        Opt -> Meta
    optMetadata Opt
    opt })
                       "FILE")
                     ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["natbib"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optCiteMethod :: CiteMethod
    optCiteMethod = CiteMethod
    Natbib }))
                     "" -- "Use natbib cite commands in LaTeX output"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["biblatex"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optCiteMethod :: CiteMethod
    optCiteMethod = CiteMethod
    Biblatex }))
                     "" -- "Use biblatex cite commands in LaTeX output"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["mathml"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt ->
                          Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optHTMLMathMethod :: HTMLMathMethod
    optHTMLMathMethod = HTMLMathMethod
    MathML }))
                     "" -- "Use mathml for HTML math"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["webtex"]
                     ((Maybe String -> Opt -> IO Opt)
    -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (Maybe String -> a) -> String -> ArgDescr a
    OptArg
                      (\arg :: Maybe String
    arg opt :: Opt
    opt -> do
                          let url' :: String
    url' = String -> Maybe String -> String
    forall a. a -> Maybe a -> a
    fromMaybe "https://latex.codecogs.com/png.latex?" Maybe String
    arg
                          Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optHTMLMathMethod :: HTMLMathMethod
    optHTMLMathMethod = Text -> HTMLMathMethod
    WebTeX (Text -> HTMLMathMethod) -> Text -> HTMLMathMethod
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack String
    url' })
                      "URL")
                     "" -- "Use web service for HTML math"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["mathjax"]
                     ((Maybe String -> Opt -> IO Opt)
    -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (Maybe String -> a) -> String -> ArgDescr a
    OptArg
                      (\arg :: Maybe String
    arg opt :: 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 Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>
                                      "tex-mml-chtml.js") String -> Text
    T.pack Maybe String
    arg
                          Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optHTMLMathMethod :: HTMLMathMethod
    optHTMLMathMethod = Text -> HTMLMathMethod
    MathJax Text
    url'})
                      "URL")
                     "" -- "Use MathJax for HTML math"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["katex"]
                     ((Maybe String -> Opt -> IO Opt)
    -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (Maybe String -> a) -> String -> ArgDescr a
    OptArg
                      (\arg :: Maybe String
    arg opt :: Opt
    opt ->
                          Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt
                            { optHTMLMathMethod :: HTMLMathMethod
    optHTMLMathMethod = Text -> HTMLMathMethod
    KaTeX (Text -> HTMLMathMethod) -> Text -> HTMLMathMethod
    forall a b. (a -> b) -> a -> b
    $
                               Text -> (String -> Text) -> Maybe String -> Text
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Text
    defaultKaTeXURL String -> Text
    T.pack Maybe String
    arg })
                      "URL")
                      "" -- Use KaTeX for HTML Math

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["gladtex"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt ->
                          Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optHTMLMathMethod :: HTMLMathMethod
    optHTMLMathMethod = HTMLMathMethod
    GladTeX }))
                     "" -- "Use gladtex for HTML math"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["trace"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optTrace :: Bool
    optTrace = Bool
    True }))
                     "" -- "Turn on diagnostic tracing in readers."

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["dump-args"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optDumpArgs :: Bool
    optDumpArgs = Bool
    True }))
                     "" -- "Print output filename and arguments to stdout."

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["ignore-args"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optIgnoreArgs :: Bool
    optIgnoreArgs = Bool
    True }))
                     "" -- "Ignore command-line arguments."

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["verbose"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optVerbosity :: Verbosity
    optVerbosity = Verbosity
    INFO }))
                     "" -- "Verbose diagnostic output."

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["quiet"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optVerbosity :: Verbosity
    optVerbosity = Verbosity
    ERROR }))
                     "" -- "Suppress warnings."

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["fail-if-warnings"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt { optFailIfWarnings :: Bool
    optFailIfWarnings = Bool
    True }))
                     "" -- "Exit with error status if there were  warnings."

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["log"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> Opt -> IO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return Opt
    opt{ optLogFile :: Maybe String
    optLogFile = String -> Maybe String
    forall a. a -> Maybe a
    Just String
    arg })
                    "FILE")
                    "" -- "Log messages in JSON format to this file."

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["bash-completion"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\_ -> 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 "bash_completion.tpl"
                         let optnames :: OptDescr a -> [String]
    optnames (Option shorts :: String
    shorts longs :: [String]
    longs _ _) =
                               (Char -> String) -> String -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map (\c :: Char
    c -> ['-',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
    forall a. [a] -> [a] -> [a]
    ++) [String]
    longs
                         let allopts :: String
    allopts = [String] -> String
    unwords ((OptDescr (Opt -> IO Opt) -> [String])
    -> [OptDescr (Opt -> IO Opt)] -> [String]
    forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
    concatMap OptDescr (Opt -> IO Opt) -> [String]
    forall a. OptDescr a -> [String]
    optnames [OptDescr (Opt -> IO Opt)]
    options)
                         Handle -> String -> IO ()
    UTF8.hPutStrLn Handle
    stdout (String -> IO ()) -> String -> IO ()
    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
                             ([String] -> String
    unwords [String]
    readersNames)
                             ([String] -> String
    unwords [String]
    writersNames)
                             ([String] -> String
    unwords ([String] -> String) -> [String] -> String
    forall a b. (a -> b) -> a -> b
    $ ((Text, Style) -> String) -> [(Text, Style)] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map (Text -> String
    T.unpack (Text -> String)
    -> ((Text, Style) -> Text) -> (Text, Style) -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Text, Style) -> Text
    forall a b. (a, b) -> a
    fst) [(Text, Style)]
    highlightingStyles)
                             ([String] -> String
    unwords [String]
    datafiles)
                         IO Opt
    forall a. IO a
    exitSuccess ))
                     "" -- "Print bash completion script"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["list-input-formats"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\_ -> do
                         (String -> IO ()) -> [String] -> IO ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ (Handle -> String -> IO ()
    UTF8.hPutStrLn Handle
    stdout) [String]
    readersNames
                         IO Opt
    forall a. IO a
    exitSuccess ))
                     ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["list-output-formats"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\_ -> do
                         (String -> IO ()) -> [String] -> IO ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ (Handle -> String -> IO ()
    UTF8.hPutStrLn Handle
    stdout) [String]
    writersNames
                         IO Opt
    forall a. IO a
    exitSuccess ))
                     ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["list-extensions"]
                     ((Maybe String -> Opt -> IO Opt)
    -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (Maybe String -> a) -> String -> ArgDescr a
    OptArg
                      (\arg :: Maybe String
    arg _ -> do
                         let extList :: [Extension]
                             extList :: [Extension]
    extList = [Extension
    forall a. Bounded a => a
    minBound..Extension
    forall a. Bounded a => a
    maxBound]
                         let allExts :: Extensions
    allExts =
                               case Maybe String
    arg of
                                 Nothing  -> [Extension] -> Extensions
    extensionsFromList [Extension]
    extList
                                 Just fmt :: String
    fmt -> Text -> Extensions
    getAllExtensions (Text -> Extensions) -> Text -> Extensions
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack String
    fmt
                         let defExts :: Extensions
    defExts =
                               case Maybe String
    arg of
                                 Nothing   -> Text -> Extensions
    getDefaultExtensions
                                               "markdown"
                                 Just fmt :: String
    fmt  -> Text -> Extensions
    getDefaultExtensions (Text -> Extensions) -> Text -> Extensions
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack String
    fmt
                         let showExt :: Extension -> String
    showExt x :: Extension
    x =
                               (if Extension -> Extensions -> Bool
    extensionEnabled Extension
    x Extensions
    defExts
                                   then '+'
                                   else if Extension -> Extensions -> Bool
    extensionEnabled Extension
    x Extensions
    allExts
                                           then '-'
                                           else ' ') Char -> String -> String
    forall a. a -> [a] -> [a]
    : Int -> String -> String
    forall a. Int -> [a] -> [a]
    drop 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 -> String -> IO ()
    UTF8.hPutStrLn Handle
    stdout (String -> IO ()) -> (Extension -> String) -> Extension -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Extension -> String
    showExt)
                           [Extension
    ex | Extension
    ex <- [Extension]
    extList, Extension -> Extensions -> Bool
    extensionEnabled Extension
    ex Extensions
    allExts]
                         IO Opt
    forall a. IO a
    exitSuccess )
                      "FORMAT")
                     ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["list-highlight-languages"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\_ -> 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 "Alert", String -> Text
    T.pack "Alert_indent"]
                                     ]
                         (String -> IO ()) -> [String] -> IO ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ (Handle -> String -> IO ()
    UTF8.hPutStrLn Handle
    stdout) [String]
    langs
                         IO Opt
    forall a. IO a
    exitSuccess ))
                     ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["list-highlight-styles"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\_ -> do
                         ((Text, Style) -> IO ()) -> [(Text, Style)] -> IO ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ (Handle -> String -> IO ()
    UTF8.hPutStrLn Handle
    stdout (String -> IO ())
    -> ((Text, Style) -> String) -> (Text, Style) -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> String
    T.unpack (Text -> String)
    -> ((Text, Style) -> Text) -> (Text, Style) -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Text, Style) -> Text
    forall a b. (a, b) -> a
    fst) [(Text, Style)]
    highlightingStyles
                         IO Opt
    forall a. IO a
    exitSuccess ))
                     ""

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "D" ["print-default-template"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> do
                         let write :: String -> IO ()
    write = case Opt -> Maybe String
    optOutputFile Opt
    opt of
                                            Just f :: String
    f  -> String -> String -> IO ()
    UTF8.writeFile String
    f
                                            Nothing -> Handle -> String -> IO ()
    UTF8.hPutStr Handle
    stdout
                         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
    $ 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 (String -> Text
    T.pack String
    arg)
                         case Either PandocError Text
    templ of
                              Right t :: Text
    t
                                | Text -> Bool
    T.null Text
    t -> -- e.g. for docx, odt, json:
                                    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
                                      ("templates/default." String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    arg)
                                | Bool
    otherwise -> String -> IO ()
    write (String -> IO ()) -> (Text -> String) -> Text -> IO ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> String
    T.unpack (Text -> IO ()) -> Text -> IO ()
    forall a b. (a -> b) -> a -> b
    $ Text
    t
                              Left e :: PandocError
    e  -> PandocError -> IO ()
    forall e a. Exception e => e -> IO a
    E.throwIO PandocError
    e
                         IO Opt
    forall a. IO a
    exitSuccess)
                      "FORMAT")
                     "" -- "Print default template for FORMAT"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["print-default-data-file"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> do
                         let write :: ByteString -> IO ()
    write = case Opt -> Maybe String
    optOutputFile Opt
    opt of
                                            Just f :: String
    f  -> String -> ByteString -> IO ()
    BS.writeFile String
    f
                                            Nothing -> Handle -> ByteString -> IO ()
    BS.hPutStr Handle
    stdout
                         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 String
    arg PandocIO ByteString -> (ByteString -> PandocIO ()) -> PandocIO ()
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= IO () -> PandocIO ()
    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
                         IO Opt
    forall a. IO a
    exitSuccess)
                      "FILE")
                      "" -- "Print default data file"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "" ["print-highlight-style"]
                     ((String -> Opt -> IO Opt) -> String -> ArgDescr (Opt -> IO Opt)
    forall a. (String -> a) -> String -> ArgDescr a
    ReqArg
                      (\arg :: String
    arg opt :: Opt
    opt -> do
                         let write :: ByteString -> IO ()
    write = case Opt -> Maybe String
    optOutputFile Opt
    opt of
                                            Just f :: String
    f  -> String -> ByteString -> IO ()
    B.writeFile String
    f
                                            Nothing -> ByteString -> IO ()
    B.putStr
                         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
    lookupHighlightStyle String
    arg
                         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 :: Indent
    confIndent = Int -> Indent
    Spaces 4
                                    ,confCompare :: Text -> Text -> Ordering
    confCompare = [Text] -> Text -> Text -> Ordering
    keyOrder
                                      ((String -> Text) -> [String] -> [Text]
    forall a b. (a -> b) -> [a] -> [b]
    map String -> Text
    T.pack
                                       ["text-color"
                                       ,"background-color"
                                       ,"line-number-color"
                                       ,"line-number-background-color"
                                       ,"bold"
                                       ,"italic"
                                       ,"underline"
                                       ,"text-styles"])
                                    ,confNumFormat :: NumberFormat
    confNumFormat = NumberFormat
    Generic
                                    ,confTrailingNewline :: Bool
    confTrailingNewline = Bool
    True} Style
    sty
                         IO Opt
    forall a. IO a
    exitSuccess)
                      "STYLE|FILE")
                     "" -- "Print default template for FORMAT"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "v" ["version"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\_ -> do
                         String
    prg <- IO String
    getProgName
                         [String]
    defaultDatadirs <- IO [String]
    defaultUserDataDirs
                         Handle -> String -> IO ()
    UTF8.hPutStrLn Handle
    stdout (String
    prg String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ " " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ Text -> String
    T.unpack Text
    pandocVersion String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++
                           String
    compileInfo String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ "\nDefault user data directory: " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++
                           String -> [String] -> String
    forall a. [a] -> [[a]] -> [a]
    intercalate " or " [String]
    defaultDatadirs String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++
                           ('\n'Char -> String -> String
    forall a. a -> [a] -> [a]
    :String
    copyrightMessage))
                         IO Opt
    forall a. IO a
    exitSuccess ))
                     "" -- "Print version"

        , String
    -> [String]
    -> ArgDescr (Opt -> IO Opt)
    -> String
    -> OptDescr (Opt -> IO Opt)
    forall a. String -> [String] -> ArgDescr a -> String -> OptDescr a
    Option "h" ["help"]
                     ((Opt -> IO Opt) -> ArgDescr (Opt -> IO Opt)
    forall a. a -> ArgDescr a
    NoArg
                      (\_ -> do
                         String
    prg <- IO String
    getProgName
                         Handle -> String -> IO ()
    UTF8.hPutStr Handle
    stdout (String -> [OptDescr (Opt -> IO Opt)] -> String
    usageMessage String
    prg [OptDescr (Opt -> IO Opt)]
    options)
                         IO Opt
    forall a. IO a
    exitSuccess ))
                     "" -- "Show help"
        ]

    getDataFileNames :: IO [FilePath]
    getDataFileNames :: IO [String]
    getDataFileNames = do
    #ifdef EMBED_DATA_FILES
      let allDataFiles = map fst dataFiles
    #else
      [String]
    allDataFiles <- (String -> Bool) -> [String] -> [String]
    forall a. (a -> Bool) -> [a] -> [a]
    filter (\x :: String
    x -> String
    x String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    /= "." Bool -> Bool -> Bool
    && String
    x String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    /= "..") ([String] -> [String]) -> IO [String] -> IO [String]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                          (IO String
    getDataDir IO String -> (String -> IO [String]) -> IO [String]
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= String -> IO [String]
    getDirectoryContents)
    #endif
      [String] -> IO [String]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([String] -> IO [String]) -> [String] -> IO [String]
    forall a b. (a -> b) -> a -> b
    $ "reference.docx" String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    : "reference.odt" String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    : "reference.pptx" String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    : [String]
    allDataFiles

    -- Returns usage message
    usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
    usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
    usageMessage programName :: String
    programName = String -> [OptDescr (Opt -> IO Opt)] -> String
    forall a. String -> [OptDescr a] -> String
    usageInfo (String
    programName String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ " [OPTIONS] [FILES]")

    copyrightMessage :: String
    copyrightMessage :: String
    copyrightMessage = String -> [String] -> String
    forall a. [a] -> [[a]] -> [a]
    intercalate "\n" [
      "Copyright (C) 2006-2020 John MacFarlane",
      "Web:  https://pandoc.org",
      "This is free software; see the source for copying conditions.",
      "There is no warranty, not even for merchantability or fitness",
      "for a particular purpose." ]

    compileInfo :: String
    compileInfo :: String
    compileInfo =
      "\nCompiled with pandoc-types " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ VERSION_pandoc_types ++ ", texmath " ++
      VERSION_texmath ++ ", skylighting " ++ VERSION_skylighting

    handleUnrecognizedOption :: String -> [String] -> [String]
    handleUnrecognizedOption :: String -> [String] -> [String]
    handleUnrecognizedOption "--smart" =
      (("--smart/-S has been removed.  Use +smart or -smart extension instead.\n" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++
        "For example: pandoc -f markdown+smart -t markdown-smart.") String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :)
    handleUnrecognizedOption "--normalize" =
      ("--normalize has been removed.  Normalization is now automatic." String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :)
    handleUnrecognizedOption "-S" = String -> [String] -> [String]
    handleUnrecognizedOption "--smart"
    handleUnrecognizedOption "--old-dashes" =
      ("--old-dashes has been removed.  Use +old_dashes extension instead." String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :)
    handleUnrecognizedOption "--no-wrap" =
      ("--no-wrap has been removed.  Use --wrap=none instead." String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :)
    handleUnrecognizedOption "--latex-engine" =
      ("--latex-engine has been removed.  Use --pdf-engine instead." String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :)
    handleUnrecognizedOption "--latex-engine-opt" =
      ("--latex-engine-opt has been removed.  Use --pdf-engine-opt instead." String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :)
    handleUnrecognizedOption "--chapters" =
      ("--chapters has been removed. Use --top-level-division=chapter instead." String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :)
    handleUnrecognizedOption "--reference-docx" =
      ("--reference-docx has been removed. Use --reference-doc instead." String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :)
    handleUnrecognizedOption "--reference-odt" =
      ("--reference-odt has been removed. Use --reference-doc instead." String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :)
    handleUnrecognizedOption "--parse-raw" =
      ("--parse-raw/-R has been removed. Use +raw_html or +raw_tex extension.\n" String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :)
    handleUnrecognizedOption "--epub-stylesheet" =
      ("--epub-stylesheet has been removed. Use --css instead.\n" String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :)
    handleUnrecognizedOption "-R" = String -> [String] -> [String]
    handleUnrecognizedOption "--parse-raw"
    handleUnrecognizedOption x :: String
    x =
      (("Unknown option " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    x String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ ".") String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    :)

    readersNames :: [String]
    readersNames :: [String]
    readersNames = [String] -> [String]
    forall a. Ord a => [a] -> [a]
    sort (((Text, Reader PandocIO) -> String)
    -> [(Text, Reader PandocIO)] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map (Text -> String
    T.unpack (Text -> String)
    -> ((Text, Reader PandocIO) -> Text)
    -> (Text, Reader PandocIO)
    -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (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 :: [String]
    writersNames :: [String]
    writersNames = [String] -> [String]
    forall a. Ord a => [a] -> [a]
    sort
      ("pdf" String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    : ((Text, Writer PandocIO) -> String)
    -> [(Text, Writer PandocIO)] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map (Text -> String
    T.unpack (Text -> String)
    -> ((Text, Writer PandocIO) -> Text)
    -> (Text, Writer PandocIO)
    -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (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 (p :: * -> * -> *) b c a.
    Bifunctor p =>
    (b -> c) -> p a b -> p a c
    second (String -> String -> String
    forall a. [a] -> [a] -> [a]
    tailDef "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 -> Text -> Bool
    `elemText` ":=")

    -- | Apply defaults from --defaults file.
    applyDefaults :: Opt -> FilePath -> IO Opt
    applyDefaults :: Opt -> String -> IO Opt
    applyDefaults opt :: Opt
    opt file :: String
    file = PandocIO Opt -> IO Opt
    forall a. PandocIO a -> IO a
    runIOorExplode (PandocIO Opt -> IO Opt) -> PandocIO Opt -> IO Opt
    forall a b. (a -> b) -> a -> b
    $ do
      let fp :: String
    fp = if String -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null (String -> String
    takeExtension String
    file)
                  then String -> String -> String
    addExtension String
    file "yaml"
                  else String
    file
      Verbosity -> PandocIO ()
    forall (m :: * -> *). PandocMonad m => Verbosity -> m ()
    setVerbosity (Verbosity -> PandocIO ()) -> Verbosity -> PandocIO ()
    forall a b. (a -> b) -> a -> b
    $ Opt -> Verbosity
    optVerbosity Opt
    opt
      [String]
    dataDirs <- IO [String] -> PandocIO [String]
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO IO [String]
    defaultUserDataDirs
      let fps :: [String]
    fps = String
    fp String -> [String] -> [String]
    forall a. a -> [a] -> [a]
    : case Opt -> Maybe String
    optDataDir Opt
    opt of
                  Nothing -> (String -> String) -> [String] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map (String -> String -> String
    </> ("defaults" String -> String -> String
    </> String
    fp))
                                   [String]
    dataDirs
                  Just dd :: String
    dd -> [String
    dd String -> String -> String
    </> "defaults" String -> String -> String
    </> String
    fp]
      String
    fp' <- String -> Maybe String -> String
    forall a. a -> Maybe a -> a
    fromMaybe String
    fp (Maybe String -> String)
    -> PandocIO (Maybe String) -> PandocIO String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (String -> PandocIO Bool) -> [String] -> PandocIO (Maybe String)
    forall (m :: * -> *) (t :: * -> *) a.
    (Monad m, Foldable t) =>
    (a -> m Bool) -> t a -> m (Maybe a)
    findM String -> PandocIO Bool
    forall (m :: * -> *). PandocMonad m => String -> m Bool
    fileExists [String]
    fps
      ByteString
    inp <- String -> PandocIO ByteString
    forall (m :: * -> *). PandocMonad m => String -> m ByteString
    readFileLazy String
    fp'
      case ByteString -> Either (Pos, String) (Opt -> Opt)
    forall v. FromYAML v => ByteString -> Either (Pos, String) v
    Y.decode1 ByteString
    inp of
          Right (Opt -> Opt
    f :: Opt -> Opt) -> Opt -> PandocIO Opt
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Opt -> PandocIO Opt) -> Opt -> PandocIO Opt
    forall a b. (a -> b) -> a -> b
    $ Opt -> Opt
    f Opt
    opt
          Left (errpos :: Pos
    errpos, errmsg :: String
    errmsg)  -> PandocError -> PandocIO Opt
    forall e (m :: * -> *) a. MonadError e m => e -> m a
    throwError (PandocError -> PandocIO Opt) -> PandocError -> PandocIO Opt
    forall a b. (a -> b) -> a -> b
    $
             Text -> PandocError
    PandocParseError (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
    $
             "Error parsing " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    fp' String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ " line " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++
              Int -> String
    forall a. Show a => a -> String
    show (Pos -> Int
    Y.posLine Pos
    errpos) String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ " column " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++
              Int -> String
    forall a. Show a => a -> String
    show (Pos -> Int
    Y.posColumn Pos
    errpos) String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ ":\n" String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    errmsg

    lookupHighlightStyle :: PandocMonad m => String -> m Style
    lookupHighlightStyle :: String -> m Style
    lookupHighlightStyle s :: String
    s
      | String -> String
    takeExtension String
    s String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == ".theme" = -- attempt to load KDE theme
        do ByteString
    contents <- String -> m ByteString
    forall (m :: * -> *). PandocMonad m => String -> m ByteString
    readFileLazy String
    s
           case ByteString -> Either String Style
    parseTheme ByteString
    contents of
                Left _    -> PandocError -> m Style
    forall e (m :: * -> *) a. MonadError e m => e -> m a
    throwError (PandocError -> m Style) -> PandocError -> m Style
    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
    $
                               "Could not read highlighting theme " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    s
                Right sty :: Style
    sty -> Style -> m Style
    forall (m :: * -> *) a. Monad m => a -> m a
    return Style
    sty
      | Bool
    otherwise =
      case Text -> [(Text, Style)] -> Maybe Style
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup (Text -> Text
    T.toLower (Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack String
    s) [(Text, Style)]
    highlightingStyles of
           Just sty :: Style
    sty -> Style -> m Style
    forall (m :: * -> *) a. Monad m => a -> m a
    return Style
    sty
           Nothing  -> PandocError -> m Style
    forall e (m :: * -> *) a. MonadError e m => e -> m a
    throwError (PandocError -> m Style) -> PandocError -> m Style
    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
    $
                          "Unknown highlight-style " String -> String -> String
    forall a. [a] -> [a] -> [a]
    ++ String
    s

    deprecatedOption :: String -> String -> IO ()
    deprecatedOption :: String -> String -> IO ()
    deprecatedOption o :: String
    o msg :: String
    msg =
      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)) IO (Either PandocError ())
    -> (Either PandocError () -> IO ()) -> IO ()
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>=
        \r :: Either PandocError ()
    r -> case Either PandocError ()
    r of
           Right () -> () -> IO ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
           Left e :: PandocError
    e   -> PandocError -> IO ()
    forall e a. Exception e => e -> IO a
    E.throwIO PandocError
    e

    -- | Set text value in text context.
    setVariable :: Text -> Text -> Context Text -> Context Text
    setVariable :: Text -> Text -> Context Text -> Context Text
    setVariable key :: Text
    key val :: Text
    val (Context ctx :: 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 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 xs :: [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 x :: 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]

    -- On Windows with ghc 8.6+, we need to rewrite paths
    -- beginning with \\ to \\?\UNC\. -- See #5127.
    normalizePath :: FilePath -> FilePath
    #ifdef _WINDOWS
    #if MIN_VERSION_base(4,12,0)
    normalizePath fp =
      if "\\\\" `isPrefixOf` fp && not ("\\\\?\\" `isPrefixOf` fp)
        then "\\\\?\\UNC\\" ++ drop 2 fp
        else fp
    #else
    normalizePath = id
    #endif
    #else
    normalizePath :: String -> String
    normalizePath = String -> String
    forall a. a -> a
    id
    #endif