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

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

    Options for pandoc when used as an app.
    -}
    module Text.Pandoc.App.Opt (
                Opt(..)
              , LineEnding (..)
              , IpynbOutput (..)
              , defaultOpts
              , addMeta
              ) where
    import Data.Char (isLower, toLower)
    import GHC.Generics hiding (Meta)
    import Text.Pandoc.Builder (setMeta)
    import Text.Pandoc.Filter (Filter (..))
    import Text.Pandoc.Logging (Verbosity (WARNING))
    import Text.Pandoc.Options (TopLevelDivision (TopLevelDefault),
                                TrackChanges (AcceptChanges),
                                WrapOption (WrapAuto), HTMLMathMethod (PlainMath),
                                ReferenceLocation (EndOfDocument),
                                ObfuscationMethod (NoObfuscation),
                                CiteMethod (Citeproc))
    import Text.Pandoc.Shared (camelCaseStrToHyphenated)
    import Text.DocLayout (render)
    import Text.DocTemplates (Context(..), Val(..))
    import Data.Text (Text, unpack)
    import qualified Data.Text as T
    import qualified Data.Map as M
    import Text.Pandoc.Definition (Meta(..), MetaValue(..), lookupMeta)
    import Data.Aeson (defaultOptions, Options(..))
    import Data.Aeson.TH (deriveJSON)
    import Control.Applicative ((<|>))
    import Data.YAML

    -- | The type of line-endings to be used when writing plain-text.
    data LineEnding = LF | CRLF | Native deriving (Int -> LineEnding -> ShowS
    [LineEnding] -> ShowS
    LineEnding -> String
    (Int -> LineEnding -> ShowS)
    -> (LineEnding -> String)
    -> ([LineEnding] -> ShowS)
    -> Show LineEnding
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [LineEnding] -> ShowS
    $cshowList :: [LineEnding] -> ShowS
    show :: LineEnding -> String
    $cshow :: LineEnding -> String
    showsPrec :: Int -> LineEnding -> ShowS
    $cshowsPrec :: Int -> LineEnding -> ShowS
    Show, (forall x. LineEnding -> Rep LineEnding x)
    -> (forall x. Rep LineEnding x -> LineEnding) -> Generic LineEnding
    forall x. Rep LineEnding x -> LineEnding
    forall x. LineEnding -> Rep LineEnding x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep LineEnding x -> LineEnding
    $cfrom :: forall x. LineEnding -> Rep LineEnding x
    Generic)

    instance FromYAML LineEnding where
      parseYAML :: Node Pos -> Parser LineEnding
    parseYAML = String
    -> (Text -> Parser LineEnding) -> Node Pos -> Parser LineEnding
    forall a. String -> (Text -> Parser a) -> Node Pos -> Parser a
    withStr "LineEnding" ((Text -> Parser LineEnding) -> Node Pos -> Parser LineEnding)
    -> (Text -> Parser LineEnding) -> Node Pos -> Parser LineEnding
    forall a b. (a -> b) -> a -> b
    $ \t :: Text
    t ->
        case Text -> Text
    T.toLower Text
    t of
          "lf"     -> LineEnding -> Parser LineEnding
    forall (m :: * -> *) a. Monad m => a -> m a
    return LineEnding
    LF
          "crlf"   -> LineEnding -> Parser LineEnding
    forall (m :: * -> *) a. Monad m => a -> m a
    return LineEnding
    CRLF
          "native" -> LineEnding -> Parser LineEnding
    forall (m :: * -> *) a. Monad m => a -> m a
    return LineEnding
    Native
          _        -> String -> Parser LineEnding
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail (String -> Parser LineEnding) -> String -> Parser LineEnding
    forall a b. (a -> b) -> a -> b
    $ "Unknown line ending type " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Text -> String
    forall a. Show a => a -> String
    show Text
    t

    -- | How to handle output blocks in ipynb.
    data IpynbOutput =
        IpynbOutputAll
      | IpynbOutputNone
      | IpynbOutputBest
      deriving (Int -> IpynbOutput -> ShowS
    [IpynbOutput] -> ShowS
    IpynbOutput -> String
    (Int -> IpynbOutput -> ShowS)
    -> (IpynbOutput -> String)
    -> ([IpynbOutput] -> ShowS)
    -> Show IpynbOutput
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [IpynbOutput] -> ShowS
    $cshowList :: [IpynbOutput] -> ShowS
    show :: IpynbOutput -> String
    $cshow :: IpynbOutput -> String
    showsPrec :: Int -> IpynbOutput -> ShowS
    $cshowsPrec :: Int -> IpynbOutput -> ShowS
    Show, (forall x. IpynbOutput -> Rep IpynbOutput x)
    -> (forall x. Rep IpynbOutput x -> IpynbOutput)
    -> Generic IpynbOutput
    forall x. Rep IpynbOutput x -> IpynbOutput
    forall x. IpynbOutput -> Rep IpynbOutput x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep IpynbOutput x -> IpynbOutput
    $cfrom :: forall x. IpynbOutput -> Rep IpynbOutput x
    Generic)

    instance FromYAML IpynbOutput where
      parseYAML :: Node Pos -> Parser IpynbOutput
    parseYAML = String
    -> (Text -> Parser IpynbOutput) -> Node Pos -> Parser IpynbOutput
    forall a. String -> (Text -> Parser a) -> Node Pos -> Parser a
    withStr "LineEnding" ((Text -> Parser IpynbOutput) -> Node Pos -> Parser IpynbOutput)
    -> (Text -> Parser IpynbOutput) -> Node Pos -> Parser IpynbOutput
    forall a b. (a -> b) -> a -> b
    $ \t :: Text
    t ->
        case Text
    t of
          "none"  -> IpynbOutput -> Parser IpynbOutput
    forall (m :: * -> *) a. Monad m => a -> m a
    return IpynbOutput
    IpynbOutputNone
          "all"   -> IpynbOutput -> Parser IpynbOutput
    forall (m :: * -> *) a. Monad m => a -> m a
    return IpynbOutput
    IpynbOutputAll
          "best"  -> IpynbOutput -> Parser IpynbOutput
    forall (m :: * -> *) a. Monad m => a -> m a
    return IpynbOutput
    IpynbOutputBest
          _       -> String -> Parser IpynbOutput
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail (String -> Parser IpynbOutput) -> String -> Parser IpynbOutput
    forall a b. (a -> b) -> a -> b
    $ "Unknown ipynb output type " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Text -> String
    forall a. Show a => a -> String
    show Text
    t

    -- | Data structure for command line options.
    data Opt = Opt
        { Opt -> Int
    optTabStop               :: Int     -- ^ Number of spaces per tab
        , Opt -> Bool
    optPreserveTabs          :: Bool    -- ^ Preserve tabs instead of converting to spaces
        , Opt -> Bool
    optStandalone            :: Bool    -- ^ Include header, footer
        , Opt -> Maybe Text
    optFrom                  :: Maybe Text  -- ^ Reader format
        , Opt -> Maybe Text
    optTo                    :: Maybe Text  -- ^ Writer format
        , Opt -> Bool
    optTableOfContents       :: Bool    -- ^ Include table of contents
        , Opt -> Int
    optShiftHeadingLevelBy   :: Int     -- ^ Shift heading level by
        , Opt -> Maybe String
    optTemplate              :: Maybe FilePath  -- ^ Custom template
        , Opt -> Context Text
    optVariables             :: Context Text    -- ^ Template variables to set
        , Opt -> Meta
    optMetadata              :: Meta -- ^ Metadata fields to set
        , Opt -> [String]
    optMetadataFiles         :: [FilePath]  -- ^ Name of YAML metadata files
        , Opt -> Maybe String
    optOutputFile            :: Maybe FilePath  -- ^ Name of output file
        , Opt -> Maybe [String]
    optInputFiles            :: Maybe [FilePath] -- ^ Names of input files
        , Opt -> Bool
    optNumberSections        :: Bool    -- ^ Number sections in LaTeX
        , Opt -> [Int]
    optNumberOffset          :: [Int]   -- ^ Starting number for sections
        , Opt -> Bool
    optSectionDivs           :: Bool    -- ^ Put sections in div tags in HTML
        , Opt -> Bool
    optIncremental           :: Bool    -- ^ Use incremental lists in Slidy/Slideous/S5
        , Opt -> Bool
    optSelfContained         :: Bool    -- ^ Make HTML accessible offline
        , Opt -> Bool
    optHtmlQTags             :: Bool    -- ^ Use <q> tags in HTML
        , Opt -> Maybe Text
    optHighlightStyle        :: Maybe Text -- ^ Style to use for highlighted code
        , Opt -> [String]
    optSyntaxDefinitions     :: [FilePath]  -- ^ xml syntax defs to load
        , Opt -> TopLevelDivision
    optTopLevelDivision      :: TopLevelDivision -- ^ Type of the top-level divisions
        , Opt -> HTMLMathMethod
    optHTMLMathMethod        :: HTMLMathMethod -- ^ Method to print HTML math
        , Opt -> Maybe String
    optAbbreviations         :: Maybe FilePath -- ^ Path to abbrevs file
        , Opt -> Maybe String
    optReferenceDoc          :: Maybe FilePath -- ^ Path of reference doc
        , Opt -> String
    optEpubSubdirectory      :: String -- ^ EPUB subdir in OCF container
        , Opt -> Maybe String
    optEpubMetadata          :: Maybe FilePath   -- ^ EPUB metadata
        , Opt -> [String]
    optEpubFonts             :: [FilePath] -- ^ EPUB fonts to embed
        , Opt -> Int
    optEpubChapterLevel      :: Int     -- ^ Header level at which to split chapters
        , Opt -> Maybe String
    optEpubCoverImage        :: Maybe FilePath -- ^ Cover image for epub
        , Opt -> Int
    optTOCDepth              :: Int     -- ^ Number of levels to include in TOC
        , Opt -> Bool
    optDumpArgs              :: Bool    -- ^ Output command-line arguments
        , Opt -> Bool
    optIgnoreArgs            :: Bool    -- ^ Ignore command-line arguments
        , Opt -> Verbosity
    optVerbosity             :: Verbosity  -- ^ Verbosity of diagnostic output
        , Opt -> Bool
    optTrace                 :: Bool  -- ^ Enable tracing
        , Opt -> Maybe String
    optLogFile               :: Maybe FilePath -- ^ File to write JSON log output
        , Opt -> Bool
    optFailIfWarnings        :: Bool    -- ^ Fail on warnings
        , Opt -> Bool
    optReferenceLinks        :: Bool    -- ^ Use reference links in writing markdown, rst
        , Opt -> ReferenceLocation
    optReferenceLocation     :: ReferenceLocation -- ^ location for footnotes and link references in markdown output
        , Opt -> Int
    optDpi                   :: Int     -- ^ Dpi
        , Opt -> WrapOption
    optWrap                  :: WrapOption  -- ^ Options for wrapping text
        , Opt -> Int
    optColumns               :: Int     -- ^ Line length in characters
        , Opt -> [Filter]
    optFilters               :: [Filter] -- ^ Filters to apply
        , Opt -> ObfuscationMethod
    optEmailObfuscation      :: ObfuscationMethod
        , Opt -> Text
    optIdentifierPrefix      :: Text
        , Opt -> Bool
    optStripEmptyParagraphs  :: Bool -- ^ Strip empty paragraphs
        , Opt -> [Text]
    optIndentedCodeClasses   :: [Text] -- ^ Default classes for indented code blocks
        , Opt -> Maybe String
    optDataDir               :: Maybe FilePath
        , Opt -> CiteMethod
    optCiteMethod            :: CiteMethod -- ^ Method to output cites
        , Opt -> Bool
    optListings              :: Bool       -- ^ Use listings package for code blocks
        , Opt -> Maybe String
    optPdfEngine             :: Maybe String -- ^ Program to use for latex/html -> pdf
        , Opt -> [String]
    optPdfEngineOpts         :: [String]   -- ^ Flags to pass to the engine
        , Opt -> Maybe Int
    optSlideLevel            :: Maybe Int  -- ^ Header level that creates slides
        , Opt -> Bool
    optSetextHeaders         :: Bool       -- ^ Use atx headers for markdown level 1-2
        , Opt -> Bool
    optAscii                 :: Bool       -- ^ Prefer ascii output
        , Opt -> Text
    optDefaultImageExtension :: Text       -- ^ Default image extension
        , Opt -> Maybe String
    optExtractMedia          :: Maybe FilePath -- ^ Path to extract embedded media
        , Opt -> TrackChanges
    optTrackChanges          :: TrackChanges -- ^ Accept or reject MS Word track-changes.
        , Opt -> Bool
    optFileScope             :: Bool         -- ^ Parse input files before combining
        , Opt -> Maybe Text
    optTitlePrefix           :: Maybe Text     -- ^ Prefix for title
        , Opt -> [String]
    optCss                   :: [FilePath]       -- ^ CSS files to link to
        , Opt -> IpynbOutput
    optIpynbOutput           :: IpynbOutput      -- ^ How to treat ipynb output blocks
        , Opt -> [String]
    optIncludeBeforeBody     :: [FilePath]       -- ^ Files to include before
        , Opt -> [String]
    optIncludeAfterBody      :: [FilePath]       -- ^ Files to include after body
        , Opt -> [String]
    optIncludeInHeader       :: [FilePath]       -- ^ Files to include in header
        , Opt -> [String]
    optResourcePath          :: [FilePath] -- ^ Path to search for images etc
        , Opt -> [(Text, Text)]
    optRequestHeaders        :: [(Text, Text)] -- ^ Headers for HTTP requests
        , Opt -> LineEnding
    optEol                   :: LineEnding -- ^ Style of line-endings to use
        , Opt -> Bool
    optStripComments         :: Bool       -- ^ Skip HTML comments
        } deriving ((forall x. Opt -> Rep Opt x)
    -> (forall x. Rep Opt x -> Opt) -> Generic Opt
    forall x. Rep Opt x -> Opt
    forall x. Opt -> Rep Opt x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cto :: forall x. Rep Opt x -> Opt
    $cfrom :: forall x. Opt -> Rep Opt x
    Generic, Int -> Opt -> ShowS
    [Opt] -> ShowS
    Opt -> String
    (Int -> Opt -> ShowS)
    -> (Opt -> String) -> ([Opt] -> ShowS) -> Show Opt
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [Opt] -> ShowS
    $cshowList :: [Opt] -> ShowS
    show :: Opt -> String
    $cshow :: Opt -> String
    showsPrec :: Int -> Opt -> ShowS
    $cshowsPrec :: Int -> Opt -> ShowS
    Show)

    instance FromYAML (Opt -> Opt) where
      parseYAML :: Node Pos -> Parser (Opt -> Opt)
    parseYAML (Mapping _ _ m :: Mapping Pos
    m) =
        ((Opt -> Opt) -> (Opt -> Opt) -> Opt -> Opt)
    -> (Opt -> Opt) -> [Opt -> Opt] -> Opt -> Opt
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr (Opt -> Opt) -> (Opt -> Opt) -> Opt -> Opt
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    (.) Opt -> Opt
    forall a. a -> a
    id ([Opt -> Opt] -> Opt -> Opt)
    -> Parser [Opt -> Opt] -> Parser (Opt -> Opt)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ((Node Pos, Node Pos) -> Parser (Opt -> Opt))
    -> [(Node Pos, Node Pos)] -> Parser [Opt -> Opt]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM (Node Pos, Node Pos) -> Parser (Opt -> Opt)
    doOpt (Mapping Pos -> [(Node Pos, Node Pos)]
    forall k a. Map k a -> [(k, a)]
    M.toList Mapping Pos
    m)
      parseYAML n :: Node Pos
    n = Node Pos -> String -> Parser (Opt -> Opt)
    forall a. Node Pos -> String -> Parser a
    failAtNode Node Pos
    n "Expected a mapping"

    doOpt :: (Node Pos, Node Pos) -> Parser (Opt -> Opt)
    doOpt :: (Node Pos, Node Pos) -> Parser (Opt -> Opt)
    doOpt (k' :: Node Pos
    k',v :: Node Pos
    v) = do
      Text
    k <- case Node Pos
    k' of
             Scalar _ (SStr t :: Text
    t) -> Text -> Parser Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return Text
    t
             Scalar _ _ -> Node Pos -> String -> Parser Text
    forall a. Node Pos -> String -> Parser a
    failAtNode Node Pos
    k' "Non-string key"
             _ -> Node Pos -> String -> Parser Text
    forall a. Node Pos -> String -> Parser a
    failAtNode Node Pos
    k' "Non-scalar key"
      case Text
    k of
        "tab-stop" ->
          Node Pos -> Parser Int
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Int -> (Int -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Int
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optTabStop :: Int
    optTabStop = Int
    x })
        "preserve-tabs" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optPreserveTabs :: Bool
    optPreserveTabs = Bool
    x })
        "standalone" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optStandalone :: Bool
    optStandalone = Bool
    x })
        "table-of-contents" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optTableOfContents :: Bool
    optTableOfContents = Bool
    x })
        "toc" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optTableOfContents :: Bool
    optTableOfContents = Bool
    x })
        "from" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optFrom :: Maybe Text
    optFrom = Maybe Text
    x })
        "reader" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optFrom :: Maybe Text
    optFrom = Maybe Text
    x })
        "to" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optTo :: Maybe Text
    optTo = Maybe Text
    x })
        "writer" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optTo :: Maybe Text
    optTo = Maybe Text
    x })
        "shift-heading-level-by" ->
          Node Pos -> Parser Int
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Int -> (Int -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Int
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optShiftHeadingLevelBy :: Int
    optShiftHeadingLevelBy = Int
    x })
        "template" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optTemplate :: Maybe String
    optTemplate = Text -> String
    unpack (Text -> String) -> Maybe Text -> Maybe String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Text
    x })
        "variables" ->
          Node Pos -> Parser (Context Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Context Text)
    -> (Context Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Context Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optVariables :: Context Text
    optVariables =
                                                   Context Text
    x Context Text -> Context Text -> Context Text
    forall a. Semigroup a => a -> a -> a
    <> Opt -> Context Text
    optVariables Opt
    o })
          -- Note: x comes first because <> for Context is left-biased union
          -- and we want to favor later default files. See #5988.
        "metadata" ->
          Node Pos -> Parser (Context Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Context Text)
    -> (Context Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Context Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optMetadata :: Meta
    optMetadata = Opt -> Meta
    optMetadata Opt
    o Meta -> Meta -> Meta
    forall a. Semigroup a => a -> a -> a
    <>
                                                   Context Text -> Meta
    contextToMeta Context Text
    x })
        "metadata-files" ->
          Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Text]
    x ->
                            (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optMetadataFiles :: [String]
    optMetadataFiles =
                                               Opt -> [String]
    optMetadataFiles Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <>
                                               (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack [Text]
    x })
        "metadata-file" -> -- allow either a list or a single value
          (Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Text]
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optMetadataFiles :: [String]
    optMetadataFiles =
                                                    Opt -> [String]
    optMetadataFiles Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <>
                                                    (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack [Text]
    x }))
          Parser (Opt -> Opt) -> Parser (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|>
          (Node Pos -> Parser Text
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Text -> (Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Text
    x ->
                            (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optMetadataFiles :: [String]
    optMetadataFiles =
                                               Opt -> [String]
    optMetadataFiles Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <>[Text -> String
    unpack Text
    x] }))
        "output-file" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optOutputFile :: Maybe String
    optOutputFile = Text -> String
    unpack (Text -> String) -> Maybe Text -> Maybe String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Text
    x })
        "input-files" ->
          Node Pos -> Parser (Maybe [Text])
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe [Text])
    -> (Maybe [Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe [Text]
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optInputFiles :: Maybe [String]
    optInputFiles =
                                                  Opt -> Maybe [String]
    optInputFiles Opt
    o Maybe [String] -> Maybe [String] -> Maybe [String]
    forall a. Semigroup a => a -> a -> a
    <>
                                                    ((Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack ([Text] -> [String]) -> Maybe [Text] -> Maybe [String]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe [Text]
    x) })
        "input-file" -> -- allow either a list or a single value
          (Node Pos -> Parser (Maybe [Text])
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe [Text])
    -> (Maybe [Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe [Text]
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optInputFiles :: Maybe [String]
    optInputFiles =
                                                    Opt -> Maybe [String]
    optInputFiles Opt
    o Maybe [String] -> Maybe [String] -> Maybe [String]
    forall a. Semigroup a => a -> a -> a
    <>
                                                      ((Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack ([Text] -> [String]) -> Maybe [Text] -> Maybe [String]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe [Text]
    x) }))
          Parser (Opt -> Opt) -> Parser (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|>
          (Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optInputFiles :: Maybe [String]
    optInputFiles =
                                                    Opt -> Maybe [String]
    optInputFiles Opt
    o Maybe [String] -> Maybe [String] -> Maybe [String]
    forall a. Semigroup a => a -> a -> a
    <>
                                                    ((\z :: Text
    z -> [Text -> String
    unpack Text
    z]) (Text -> [String]) -> Maybe Text -> Maybe [String]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Text
    x)
                                                }))
        "number-sections" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optNumberSections :: Bool
    optNumberSections = Bool
    x })
        "number-offset" ->
          Node Pos -> Parser [Int]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Int]
    -> ([Int] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Int]
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optNumberOffset :: [Int]
    optNumberOffset = [Int]
    x })
        "section-divs" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optSectionDivs :: Bool
    optSectionDivs = Bool
    x })
        "incremental" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optIncremental :: Bool
    optIncremental = Bool
    x })
        "self-contained" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optSelfContained :: Bool
    optSelfContained = Bool
    x })
        "html-q-tags" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optHtmlQTags :: Bool
    optHtmlQTags = Bool
    x })
        "highlight-style" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optHighlightStyle :: Maybe Text
    optHighlightStyle = Maybe Text
    x })
        "syntax-definition" ->
          (Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Text]
    x ->
                    (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optSyntaxDefinitions :: [String]
    optSyntaxDefinitions =
                                       Opt -> [String]
    optSyntaxDefinitions Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <> (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack [Text]
    x }))
          Parser (Opt -> Opt) -> Parser (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|>
          (Node Pos -> Parser Text
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Text -> (Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Text
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optSyntaxDefinitions :: [String]
    optSyntaxDefinitions =
                                     Opt -> [String]
    optSyntaxDefinitions Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <> [Text -> String
    unpack Text
    x] }))
        "syntax-definitions" ->
          Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Text]
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optSyntaxDefinitions :: [String]
    optSyntaxDefinitions =
                                    Opt -> [String]
    optSyntaxDefinitions Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <> (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack [Text]
    x })
        "top-level-division" ->
          Node Pos -> Parser TopLevelDivision
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser TopLevelDivision
    -> (TopLevelDivision -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: TopLevelDivision
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optTopLevelDivision :: TopLevelDivision
    optTopLevelDivision = TopLevelDivision
    x })
        "html-math-method" ->
          Node Pos -> Parser HTMLMathMethod
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser HTMLMathMethod
    -> (HTMLMathMethod -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: HTMLMathMethod
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optHTMLMathMethod :: HTMLMathMethod
    optHTMLMathMethod = HTMLMathMethod
    x })
        "abbreviations" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optAbbreviations :: Maybe String
    optAbbreviations = Text -> String
    unpack (Text -> String) -> Maybe Text -> Maybe String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Text
    x })
        "reference-doc" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optReferenceDoc :: Maybe String
    optReferenceDoc = Text -> String
    unpack (Text -> String) -> Maybe Text -> Maybe String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Text
    x })
        "epub-subdirectory" ->
          Node Pos -> Parser Text
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Text -> (Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Text
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optEpubSubdirectory :: String
    optEpubSubdirectory = Text -> String
    unpack Text
    x })
        "epub-metadata" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optEpubMetadata :: Maybe String
    optEpubMetadata = Text -> String
    unpack (Text -> String) -> Maybe Text -> Maybe String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Text
    x })
        "epub-fonts" ->
          Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Text]
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optEpubFonts :: [String]
    optEpubFonts = Opt -> [String]
    optEpubFonts Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <>
                                                   (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack [Text]
    x })
        "epub-chapter-level" ->
          Node Pos -> Parser Int
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Int -> (Int -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Int
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optEpubChapterLevel :: Int
    optEpubChapterLevel = Int
    x })
        "epub-cover-image" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optEpubCoverImage :: Maybe String
    optEpubCoverImage = Text -> String
    unpack (Text -> String) -> Maybe Text -> Maybe String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Text
    x })
        "toc-depth" ->
          Node Pos -> Parser Int
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Int -> (Int -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Int
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optTOCDepth :: Int
    optTOCDepth = Int
    x })
        "dump-args" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optDumpArgs :: Bool
    optDumpArgs = Bool
    x })
        "ignore-args" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optIgnoreArgs :: Bool
    optIgnoreArgs = Bool
    x })
        "verbosity" ->
          Node Pos -> Parser Verbosity
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Verbosity
    -> (Verbosity -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Verbosity
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optVerbosity :: Verbosity
    optVerbosity = Verbosity
    x })
        "trace" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optTrace :: Bool
    optTrace = Bool
    x })
        "log-file" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optLogFile :: Maybe String
    optLogFile = Text -> String
    unpack (Text -> String) -> Maybe Text -> Maybe String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Text
    x })
        "fail-if-warnings" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optFailIfWarnings :: Bool
    optFailIfWarnings = Bool
    x })
        "reference-links" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optReferenceLinks :: Bool
    optReferenceLinks = Bool
    x })
        "reference-location" ->
          Node Pos -> Parser ReferenceLocation
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser ReferenceLocation
    -> (ReferenceLocation -> Parser (Opt -> Opt))
    -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: ReferenceLocation
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optReferenceLocation :: ReferenceLocation
    optReferenceLocation = ReferenceLocation
    x })
        "dpi" ->
          Node Pos -> Parser Int
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Int -> (Int -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Int
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optDpi :: Int
    optDpi = Int
    x })
        "wrap" ->
          Node Pos -> Parser WrapOption
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser WrapOption
    -> (WrapOption -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: WrapOption
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optWrap :: WrapOption
    optWrap = WrapOption
    x })
        "columns" ->
          Node Pos -> Parser Int
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Int -> (Int -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Int
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optColumns :: Int
    optColumns = Int
    x })
        "filters" ->
          Node Pos -> Parser [Filter]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Filter]
    -> ([Filter] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Filter]
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optFilters :: [Filter]
    optFilters = Opt -> [Filter]
    optFilters Opt
    o [Filter] -> [Filter] -> [Filter]
    forall a. Semigroup a => a -> a -> a
    <> [Filter]
    x })
        "email-obfuscation" ->
          Node Pos -> Parser ObfuscationMethod
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser ObfuscationMethod
    -> (ObfuscationMethod -> Parser (Opt -> Opt))
    -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: ObfuscationMethod
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optEmailObfuscation :: ObfuscationMethod
    optEmailObfuscation = ObfuscationMethod
    x })
        "identifier-prefix" ->
          Node Pos -> Parser Text
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Text -> (Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Text
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optIdentifierPrefix :: Text
    optIdentifierPrefix = Text
    x })
        "strip-empty-paragraphs" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optStripEmptyParagraphs :: Bool
    optStripEmptyParagraphs = Bool
    x })
        "indented-code-classes" ->
          Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Text]
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optIndentedCodeClasses :: [Text]
    optIndentedCodeClasses = [Text]
    x })
        "data-dir" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optDataDir :: Maybe String
    optDataDir = Text -> String
    unpack (Text -> String) -> Maybe Text -> Maybe String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Text
    x })
        "cite-method" ->
          Node Pos -> Parser CiteMethod
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser CiteMethod
    -> (CiteMethod -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: CiteMethod
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optCiteMethod :: CiteMethod
    optCiteMethod = CiteMethod
    x })
        "listings" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optListings :: Bool
    optListings = Bool
    x })
        "pdf-engine" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optPdfEngine :: Maybe String
    optPdfEngine = Text -> String
    unpack (Text -> String) -> Maybe Text -> Maybe String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Text
    x })
        "pdf-engine-opts" ->
          Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Text]
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optPdfEngineOpts :: [String]
    optPdfEngineOpts = (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack [Text]
    x })
        "pdf-engine-opt" ->
          (Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Text]
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optPdfEngineOpts :: [String]
    optPdfEngineOpts = (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack [Text]
    x }))
          Parser (Opt -> Opt) -> Parser (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|>
          (Node Pos -> Parser Text
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Text -> (Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Text
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optPdfEngineOpts :: [String]
    optPdfEngineOpts = [Text -> String
    unpack Text
    x] }))
        "slide-level" ->
          Node Pos -> Parser (Maybe Int)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Int)
    -> (Maybe Int -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Int
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optSlideLevel :: Maybe Int
    optSlideLevel = Maybe Int
    x })
        "atx-headers" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optSetextHeaders :: Bool
    optSetextHeaders = Bool -> Bool
    not Bool
    x })
        "ascii" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optAscii :: Bool
    optAscii = Bool
    x })
        "default-image-extension" ->
          Node Pos -> Parser Text
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Text -> (Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Text
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optDefaultImageExtension :: Text
    optDefaultImageExtension = Text
    x })
        "extract-media" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optExtractMedia :: Maybe String
    optExtractMedia = Text -> String
    unpack (Text -> String) -> Maybe Text -> Maybe String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Text
    x })
        "track-changes" ->
          Node Pos -> Parser TrackChanges
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser TrackChanges
    -> (TrackChanges -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: TrackChanges
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optTrackChanges :: TrackChanges
    optTrackChanges = TrackChanges
    x })
        "file-scope" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optFileScope :: Bool
    optFileScope = Bool
    x })
        "title-prefix" ->
          Node Pos -> Parser (Maybe Text)
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser (Maybe Text)
    -> (Maybe Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Maybe Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optTitlePrefix :: Maybe Text
    optTitlePrefix = Maybe Text
    x,
                                                 optStandalone :: Bool
    optStandalone = Bool
    True })
        "css" ->
          (Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Text]
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optCss :: [String]
    optCss = Opt -> [String]
    optCss Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <>
                                                     (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack [Text]
    x }))
          Parser (Opt -> Opt) -> Parser (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|>
          (Node Pos -> Parser Text
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Text -> (Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Text
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optCss :: [String]
    optCss = Opt -> [String]
    optCss Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <>
                                                    [Text -> String
    unpack Text
    x] }))
        "bibliography" ->
          do let addItem :: Text -> Opt -> Opt
    addItem x :: Text
    x o :: Opt
    o = Opt
    o{ optMetadata :: Meta
    optMetadata =
                                     String -> String -> Meta -> Meta
    addMeta "bibliography" (Text -> String
    T.unpack Text
    x)
                                        (Opt -> Meta
    optMetadata Opt
    o) }
             (Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \([Text]
    xs :: [Text]) -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return ((Opt -> Opt) -> Parser (Opt -> Opt))
    -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall a b. (a -> b) -> a -> b
    $ \o :: Opt
    o ->
                                                        (Text -> Opt -> Opt) -> Opt -> [Text] -> Opt
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr Text -> Opt -> Opt
    addItem Opt
    o [Text]
    xs)
              Parser (Opt -> Opt) -> Parser (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|>
              (Node Pos -> Parser Text
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Text -> (Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \(Text
    x :: Text) -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return ((Opt -> Opt) -> Parser (Opt -> Opt))
    -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall a b. (a -> b) -> a -> b
    $ \o :: Opt
    o -> Text -> Opt -> Opt
    addItem Text
    x Opt
    o)
        "csl" ->
          do let addItem :: Text -> Opt -> Opt
    addItem x :: Text
    x o :: Opt
    o = Opt
    o{ optMetadata :: Meta
    optMetadata =
                                     String -> String -> Meta -> Meta
    addMeta "csl" (Text -> String
    T.unpack Text
    x)
                                       (Opt -> Meta
    optMetadata Opt
    o) }
             (Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \([Text]
    xs :: [Text]) -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return ((Opt -> Opt) -> Parser (Opt -> Opt))
    -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall a b. (a -> b) -> a -> b
    $ \o :: Opt
    o ->
                                                        (Text -> Opt -> Opt) -> Opt -> [Text] -> Opt
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr Text -> Opt -> Opt
    addItem Opt
    o [Text]
    xs)
              Parser (Opt -> Opt) -> Parser (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|>
              (Node Pos -> Parser Text
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Text -> (Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \(Text
    x :: Text) -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return ((Opt -> Opt) -> Parser (Opt -> Opt))
    -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall a b. (a -> b) -> a -> b
    $ \o :: Opt
    o -> Text -> Opt -> Opt
    addItem Text
    x Opt
    o)
        "ipynb-output" ->
          Node Pos -> Parser IpynbOutput
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser IpynbOutput
    -> (IpynbOutput -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: IpynbOutput
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optIpynbOutput :: IpynbOutput
    optIpynbOutput = IpynbOutput
    x })
        "include-before-body" ->
          (Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Text]
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optIncludeBeforeBody :: [String]
    optIncludeBeforeBody =
                                    Opt -> [String]
    optIncludeBeforeBody Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <> (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack [Text]
    x }))
          Parser (Opt -> Opt) -> Parser (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|>
          (Node Pos -> Parser Text
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Text -> (Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Text
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optIncludeBeforeBody :: [String]
    optIncludeBeforeBody =
                                    Opt -> [String]
    optIncludeBeforeBody Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <> [Text -> String
    unpack Text
    x] }))
        "include-after-body" ->
          (Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Text]
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optIncludeAfterBody :: [String]
    optIncludeAfterBody =
                                    Opt -> [String]
    optIncludeAfterBody Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <> (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack [Text]
    x }))
          Parser (Opt -> Opt) -> Parser (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|>
          (Node Pos -> Parser Text
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Text -> (Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Text
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optIncludeAfterBody :: [String]
    optIncludeAfterBody =
                                    Opt -> [String]
    optIncludeAfterBody Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <> [Text -> String
    unpack Text
    x] }))
        "include-in-header" ->
          (Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Text]
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optIncludeInHeader :: [String]
    optIncludeInHeader =
                                    Opt -> [String]
    optIncludeInHeader Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <> (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack [Text]
    x }))
          Parser (Opt -> Opt) -> Parser (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|>
          (Node Pos -> Parser Text
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Text -> (Text -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Text
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optIncludeInHeader :: [String]
    optIncludeInHeader =
                                    Opt -> [String]
    optIncludeInHeader Opt
    o [String] -> [String] -> [String]
    forall a. Semigroup a => a -> a -> a
    <> [Text -> String
    unpack Text
    x] }))
        "resource-path" ->
          Node Pos -> Parser [Text]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [Text]
    -> ([Text] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Text]
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optResourcePath :: [String]
    optResourcePath = (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    unpack [Text]
    x })
        "request-headers" ->
          Node Pos -> Parser [(Text, Text)]
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser [(Text, Text)]
    -> ([(Text, Text)] -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [(Text, Text)]
    x ->
                 (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optRequestHeaders :: [(Text, Text)]
    optRequestHeaders = [(Text, Text)]
    x })
        "eol" ->
          Node Pos -> Parser LineEnding
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser LineEnding
    -> (LineEnding -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: LineEnding
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o{ optEol :: LineEnding
    optEol = LineEnding
    x })
        "strip-comments" ->
          Node Pos -> Parser Bool
    forall a. FromYAML a => Node Pos -> Parser a
    parseYAML Node Pos
    v Parser Bool -> (Bool -> Parser (Opt -> Opt)) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: Bool
    x -> (Opt -> Opt) -> Parser (Opt -> Opt)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (\o :: Opt
    o -> Opt
    o  { optStripComments :: Bool
    optStripComments = Bool
    x })
        _ -> Node Pos -> String -> Parser (Opt -> Opt)
    forall a. Node Pos -> String -> Parser a
    failAtNode Node Pos
    k' (String -> Parser (Opt -> Opt)) -> String -> Parser (Opt -> Opt)
    forall a b. (a -> b) -> a -> b
    $ "Unknown option " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ Text -> String
    forall a. Show a => a -> String
    show Text
    k

    -- | Defaults for command-line options.
    defaultOpts :: Opt
    defaultOpts :: Opt
    defaultOpts = Opt :: Int
    -> Bool
    -> Bool
    -> Maybe Text
    -> Maybe Text
    -> Bool
    -> Int
    -> Maybe String
    -> Context Text
    -> Meta
    -> [String]
    -> Maybe String
    -> Maybe [String]
    -> Bool
    -> [Int]
    -> Bool
    -> Bool
    -> Bool
    -> Bool
    -> Maybe Text
    -> [String]
    -> TopLevelDivision
    -> HTMLMathMethod
    -> Maybe String
    -> Maybe String
    -> String
    -> Maybe String
    -> [String]
    -> Int
    -> Maybe String
    -> Int
    -> Bool
    -> Bool
    -> Verbosity
    -> Bool
    -> Maybe String
    -> Bool
    -> Bool
    -> ReferenceLocation
    -> Int
    -> WrapOption
    -> Int
    -> [Filter]
    -> ObfuscationMethod
    -> Text
    -> Bool
    -> [Text]
    -> Maybe String
    -> CiteMethod
    -> Bool
    -> Maybe String
    -> [String]
    -> Maybe Int
    -> Bool
    -> Bool
    -> Text
    -> Maybe String
    -> TrackChanges
    -> Bool
    -> Maybe Text
    -> [String]
    -> IpynbOutput
    -> [String]
    -> [String]
    -> [String]
    -> [String]
    -> [(Text, Text)]
    -> LineEnding
    -> Bool
    -> Opt
    Opt
        { optTabStop :: Int
    optTabStop               = 4
        , optPreserveTabs :: Bool
    optPreserveTabs          = Bool
    False
        , optStandalone :: Bool
    optStandalone            = Bool
    False
        , optFrom :: Maybe Text
    optFrom                  = Maybe Text
    forall a. Maybe a
    Nothing
        , optTo :: Maybe Text
    optTo                    = Maybe Text
    forall a. Maybe a
    Nothing
        , optTableOfContents :: Bool
    optTableOfContents       = Bool
    False
        , optShiftHeadingLevelBy :: Int
    optShiftHeadingLevelBy   = 0
        , optTemplate :: Maybe String
    optTemplate              = Maybe String
    forall a. Maybe a
    Nothing
        , optVariables :: Context Text
    optVariables             = Context Text
    forall a. Monoid a => a
    mempty
        , optMetadata :: Meta
    optMetadata              = Meta
    forall a. Monoid a => a
    mempty
        , optMetadataFiles :: [String]
    optMetadataFiles         = []
        , optOutputFile :: Maybe String
    optOutputFile            = Maybe String
    forall a. Maybe a
    Nothing
        , optInputFiles :: Maybe [String]
    optInputFiles            = Maybe [String]
    forall a. Maybe a
    Nothing
        , optNumberSections :: Bool
    optNumberSections        = Bool
    False
        , optNumberOffset :: [Int]
    optNumberOffset          = [0,0,0,0,0,0]
        , optSectionDivs :: Bool
    optSectionDivs           = Bool
    False
        , optIncremental :: Bool
    optIncremental           = Bool
    False
        , optSelfContained :: Bool
    optSelfContained         = Bool
    False
        , optHtmlQTags :: Bool
    optHtmlQTags             = Bool
    False
        , optHighlightStyle :: Maybe Text
    optHighlightStyle        = Text -> Maybe Text
    forall a. a -> Maybe a
    Just "pygments"
        , optSyntaxDefinitions :: [String]
    optSyntaxDefinitions     = []
        , optTopLevelDivision :: TopLevelDivision
    optTopLevelDivision      = TopLevelDivision
    TopLevelDefault
        , optHTMLMathMethod :: HTMLMathMethod
    optHTMLMathMethod        = HTMLMathMethod
    PlainMath
        , optAbbreviations :: Maybe String
    optAbbreviations         = Maybe String
    forall a. Maybe a
    Nothing
        , optReferenceDoc :: Maybe String
    optReferenceDoc          = Maybe String
    forall a. Maybe a
    Nothing
        , optEpubSubdirectory :: String
    optEpubSubdirectory      = "EPUB"
        , optEpubMetadata :: Maybe String
    optEpubMetadata          = Maybe String
    forall a. Maybe a
    Nothing
        , optEpubFonts :: [String]
    optEpubFonts             = []
        , optEpubChapterLevel :: Int
    optEpubChapterLevel      = 1
        , optEpubCoverImage :: Maybe String
    optEpubCoverImage        = Maybe String
    forall a. Maybe a
    Nothing
        , optTOCDepth :: Int
    optTOCDepth              = 3
        , optDumpArgs :: Bool
    optDumpArgs              = Bool
    False
        , optIgnoreArgs :: Bool
    optIgnoreArgs            = Bool
    False
        , optVerbosity :: Verbosity
    optVerbosity             = Verbosity
    WARNING
        , optTrace :: Bool
    optTrace                 = Bool
    False
        , optLogFile :: Maybe String
    optLogFile               = Maybe String
    forall a. Maybe a
    Nothing
        , optFailIfWarnings :: Bool
    optFailIfWarnings        = Bool
    False
        , optReferenceLinks :: Bool
    optReferenceLinks        = Bool
    False
        , optReferenceLocation :: ReferenceLocation
    optReferenceLocation     = ReferenceLocation
    EndOfDocument
        , optDpi :: Int
    optDpi                   = 96
        , optWrap :: WrapOption
    optWrap                  = WrapOption
    WrapAuto
        , optColumns :: Int
    optColumns               = 72
        , optFilters :: [Filter]
    optFilters               = []
        , optEmailObfuscation :: ObfuscationMethod
    optEmailObfuscation      = ObfuscationMethod
    NoObfuscation
        , optIdentifierPrefix :: Text
    optIdentifierPrefix      = ""
        , optStripEmptyParagraphs :: Bool
    optStripEmptyParagraphs  = Bool
    False
        , optIndentedCodeClasses :: [Text]
    optIndentedCodeClasses   = []
        , optDataDir :: Maybe String
    optDataDir               = Maybe String
    forall a. Maybe a
    Nothing
        , optCiteMethod :: CiteMethod
    optCiteMethod            = CiteMethod
    Citeproc
        , optListings :: Bool
    optListings              = Bool
    False
        , optPdfEngine :: Maybe String
    optPdfEngine             = Maybe String
    forall a. Maybe a
    Nothing
        , optPdfEngineOpts :: [String]
    optPdfEngineOpts         = []
        , optSlideLevel :: Maybe Int
    optSlideLevel            = Maybe Int
    forall a. Maybe a
    Nothing
        , optSetextHeaders :: Bool
    optSetextHeaders         = Bool
    True
        , optAscii :: Bool
    optAscii                 = Bool
    False
        , optDefaultImageExtension :: Text
    optDefaultImageExtension = ""
        , optExtractMedia :: Maybe String
    optExtractMedia          = Maybe String
    forall a. Maybe a
    Nothing
        , optTrackChanges :: TrackChanges
    optTrackChanges          = TrackChanges
    AcceptChanges
        , optFileScope :: Bool
    optFileScope             = Bool
    False
        , optTitlePrefix :: Maybe Text
    optTitlePrefix           = Maybe Text
    forall a. Maybe a
    Nothing
        , optCss :: [String]
    optCss                   = []
        , optIpynbOutput :: IpynbOutput
    optIpynbOutput           = IpynbOutput
    IpynbOutputBest
        , optIncludeBeforeBody :: [String]
    optIncludeBeforeBody     = []
        , optIncludeAfterBody :: [String]
    optIncludeAfterBody      = []
        , optIncludeInHeader :: [String]
    optIncludeInHeader       = []
        , optResourcePath :: [String]
    optResourcePath          = ["."]
        , optRequestHeaders :: [(Text, Text)]
    optRequestHeaders        = []
        , optEol :: LineEnding
    optEol                   = LineEnding
    Native
        , optStripComments :: Bool
    optStripComments         = Bool
    False
        }

    contextToMeta :: Context Text -> Meta
    contextToMeta :: Context Text -> Meta
    contextToMeta (Context m :: Map Text (Val Text)
    m) =
      Map Text MetaValue -> Meta
    Meta (Map Text MetaValue -> Meta)
    -> (Map Text (Val Text) -> Map Text MetaValue)
    -> Map Text (Val Text)
    -> Meta
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Val Text -> MetaValue)
    -> Map Text (Val Text) -> Map Text MetaValue
    forall a b k. (a -> b) -> Map k a -> Map k b
    M.map Val Text -> MetaValue
    valToMetaVal (Map Text (Val Text) -> Meta) -> Map Text (Val Text) -> Meta
    forall a b. (a -> b) -> a -> b
    $ Map Text (Val Text)
    m

    valToMetaVal :: Val Text -> MetaValue
    valToMetaVal :: Val Text -> MetaValue
    valToMetaVal (MapVal (Context m :: Map Text (Val Text)
    m)) =
      Map Text MetaValue -> MetaValue
    MetaMap (Map Text MetaValue -> MetaValue)
    -> (Map Text (Val Text) -> Map Text MetaValue)
    -> Map Text (Val Text)
    -> MetaValue
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Val Text -> MetaValue)
    -> Map Text (Val Text) -> Map Text MetaValue
    forall a b k. (a -> b) -> Map k a -> Map k b
    M.map Val Text -> MetaValue
    valToMetaVal (Map Text (Val Text) -> MetaValue)
    -> Map Text (Val Text) -> MetaValue
    forall a b. (a -> b) -> a -> b
    $ Map Text (Val Text)
    m
    valToMetaVal (ListVal xs :: [Val Text]
    xs) = [MetaValue] -> MetaValue
    MetaList ([MetaValue] -> MetaValue) -> [MetaValue] -> MetaValue
    forall a b. (a -> b) -> a -> b
    $ (Val Text -> MetaValue) -> [Val Text] -> [MetaValue]
    forall a b. (a -> b) -> [a] -> [b]
    map Val Text -> MetaValue
    valToMetaVal [Val Text]
    xs
    valToMetaVal (SimpleVal d :: Doc Text
    d) = Text -> MetaValue
    MetaString (Text -> MetaValue) -> Text -> MetaValue
    forall a b. (a -> b) -> a -> b
    $ Maybe Int -> Doc Text -> Text
    forall a. HasChars a => Maybe Int -> Doc a -> a
    render Maybe Int
    forall a. Maybe a
    Nothing Doc Text
    d
    valToMetaVal NullVal = Text -> MetaValue
    MetaString ""

    addMeta :: String -> String -> Meta -> Meta
    addMeta :: String -> String -> Meta -> Meta
    addMeta k :: String
    k v :: String
    v meta :: Meta
    meta =
      case Text -> Meta -> Maybe MetaValue
    lookupMeta Text
    k' Meta
    meta of
           Nothing -> Text -> MetaValue -> Meta -> Meta
    forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
    setMeta Text
    k' MetaValue
    v' Meta
    meta
           Just (MetaList xs :: [MetaValue]
    xs) ->
                      Text -> MetaValue -> Meta -> Meta
    forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
    setMeta Text
    k' ([MetaValue] -> MetaValue
    MetaList ([MetaValue]
    xs [MetaValue] -> [MetaValue] -> [MetaValue]
    forall a. [a] -> [a] -> [a]
    ++ [MetaValue
    v'])) Meta
    meta
           Just x :: MetaValue
    x  -> Text -> MetaValue -> Meta -> Meta
    forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
    setMeta Text
    k' ([MetaValue] -> MetaValue
    MetaList [MetaValue
    x, MetaValue
    v']) Meta
    meta
     where
      v' :: MetaValue
    v' = String -> MetaValue
    readMetaValue String
    v
      k' :: Text
    k' = String -> Text
    T.pack String
    k

    readMetaValue :: String -> MetaValue
    readMetaValue :: String -> MetaValue
    readMetaValue s :: String
    s
      | String
    s String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == "true"  = Bool -> MetaValue
    MetaBool Bool
    True
      | String
    s String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == "True"  = Bool -> MetaValue
    MetaBool Bool
    True
      | String
    s String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == "TRUE"  = Bool -> MetaValue
    MetaBool Bool
    True
      | String
    s String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == "false" = Bool -> MetaValue
    MetaBool Bool
    False
      | String
    s String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == "False" = Bool -> MetaValue
    MetaBool Bool
    False
      | String
    s String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == "FALSE" = Bool -> MetaValue
    MetaBool Bool
    False
      | Bool
    otherwise    = Text -> MetaValue
    MetaString (Text -> MetaValue) -> Text -> MetaValue
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack String
    s

    -- see https://github.com/jgm/pandoc/pull/4083
    -- using generic deriving caused long compilation times
    $(deriveJSON
       defaultOptions{ fieldLabelModifier = drop 11 . map toLower } ''IpynbOutput)
    $(deriveJSON
       defaultOptions{ fieldLabelModifier = map toLower } ''LineEnding)
    $(deriveJSON
       defaultOptions{ fieldLabelModifier =
                          camelCaseStrToHyphenated . dropWhile isLower
                     } ''Opt)