    {-# LANGUAGE OverloadedStrings #-}
    {- |
       Module      : Text.Pandoc.Readers.Org.ExportSettings
       Copyright   : © 2016–2020 Albert Krewinkel
       License     : GNU GPL, version 2 or above

       Maintainer  : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>

    Parsers for Org-mode export options.
    -}
    module Text.Pandoc.Readers.Org.ExportSettings
      ( exportSettings
      ) where

    import Text.Pandoc.Class.PandocMonad (PandocMonad, report)
    import Text.Pandoc.Logging (LogMessage (UnknownOrgExportOption))
    import Text.Pandoc.Readers.Org.ParserState
    import Text.Pandoc.Readers.Org.Parsing

    import Control.Monad (mzero, void)
    import Data.Char (toLower)
    import Data.Maybe (listToMaybe)
    import Data.Text (Text)

    -- | Read and handle space separated org-mode export settings.
    exportSettings :: PandocMonad m => OrgParser m ()
    exportSettings :: OrgParser m ()
    exportSettings = ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [()]
    -> OrgParser m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [()]
     -> OrgParser m ())
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [()]
    -> OrgParser m ()
    forall a b. (a -> b) -> a -> b
    $ OrgParser m ()
    -> OrgParser m ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [()]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    sepBy OrgParser m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces OrgParser m ()
    forall (m :: * -> *). PandocMonad m => OrgParser m ()
    exportSetting

    -- | Setter function for export settings.
    type ExportSettingSetter a = a -> ExportSettings -> ExportSettings

    -- | Read and process a single org-mode export option.
    exportSetting :: PandocMonad m => OrgParser m ()
    exportSetting :: OrgParser m ()
    exportSetting = [OrgParser m ()] -> OrgParser m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice
      [ Text -> ExportSettingSetter Bool -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text -> ExportSettingSetter Bool -> OrgParser m ()
    booleanSetting "^" (\val :: Bool
    val es :: ExportSettings
    es -> ExportSettings
    es { exportSubSuperscripts :: Bool
    exportSubSuperscripts = Bool
    val })
      , Text -> ExportSettingSetter Bool -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text -> ExportSettingSetter Bool -> OrgParser m ()
    booleanSetting "'" (\val :: Bool
    val es :: ExportSettings
    es -> ExportSettings
    es { exportSmartQuotes :: Bool
    exportSmartQuotes = Bool
    val })
      , Text -> ExportSettingSetter Bool -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text -> ExportSettingSetter Bool -> OrgParser m ()
    booleanSetting "*" (\val :: Bool
    val es :: ExportSettings
    es -> ExportSettings
    es { exportEmphasizedText :: Bool
    exportEmphasizedText = Bool
    val })
      , Text -> ExportSettingSetter Bool -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text -> ExportSettingSetter Bool -> OrgParser m ()
    booleanSetting "-" (\val :: Bool
    val es :: ExportSettings
    es -> ExportSettings
    es { exportSpecialStrings :: Bool
    exportSpecialStrings = Bool
    val })
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting ":"
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "<"
      , Text -> ExportSettingSetter Bool -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text -> ExportSettingSetter Bool -> OrgParser m ()
    booleanSetting "\\n" (\val :: Bool
    val es :: ExportSettings
    es -> ExportSettings
    es { exportPreserveBreaks :: Bool
    exportPreserveBreaks = Bool
    val })
      , Text -> ExportSettingSetter ArchivedTreesOption -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text -> ExportSettingSetter ArchivedTreesOption -> OrgParser m ()
    archivedTreeSetting "arch" (\val :: ArchivedTreesOption
    val es :: ExportSettings
    es -> ExportSettings
    es { exportArchivedTrees :: ArchivedTreesOption
    exportArchivedTrees = ArchivedTreesOption
    val })
      , Text -> ExportSettingSetter Bool -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text -> ExportSettingSetter Bool -> OrgParser m ()
    booleanSetting "author" (\val :: Bool
    val es :: ExportSettings
    es -> ExportSettings
    es { exportWithAuthor :: Bool
    exportWithAuthor = Bool
    val })
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "c"
      -- org-mode allows the special value `comment` for creator, which we'll
      -- interpret as true as it doesn't make sense in the context of Pandoc.
      , Text -> ExportSettingSetter Bool -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text -> ExportSettingSetter Bool -> OrgParser m ()
    booleanSetting "creator" (\val :: Bool
    val es :: ExportSettings
    es -> ExportSettings
    es { exportWithCreator :: Bool
    exportWithCreator = Bool
    val })
      , Text
    -> ExportSettingSetter (Either [Text] [Text]) -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text
    -> ExportSettingSetter (Either [Text] [Text]) -> OrgParser m ()
    complementableListSetting "d" (\val :: Either [Text] [Text]
    val es :: ExportSettings
    es -> ExportSettings
    es { exportDrawers :: Either [Text] [Text]
    exportDrawers = Either [Text] [Text]
    val })
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "date"
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "e"
      , Text -> ExportSettingSetter Bool -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text -> ExportSettingSetter Bool -> OrgParser m ()
    booleanSetting "email" (\val :: Bool
    val es :: ExportSettings
    es -> ExportSettings
    es { exportWithEmail :: Bool
    exportWithEmail = Bool
    val })
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "f"
      , Text -> ExportSettingSetter Int -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text -> ExportSettingSetter Int -> OrgParser m ()
    integerSetting "H" (\val :: Int
    val es :: ExportSettings
    es -> ExportSettings
    es { exportHeadlineLevels :: Int
    exportHeadlineLevels = Int
    val })
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "inline"
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "num"
      , Text -> ExportSettingSetter Bool -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text -> ExportSettingSetter Bool -> OrgParser m ()
    booleanSetting "p" (\val :: Bool
    val es :: ExportSettings
    es -> ExportSettings
    es { exportWithPlanning :: Bool
    exportWithPlanning = Bool
    val })
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "pri"
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "prop"
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "stat"
      , Text -> ExportSettingSetter Bool -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text -> ExportSettingSetter Bool -> OrgParser m ()
    booleanSetting "tags" (\val :: Bool
    val es :: ExportSettings
    es -> ExportSettings
    es { exportWithTags :: Bool
    exportWithTags = Bool
    val })
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "tasks"
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "tex"
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "timestamp"
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "title"
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "toc"
      , Text -> ExportSettingSetter Bool -> OrgParser m ()
    forall (m :: * -> *).
    Monad m =>
    Text -> ExportSettingSetter Bool -> OrgParser m ()
    booleanSetting "todo" (\val :: Bool
    val es :: ExportSettings
    es -> ExportSettings
    es { exportWithTodoKeywords :: Bool
    exportWithTodoKeywords = Bool
    val })
      , Text -> OrgParser m ()
    forall (m :: * -> *). Monad m => Text -> OrgParser m ()
    ignoredSetting "|"
      , OrgParser m ()
    forall (m :: * -> *). PandocMonad m => OrgParser m ()
    ignoreAndWarn
      ] OrgParser m () -> String -> OrgParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> String -> ParsecT s u m a
    <?> "export setting"

    genericExportSetting :: Monad m
                         => OrgParser m a
                         -> Text
                         -> ExportSettingSetter a
                         -> OrgParser m ()
    genericExportSetting :: OrgParser m a -> Text -> ExportSettingSetter a -> OrgParser m ()
    genericExportSetting optionParser :: OrgParser m a
    optionParser settingIdentifier :: Text
    settingIdentifier setter :: ExportSettingSetter a
    setter = OrgParser m () -> OrgParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m () -> OrgParser m ())
    -> OrgParser m () -> OrgParser m ()
    forall a b. (a -> b) -> a -> b
    $ do
      Char
    _     <- Text -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Text -> ParsecT s u m Text
    textStr Text
    settingIdentifier ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':'
      a
    value <- OrgParser m a
    optionParser
      (OrgParserState -> OrgParserState) -> OrgParser m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((OrgParserState -> OrgParserState) -> OrgParser m ())
    -> (OrgParserState -> OrgParserState) -> OrgParser m ()
    forall a b. (a -> b) -> a -> b
    $ a -> OrgParserState -> OrgParserState
    modifyExportSettings a
    value
     where
       modifyExportSettings :: a -> OrgParserState -> OrgParserState
    modifyExportSettings val :: a
    val st :: OrgParserState
    st =
         OrgParserState
    st { orgStateExportSettings :: ExportSettings
    orgStateExportSettings = ExportSettingSetter a
    setter a
    val (ExportSettings -> ExportSettings)
    -> (OrgParserState -> ExportSettings)
    -> OrgParserState
    -> ExportSettings
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OrgParserState -> ExportSettings
    orgStateExportSettings (OrgParserState -> ExportSettings)
    -> OrgParserState -> ExportSettings
    forall a b. (a -> b) -> a -> b
    $ OrgParserState
    st }

    -- | A boolean option, either nil (False) or non-nil (True).
    booleanSetting :: Monad m => Text ->  ExportSettingSetter Bool -> OrgParser m ()
    booleanSetting :: Text -> ExportSettingSetter Bool -> OrgParser m ()
    booleanSetting = OrgParser m Bool
    -> Text -> ExportSettingSetter Bool -> OrgParser m ()
    forall (m :: * -> *) a.
    Monad m =>
    OrgParser m a -> Text -> ExportSettingSetter a -> OrgParser m ()
    genericExportSetting OrgParser m Bool
    forall (m :: * -> *). Monad m => OrgParser m Bool
    elispBoolean

    -- | An integer-valued option.
    integerSetting :: Monad m => Text -> ExportSettingSetter Int -> OrgParser m ()
    integerSetting :: Text -> ExportSettingSetter Int -> OrgParser m ()
    integerSetting = OrgParser m Int
    -> Text -> ExportSettingSetter Int -> OrgParser m ()
    forall (m :: * -> *) a.
    Monad m =>
    OrgParser m a -> Text -> ExportSettingSetter a -> OrgParser m ()
    genericExportSetting OrgParser m Int
    forall u. ParsecT Text u (ReaderT OrgParserLocal m) Int
    parseInt
     where
       parseInt :: ParsecT Text u (ReaderT OrgParserLocal m) Int
    parseInt = ParsecT Text u (ReaderT OrgParserLocal m) Int
    -> ParsecT Text u (ReaderT OrgParserLocal m) Int
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text u (ReaderT OrgParserLocal m) Int
     -> ParsecT Text u (ReaderT OrgParserLocal m) Int)
    -> ParsecT Text u (ReaderT OrgParserLocal m) Int
    -> ParsecT Text u (ReaderT OrgParserLocal m) Int
    forall a b. (a -> b) -> a -> b
    $
         ParsecT Text u (ReaderT OrgParserLocal m) Char
    -> ParsecT Text u (ReaderT OrgParserLocal m) String
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 ParsecT Text u (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    digit ParsecT Text u (ReaderT OrgParserLocal m) String
    -> (String -> ParsecT Text u (ReaderT OrgParserLocal m) Int)
    -> ParsecT Text u (ReaderT OrgParserLocal m) Int
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= ParsecT Text u (ReaderT OrgParserLocal m) Int
    -> ((Int, String) -> ParsecT Text u (ReaderT OrgParserLocal m) Int)
    -> Maybe (Int, String)
    -> ParsecT Text u (ReaderT OrgParserLocal m) Int
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe ParsecT Text u (ReaderT OrgParserLocal m) Int
    forall (m :: * -> *) a. MonadPlus m => m a
    mzero (Int -> ParsecT Text u (ReaderT OrgParserLocal m) Int
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Int -> ParsecT Text u (ReaderT OrgParserLocal m) Int)
    -> ((Int, String) -> Int)
    -> (Int, String)
    -> ParsecT Text u (ReaderT OrgParserLocal m) Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Int, String) -> Int
    forall a b. (a, b) -> a
    fst) (Maybe (Int, String)
     -> ParsecT Text u (ReaderT OrgParserLocal m) Int)
    -> (String -> Maybe (Int, String))
    -> String
    -> ParsecT Text u (ReaderT OrgParserLocal m) Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [(Int, String)] -> Maybe (Int, String)
    forall a. [a] -> Maybe a
    listToMaybe ([(Int, String)] -> Maybe (Int, String))
    -> (String -> [(Int, String)]) -> String -> Maybe (Int, String)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> [(Int, String)]
    forall a. Read a => ReadS a
    reads

    -- | Either the string "headline" or an elisp boolean and treated as an
    -- @ArchivedTreesOption@.
    archivedTreeSetting :: Monad m
                        => Text
                        -> ExportSettingSetter ArchivedTreesOption
                        -> OrgParser m ()
    archivedTreeSetting :: Text -> ExportSettingSetter ArchivedTreesOption -> OrgParser m ()
    archivedTreeSetting =
      OrgParser m ArchivedTreesOption
    -> Text
    -> ExportSettingSetter ArchivedTreesOption
    -> OrgParser m ()
    forall (m :: * -> *) a.
    Monad m =>
    OrgParser m a -> Text -> ExportSettingSetter a -> OrgParser m ()
    genericExportSetting (OrgParser m ArchivedTreesOption
     -> Text
     -> ExportSettingSetter ArchivedTreesOption
     -> OrgParser m ())
    -> OrgParser m ArchivedTreesOption
    -> Text
    -> ExportSettingSetter ArchivedTreesOption
    -> OrgParser m ()
    forall a b. (a -> b) -> a -> b
    $ OrgParser m ArchivedTreesOption
    archivedTreesHeadlineSetting OrgParser m ArchivedTreesOption
    -> OrgParser m ArchivedTreesOption
    -> OrgParser m ArchivedTreesOption
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> OrgParser m ArchivedTreesOption
    archivedTreesBoolean
     where
       archivedTreesHeadlineSetting :: OrgParser m ArchivedTreesOption
    archivedTreesHeadlineSetting = OrgParser m ArchivedTreesOption -> OrgParser m ArchivedTreesOption
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m ArchivedTreesOption
     -> OrgParser m ArchivedTreesOption)
    -> OrgParser m ArchivedTreesOption
    -> OrgParser m ArchivedTreesOption
    forall a b. (a -> b) -> a -> b
    $ do
         String
    _ <- String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string "headline"
         ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall (m :: * -> *). Monad m => OrgParser m Char
    newline ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar)
         ArchivedTreesOption -> OrgParser m ArchivedTreesOption
    forall (m :: * -> *) a. Monad m => a -> m a
    return ArchivedTreesOption
    ArchivedTreesHeadlineOnly

       archivedTreesBoolean :: OrgParser m ArchivedTreesOption
    archivedTreesBoolean = OrgParser m ArchivedTreesOption -> OrgParser m ArchivedTreesOption
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m ArchivedTreesOption
     -> OrgParser m ArchivedTreesOption)
    -> OrgParser m ArchivedTreesOption
    -> OrgParser m ArchivedTreesOption
    forall a b. (a -> b) -> a -> b
    $ do
         Bool
    exportBool <- OrgParser m Bool
    forall (m :: * -> *). Monad m => OrgParser m Bool
    elispBoolean
         ArchivedTreesOption -> OrgParser m ArchivedTreesOption
    forall (m :: * -> *) a. Monad m => a -> m a
    return (ArchivedTreesOption -> OrgParser m ArchivedTreesOption)
    -> ArchivedTreesOption -> OrgParser m ArchivedTreesOption
    forall a b. (a -> b) -> a -> b
    $
           if Bool
    exportBool
           then ArchivedTreesOption
    ArchivedTreesExport
           else ArchivedTreesOption
    ArchivedTreesNoExport

    -- | A list or a complement list (i.e. a list starting with `not`).
    complementableListSetting :: Monad m
                              => Text
                              -> ExportSettingSetter (Either [Text] [Text])
                              -> OrgParser m ()
    complementableListSetting :: Text
    -> ExportSettingSetter (Either [Text] [Text]) -> OrgParser m ()
    complementableListSetting = OrgParser m (Either [Text] [Text])
    -> Text
    -> ExportSettingSetter (Either [Text] [Text])
    -> OrgParser m ()
    forall (m :: * -> *) a.
    Monad m =>
    OrgParser m a -> Text -> ExportSettingSetter a -> OrgParser m ()
    genericExportSetting (OrgParser m (Either [Text] [Text])
     -> Text
     -> ExportSettingSetter (Either [Text] [Text])
     -> OrgParser m ())
    -> OrgParser m (Either [Text] [Text])
    -> Text
    -> ExportSettingSetter (Either [Text] [Text])
    -> OrgParser m ()
    forall a b. (a -> b) -> a -> b
    $ [OrgParser m (Either [Text] [Text])]
    -> OrgParser m (Either [Text] [Text])
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice
      [ [Text] -> Either [Text] [Text]
    forall a b. a -> Either a b
    Left  ([Text] -> Either [Text] [Text])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Text]
    -> OrgParser m (Either [Text] [Text])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Text]
    forall (m :: * -> *). Monad m => OrgParser m [Text]
    complementTextList
      , [Text] -> Either [Text] [Text]
    forall a b. b -> Either a b
    Right ([Text] -> Either [Text] [Text])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Text]
    -> OrgParser m (Either [Text] [Text])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Text]
    forall (m :: * -> *). Monad m => OrgParser m [Text]
    stringList
      , (\b :: Bool
    b -> if Bool
    b then [Text] -> Either [Text] [Text]
    forall a b. a -> Either a b
    Left [] else [Text] -> Either [Text] [Text]
    forall a b. b -> Either a b
    Right []) (Bool -> Either [Text] [Text])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    -> OrgParser m (Either [Text] [Text])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (m :: * -> *). Monad m => OrgParser m Bool
    elispBoolean
      ]
     where
       -- Read a plain list of strings.
       stringList :: Monad m => OrgParser m [Text]
       stringList :: OrgParser m [Text]
    stringList = OrgParser m [Text] -> OrgParser m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m [Text] -> OrgParser m [Text])
    -> OrgParser m [Text] -> OrgParser m [Text]
    forall a b. (a -> b) -> a -> b
    $
         Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '('
           ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m [Text] -> OrgParser m [Text]
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m [Text]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    sepBy ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *). Monad m => OrgParser m Text
    elispText ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    spaces
           OrgParser m [Text]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m [Text]
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ')'

       -- Read an emacs lisp list specifying a complement set.
       complementTextList :: Monad m => OrgParser m [Text]
       complementTextList :: OrgParser m [Text]
    complementTextList = OrgParser m [Text] -> OrgParser m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m [Text] -> OrgParser m [Text])
    -> OrgParser m [Text] -> OrgParser m [Text]
    forall a b. (a -> b) -> a -> b
    $
         String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string "(not "
           ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> OrgParser m [Text] -> OrgParser m [Text]
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m [Text]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    sepBy ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *). Monad m => OrgParser m Text
    elispText ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    spaces
           OrgParser m [Text]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m [Text]
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ')'

       elispText :: Monad m => OrgParser m Text
       elispText :: OrgParser m Text
    elispText = OrgParser m Text -> OrgParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Text -> OrgParser m Text)
    -> OrgParser m Text -> OrgParser m Text
    forall a b. (a -> b) -> a -> b
    $
         Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '"'
           ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m Text -> OrgParser m Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m Text
    forall s (m :: * -> *) t st a.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
    manyTillChar ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    alphaNum (Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '"')

    -- | Read but ignore the export setting.
    ignoredSetting :: Monad m => Text -> OrgParser m ()
    ignoredSetting :: Text -> OrgParser m ()
    ignoredSetting s :: Text
    s = OrgParser m () -> OrgParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (() ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> OrgParser m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Text -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Text -> ParsecT s u m Text
    textStr Text
    s OrgParser m ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m ()
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':' OrgParser m ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> OrgParser m ()
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    nonspaceChar)

    -- | Read any setting string, but ignore it and emit a warning.
    ignoreAndWarn :: PandocMonad m => OrgParser m ()
    ignoreAndWarn :: OrgParser m ()
    ignoreAndWarn = OrgParser m () -> OrgParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m () -> OrgParser m ())
    -> OrgParser m () -> OrgParser m ()
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    opt <- ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    nonspaceChar
      LogMessage -> OrgParser m ()
    forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
    report (Text -> LogMessage
    UnknownOrgExportOption Text
    opt)
      () -> OrgParser m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    -- | Read an elisp boolean.  Only NIL is treated as false, non-NIL values are
    -- interpreted as true.
    elispBoolean :: Monad m => OrgParser m Bool
    elispBoolean :: OrgParser m Bool
    elispBoolean = OrgParser m Bool -> OrgParser m Bool
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Bool -> OrgParser m Bool)
    -> OrgParser m Bool -> OrgParser m Bool
    forall a b. (a -> b) -> a -> b
    $ do
      String
    value <- ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    nonspaceChar
      Bool -> OrgParser m Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Bool -> OrgParser m Bool) -> Bool -> OrgParser m Bool
    forall a b. (a -> b) -> a -> b
    $ case (Char -> Char) -> String -> String
    forall a b. (a -> b) -> [a] -> [b]
    map Char -> Char
    toLower String
    value of
                 "nil" -> Bool
    False
                 "{}"  -> Bool
    False
                 "()"  -> Bool
    False
                 _     -> Bool
    True