    {-# LANGUAGE FlexibleInstances     #-}
    {-# LANGUAGE MultiParamTypeClasses #-}
    {-# LANGUAGE OverloadedStrings     #-}
    {- |
       Module      : Text.Pandoc.Readers.Org.ParserState
       Copyright   : Copyright (C) 2014-2024 Albert Krewinkel
       License     : GNU GPL, version 2 or above

       Maintainer  : Albert Krewinkel <albert+pandoc@tarleb.com>

    Define the Org-mode parser state.
    -}
    module Text.Pandoc.Readers.Org.ParserState
      ( OrgParserState (..)
      , defaultOrgParserState
      , OrgParserLocal (..)
      , OrgNoteRecord
      , Tag(..)
      , HasReaderOptions (..)
      , HasQuoteContext (..)
      , HasMacros (..)
      , TodoMarker (..)
      , TodoSequence
      , TodoState (..)
      , activeTodoMarkers
      , registerTodoSequence
      , MacroExpander
      , lookupMacro
      , registerMacro
      , F
      , askF
      , asksF
      , trimInlinesF
      , runF
      , returnF
      , ExportSettings (..)
      , ArchivedTreesOption (..)
      , TeXExport (..)
      , optionsToParserState
      ) where

    import Control.Monad.Reader (ReaderT, asks, local)

    import Data.Default (Default (..))
    import qualified Data.Map as M
    import qualified Data.Set as Set
    import Data.Text (Text)

    import Text.Pandoc.Builder (Blocks)
    import Text.Pandoc.Definition (Meta (..), nullMeta)
    import Text.Pandoc.Logging
    import Text.Pandoc.Options (ReaderOptions (..))
    import Text.Pandoc.Parsing (Future, HasIdentifierList (..),
                                HasIncludeFiles (..), HasLastStrPosition (..),
                                HasLogMessages (..), HasMacros (..),
                                HasQuoteContext (..), HasReaderOptions (..),
                                ParserContext (..), QuoteContext (..), SourcePos,
                                askF, asksF, returnF, runF, trimInlinesF)
    import Text.Pandoc.TeX (Macro)

    -- | This is used to delay evaluation until all relevant information has been
    -- parsed and made available in the parser state.
    type F = Future OrgParserState

    -- | An inline note / footnote containing the note key and its (inline) value.
    type OrgNoteRecord = (Text, F Blocks)
    -- | Table of footnotes
    type OrgNoteTable = [OrgNoteRecord]
    -- | Map of functions for link transformations.  The map key is refers to the
    -- link-type, the corresponding function transforms the given link string.
    type OrgLinkFormatters = M.Map Text (Text -> Text)
    -- | Macro expander function
    type MacroExpander = [Text] -> Text
    -- | Tag
    newtype Tag = Tag { Tag -> Text
    fromTag :: Text }
      deriving (Int -> Tag -> ShowS
    [Tag] -> ShowS
    Tag -> String
    (Int -> Tag -> ShowS)
    -> (Tag -> String) -> ([Tag] -> ShowS) -> Show Tag
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Tag -> ShowS
    showsPrec :: Int -> Tag -> ShowS
    $cshow :: Tag -> String
    show :: Tag -> String
    $cshowList :: [Tag] -> ShowS
    showList :: [Tag] -> ShowS
    Show, Tag -> Tag -> Bool
    (Tag -> Tag -> Bool) -> (Tag -> Tag -> Bool) -> Eq Tag
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Tag -> Tag -> Bool
    == :: Tag -> Tag -> Bool
    $c/= :: Tag -> Tag -> Bool
    /= :: Tag -> Tag -> Bool
    Eq, Eq Tag
    Eq Tag =>
    (Tag -> Tag -> Ordering)
    -> (Tag -> Tag -> Bool)
    -> (Tag -> Tag -> Bool)
    -> (Tag -> Tag -> Bool)
    -> (Tag -> Tag -> Bool)
    -> (Tag -> Tag -> Tag)
    -> (Tag -> Tag -> Tag)
    -> Ord Tag
    Tag -> Tag -> Bool
    Tag -> Tag -> Ordering
    Tag -> Tag -> Tag
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Tag -> Tag -> Ordering
    compare :: Tag -> Tag -> Ordering
    $c< :: Tag -> Tag -> Bool
    < :: Tag -> Tag -> Bool
    $c<= :: Tag -> Tag -> Bool
    <= :: Tag -> Tag -> Bool
    $c> :: Tag -> Tag -> Bool
    > :: Tag -> Tag -> Bool
    $c>= :: Tag -> Tag -> Bool
    >= :: Tag -> Tag -> Bool
    $cmax :: Tag -> Tag -> Tag
    max :: Tag -> Tag -> Tag
    $cmin :: Tag -> Tag -> Tag
    min :: Tag -> Tag -> Tag
    Ord)

    -- | The states in which a todo item can be
    data TodoState = Todo | Done
      deriving (TodoState -> TodoState -> Bool
    (TodoState -> TodoState -> Bool)
    -> (TodoState -> TodoState -> Bool) -> Eq TodoState
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TodoState -> TodoState -> Bool
    == :: TodoState -> TodoState -> Bool
    $c/= :: TodoState -> TodoState -> Bool
    /= :: TodoState -> TodoState -> Bool
    Eq, Eq TodoState
    Eq TodoState =>
    (TodoState -> TodoState -> Ordering)
    -> (TodoState -> TodoState -> Bool)
    -> (TodoState -> TodoState -> Bool)
    -> (TodoState -> TodoState -> Bool)
    -> (TodoState -> TodoState -> Bool)
    -> (TodoState -> TodoState -> TodoState)
    -> (TodoState -> TodoState -> TodoState)
    -> Ord TodoState
    TodoState -> TodoState -> Bool
    TodoState -> TodoState -> Ordering
    TodoState -> TodoState -> TodoState
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: TodoState -> TodoState -> Ordering
    compare :: TodoState -> TodoState -> Ordering
    $c< :: TodoState -> TodoState -> Bool
    < :: TodoState -> TodoState -> Bool
    $c<= :: TodoState -> TodoState -> Bool
    <= :: TodoState -> TodoState -> Bool
    $c> :: TodoState -> TodoState -> Bool
    > :: TodoState -> TodoState -> Bool
    $c>= :: TodoState -> TodoState -> Bool
    >= :: TodoState -> TodoState -> Bool
    $cmax :: TodoState -> TodoState -> TodoState
    max :: TodoState -> TodoState -> TodoState
    $cmin :: TodoState -> TodoState -> TodoState
    min :: TodoState -> TodoState -> TodoState
    Ord, Int -> TodoState -> ShowS
    [TodoState] -> ShowS
    TodoState -> String
    (Int -> TodoState -> ShowS)
    -> (TodoState -> String)
    -> ([TodoState] -> ShowS)
    -> Show TodoState
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> TodoState -> ShowS
    showsPrec :: Int -> TodoState -> ShowS
    $cshow :: TodoState -> String
    show :: TodoState -> String
    $cshowList :: [TodoState] -> ShowS
    showList :: [TodoState] -> ShowS
    Show)

    -- | A ToDo keyword like @TODO@ or @DONE@.
    data TodoMarker = TodoMarker
      { TodoMarker -> TodoState
    todoMarkerState :: TodoState
      , TodoMarker -> Text
    todoMarkerName  :: Text
      }
      deriving (Int -> TodoMarker -> ShowS
    [TodoMarker] -> ShowS
    TodoMarker -> String
    (Int -> TodoMarker -> ShowS)
    -> (TodoMarker -> String)
    -> ([TodoMarker] -> ShowS)
    -> Show TodoMarker
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> TodoMarker -> ShowS
    showsPrec :: Int -> TodoMarker -> ShowS
    $cshow :: TodoMarker -> String
    show :: TodoMarker -> String
    $cshowList :: [TodoMarker] -> ShowS
    showList :: [TodoMarker] -> ShowS
    Show, TodoMarker -> TodoMarker -> Bool
    (TodoMarker -> TodoMarker -> Bool)
    -> (TodoMarker -> TodoMarker -> Bool) -> Eq TodoMarker
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: TodoMarker -> TodoMarker -> Bool
    == :: TodoMarker -> TodoMarker -> Bool
    $c/= :: TodoMarker -> TodoMarker -> Bool
    /= :: TodoMarker -> TodoMarker -> Bool
    Eq)

    -- | Collection of todo markers in the order in which items should progress
    type TodoSequence = [TodoMarker]

    -- | Org-mode parser state
    data OrgParserState = OrgParserState
      { OrgParserState -> [Text]
    orgStateAnchorIds            :: [Text]
      , OrgParserState -> String
    orgStateEmphasisCharStack    :: [Char]
      , OrgParserState -> String
    orgStateEmphasisPreChars     :: [Char] -- ^ Chars allowed to occur before
                                               -- emphasis; spaces and newlines are
                                               -- always ok in addition to what is
                                               -- specified here.
      , OrgParserState -> String
    orgStateEmphasisPostChars    :: [Char] -- ^ Chars allowed at after emphasis
      , OrgParserState -> Maybe Int
    orgStateEmphasisNewlines     :: Maybe Int
      , OrgParserState -> Set Tag
    orgStateExcludeTags          :: Set.Set Tag
      , OrgParserState -> Bool
    orgStateExcludeTagsChanged   :: Bool
      , OrgParserState -> ExportSettings
    orgStateExportSettings       :: ExportSettings
      , OrgParserState -> Set Text
    orgStateIdentifiers          :: Set.Set Text
      , OrgParserState -> [Text]
    orgStateIncludeFiles         :: [Text]
      , OrgParserState -> Maybe SourcePos
    orgStateLastForbiddenCharPos :: Maybe SourcePos
      , OrgParserState -> Maybe SourcePos
    orgStateLastPreCharPos       :: Maybe SourcePos
      , OrgParserState -> Maybe SourcePos
    orgStateLastStrPos           :: Maybe SourcePos
      , OrgParserState -> OrgLinkFormatters
    orgStateLinkFormatters       :: OrgLinkFormatters
      , OrgParserState -> Map Text MacroExpander
    orgStateMacros               :: M.Map Text MacroExpander
      , OrgParserState -> Int
    orgStateMacroDepth           :: Int
      , OrgParserState -> F Meta
    orgStateMeta                 :: F Meta
      , OrgParserState -> OrgNoteTable
    orgStateNotes'               :: OrgNoteTable
      , OrgParserState -> ReaderOptions
    orgStateOptions              :: ReaderOptions
      , OrgParserState -> ParserContext
    orgStateParserContext        :: ParserContext
      , OrgParserState -> Set Tag
    orgStateSelectTags           :: Set.Set Tag
      , OrgParserState -> Bool
    orgStateSelectTagsChanged    :: Bool
      , OrgParserState -> [[TodoMarker]]
    orgStateTodoSequences        :: [TodoSequence]
      , OrgParserState -> Bool
    orgStateTrimLeadBlkIndent    :: Bool
      , OrgParserState -> [LogMessage]
    orgLogMessages               :: [LogMessage]
      , OrgParserState -> Map Text Macro
    orgMacros                    :: M.Map Text Macro
      }

    newtype OrgParserLocal = OrgParserLocal
      { OrgParserLocal -> QuoteContext
    orgLocalQuoteContext :: QuoteContext
      }

    instance Default OrgParserLocal where
      def :: OrgParserLocal
    def = QuoteContext -> OrgParserLocal
    OrgParserLocal QuoteContext
    NoQuote

    instance HasReaderOptions OrgParserState where
      extractReaderOptions :: OrgParserState -> ReaderOptions
    extractReaderOptions = OrgParserState -> ReaderOptions
    orgStateOptions

    instance HasLastStrPosition OrgParserState where
      getLastStrPos :: OrgParserState -> Maybe SourcePos
    getLastStrPos = OrgParserState -> Maybe SourcePos
    orgStateLastStrPos
      setLastStrPos :: Maybe SourcePos -> OrgParserState -> OrgParserState
    setLastStrPos Maybe SourcePos
    pos OrgParserState
    st = OrgParserState
    st{ orgStateLastStrPos = pos }

    instance Monad m => HasQuoteContext st (ReaderT OrgParserLocal m) where
      getQuoteContext :: forall s t.
    Stream s (ReaderT OrgParserLocal m) t =>
    ParsecT s st (ReaderT OrgParserLocal m) QuoteContext
    getQuoteContext = (OrgParserLocal -> QuoteContext)
    -> ParsecT s st (ReaderT OrgParserLocal m) QuoteContext
    forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
    asks OrgParserLocal -> QuoteContext
    orgLocalQuoteContext
      withQuoteContext :: forall s a.
    QuoteContext
    -> ParsecT s st (ReaderT OrgParserLocal m) a
    -> ParsecT s st (ReaderT OrgParserLocal m) a
    withQuoteContext QuoteContext
    q = (OrgParserLocal -> OrgParserLocal)
    -> ParsecT s st (ReaderT OrgParserLocal m) a
    -> ParsecT s st (ReaderT OrgParserLocal m) a
    forall a.
    (OrgParserLocal -> OrgParserLocal)
    -> ParsecT s st (ReaderT OrgParserLocal m) a
    -> ParsecT s st (ReaderT OrgParserLocal m) a
    forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
    local (\OrgParserLocal
    s -> OrgParserLocal
    s{orgLocalQuoteContext = q})

    instance HasIdentifierList OrgParserState where
      extractIdentifierList :: OrgParserState -> Set Text
    extractIdentifierList = OrgParserState -> Set Text
    orgStateIdentifiers
      updateIdentifierList :: (Set Text -> Set Text) -> OrgParserState -> OrgParserState
    updateIdentifierList Set Text -> Set Text
    f OrgParserState
    s = OrgParserState
    s{ orgStateIdentifiers = f (orgStateIdentifiers s) }

    instance HasLogMessages OrgParserState where
      addLogMessage :: LogMessage -> OrgParserState -> OrgParserState
    addLogMessage LogMessage
    msg OrgParserState
    st = OrgParserState
    st{ orgLogMessages = msg : orgLogMessages st }
      getLogMessages :: OrgParserState -> [LogMessage]
    getLogMessages OrgParserState
    st = [LogMessage] -> [LogMessage]
    forall a. [a] -> [a]
    reverse ([LogMessage] -> [LogMessage]) -> [LogMessage] -> [LogMessage]
    forall a b. (a -> b) -> a -> b
    $ OrgParserState -> [LogMessage]
    orgLogMessages OrgParserState
    st

    instance HasMacros OrgParserState where
      extractMacros :: OrgParserState -> Map Text Macro
    extractMacros OrgParserState
    st = OrgParserState -> Map Text Macro
    orgMacros OrgParserState
    st
      updateMacros :: (Map Text Macro -> Map Text Macro)
    -> OrgParserState -> OrgParserState
    updateMacros Map Text Macro -> Map Text Macro
    f OrgParserState
    st = OrgParserState
    st{ orgMacros = f (orgMacros st) }

    instance HasIncludeFiles OrgParserState where
      getIncludeFiles :: OrgParserState -> [Text]
    getIncludeFiles = OrgParserState -> [Text]
    orgStateIncludeFiles
      addIncludeFile :: Text -> OrgParserState -> OrgParserState
    addIncludeFile Text
    f OrgParserState
    st = OrgParserState
    st { orgStateIncludeFiles = f : orgStateIncludeFiles st }
      dropLatestIncludeFile :: OrgParserState -> OrgParserState
    dropLatestIncludeFile OrgParserState
    st =
        OrgParserState
    st { orgStateIncludeFiles = drop 1 $ orgStateIncludeFiles st }

    instance Default OrgParserState where
      def :: OrgParserState
    def = OrgParserState
    defaultOrgParserState

    defaultOrgParserState :: OrgParserState
    defaultOrgParserState :: OrgParserState
    defaultOrgParserState = OrgParserState
      { orgStateAnchorIds :: [Text]
    orgStateAnchorIds = []
      , orgStateEmphasisPreChars :: String
    orgStateEmphasisPreChars = String
    "-\t ('\"{\x200B"
      , orgStateEmphasisPostChars :: String
    orgStateEmphasisPostChars  = String
    "-\t\n .,:!?;'\")}[\x200B"
      , orgStateEmphasisCharStack :: String
    orgStateEmphasisCharStack = []
      , orgStateEmphasisNewlines :: Maybe Int
    orgStateEmphasisNewlines = Maybe Int
    forall a. Maybe a
    Nothing
      , orgStateExportSettings :: ExportSettings
    orgStateExportSettings = ExportSettings
    forall a. Default a => a
    def
      , orgStateExcludeTags :: Set Tag
    orgStateExcludeTags = Tag -> Set Tag
    forall a. a -> Set a
    Set.singleton (Tag -> Set Tag) -> Tag -> Set Tag
    forall a b. (a -> b) -> a -> b
    $ Text -> Tag
    Tag Text
    "noexport"
      , orgStateExcludeTagsChanged :: Bool
    orgStateExcludeTagsChanged = Bool
    False
      , orgStateIdentifiers :: Set Text
    orgStateIdentifiers = Set Text
    forall a. Set a
    Set.empty
      , orgStateIncludeFiles :: [Text]
    orgStateIncludeFiles = []
      , orgStateLastForbiddenCharPos :: Maybe SourcePos
    orgStateLastForbiddenCharPos = Maybe SourcePos
    forall a. Maybe a
    Nothing
      , orgStateLastPreCharPos :: Maybe SourcePos
    orgStateLastPreCharPos = Maybe SourcePos
    forall a. Maybe a
    Nothing
      , orgStateLastStrPos :: Maybe SourcePos
    orgStateLastStrPos = Maybe SourcePos
    forall a. Maybe a
    Nothing
      , orgStateLinkFormatters :: OrgLinkFormatters
    orgStateLinkFormatters = OrgLinkFormatters
    forall k a. Map k a
    M.empty
      , orgStateMacros :: Map Text MacroExpander
    orgStateMacros = Map Text MacroExpander
    forall k a. Map k a
    M.empty
      , orgStateMacroDepth :: Int
    orgStateMacroDepth = Int
    0
      , orgStateMeta :: F Meta
    orgStateMeta = Meta -> F Meta
    forall a. a -> Future OrgParserState a
    forall (m :: * -> *) a. Monad m => a -> m a
    return Meta
    nullMeta
      , orgStateNotes' :: OrgNoteTable
    orgStateNotes' = []
      , orgStateOptions :: ReaderOptions
    orgStateOptions = ReaderOptions
    forall a. Default a => a
    def
      , orgStateParserContext :: ParserContext
    orgStateParserContext = ParserContext
    NullState
      , orgStateSelectTags :: Set Tag
    orgStateSelectTags = Tag -> Set Tag
    forall a. a -> Set a
    Set.singleton (Tag -> Set Tag) -> Tag -> Set Tag
    forall a b. (a -> b) -> a -> b
    $ Text -> Tag
    Tag Text
    "export"
      , orgStateSelectTagsChanged :: Bool
    orgStateSelectTagsChanged = Bool
    False
      , orgStateTrimLeadBlkIndent :: Bool
    orgStateTrimLeadBlkIndent = Bool
    True
      , orgStateTodoSequences :: [[TodoMarker]]
    orgStateTodoSequences = []
      , orgLogMessages :: [LogMessage]
    orgLogMessages = []
      , orgMacros :: Map Text Macro
    orgMacros = Map Text Macro
    forall k a. Map k a
    M.empty
      }

    optionsToParserState :: ReaderOptions -> OrgParserState
    optionsToParserState :: ReaderOptions -> OrgParserState
    optionsToParserState ReaderOptions
    opts =
      OrgParserState
    forall a. Default a => a
    def { orgStateOptions = opts }

    registerTodoSequence :: TodoSequence -> OrgParserState -> OrgParserState
    registerTodoSequence :: [TodoMarker] -> OrgParserState -> OrgParserState
    registerTodoSequence [TodoMarker]
    todoSeq OrgParserState
    st =
      let curSeqs :: [[TodoMarker]]
    curSeqs = OrgParserState -> [[TodoMarker]]
    orgStateTodoSequences OrgParserState
    st
      in OrgParserState
    st{ orgStateTodoSequences = todoSeq : curSeqs }

    -- | Get the current todo/done sequences. If no custom todo sequences have been
    -- defined, return a list containing just the default todo/done sequence.
    activeTodoSequences :: OrgParserState -> [TodoSequence]
    activeTodoSequences :: OrgParserState -> [[TodoMarker]]
    activeTodoSequences OrgParserState
    st =
      let curSeqs :: [[TodoMarker]]
    curSeqs = OrgParserState -> [[TodoMarker]]
    orgStateTodoSequences OrgParserState
    st
      in if [[TodoMarker]] -> Bool
    forall a. [a] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [[TodoMarker]]
    curSeqs
         then [[ TodoState -> Text -> TodoMarker
    TodoMarker TodoState
    Todo Text
    "TODO" , TodoState -> Text -> TodoMarker
    TodoMarker TodoState
    Done Text
    "DONE" ]]
         else [[TodoMarker]]
    curSeqs

    activeTodoMarkers :: OrgParserState -> TodoSequence
    activeTodoMarkers :: OrgParserState -> [TodoMarker]
    activeTodoMarkers = [[TodoMarker]] -> [TodoMarker]
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat ([[TodoMarker]] -> [TodoMarker])
    -> (OrgParserState -> [[TodoMarker]])
    -> OrgParserState
    -> [TodoMarker]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OrgParserState -> [[TodoMarker]]
    activeTodoSequences

    lookupMacro :: Text -> OrgParserState -> Maybe MacroExpander
    lookupMacro :: Text -> OrgParserState -> Maybe MacroExpander
    lookupMacro Text
    macroName = Text -> Map Text MacroExpander -> Maybe MacroExpander
    forall k a. Ord k => k -> Map k a -> Maybe a
    M.lookup Text
    macroName (Map Text MacroExpander -> Maybe MacroExpander)
    -> (OrgParserState -> Map Text MacroExpander)
    -> OrgParserState
    -> Maybe MacroExpander
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OrgParserState -> Map Text MacroExpander
    orgStateMacros

    registerMacro :: (Text, MacroExpander) -> OrgParserState -> OrgParserState
    registerMacro :: (Text, MacroExpander) -> OrgParserState -> OrgParserState
    registerMacro (Text
    name, MacroExpander
    expander) OrgParserState
    st =
      let curMacros :: Map Text MacroExpander
    curMacros = OrgParserState -> Map Text MacroExpander
    orgStateMacros OrgParserState
    st
      in OrgParserState
    st{ orgStateMacros = M.insert name expander curMacros }

    --
    -- Export Settings
    --

    -- | Options for the way archived trees are handled.
    data ArchivedTreesOption =
        ArchivedTreesExport       -- ^ Export the complete tree
      | ArchivedTreesNoExport     -- ^ Exclude archived trees from exporting
      | ArchivedTreesHeadlineOnly -- ^ Export only the headline, discard the contents

    -- | Options for the handling of LaTeX environments and fragments.
    -- Represents allowed values of Emacs variable @org-export-with-latex@.
    data TeXExport
      = TeXExport                 -- ^ Include raw TeX in the output
      | TeXIgnore                 -- ^ Ignore raw TeX
      | TeXVerbatim               -- ^ Keep everything in verbatim

    -- | Export settings <http://orgmode.org/manual/Export-settings.html>
    -- These settings can be changed via OPTIONS statements.
    data ExportSettings = ExportSettings
      { ExportSettings -> ArchivedTreesOption
    exportArchivedTrees    :: ArchivedTreesOption -- ^ How to treat archived trees
      , ExportSettings -> Either [Text] [Text]
    exportDrawers          :: Either [Text] [Text]
      -- ^ Specify drawer names which should be exported.  @Left@ names are
      -- explicitly excluded from the resulting output while @Right@ means that
      -- only the listed drawer names should be included.
      , ExportSettings -> Bool
    exportEmphasizedText   :: Bool -- ^ Parse emphasized text
      , ExportSettings -> Int
    exportHeadlineLevels   :: Int
      -- ^ Maximum depth of headlines, deeper headlines are convert to list
      , ExportSettings -> Bool
    exportPreserveBreaks   :: Bool -- ^ Whether to preserve linebreaks
      , ExportSettings -> Bool
    exportSmartQuotes      :: Bool -- ^ Parse quotes smartly
      , ExportSettings -> Bool
    exportSpecialStrings   :: Bool -- ^ Parse ellipses and dashes smartly
      , ExportSettings -> Bool
    exportSubSuperscripts  :: Bool -- ^ TeX-like syntax for sub- and superscripts
      , ExportSettings -> Bool
    exportWithAuthor       :: Bool -- ^ Include author in final meta-data
      , ExportSettings -> Bool
    exportWithCreator      :: Bool -- ^ Include creator in final meta-data
      , ExportSettings -> Bool
    exportWithEmail        :: Bool -- ^ Include email in final meta-data
      , ExportSettings -> Bool
    exportWithEntities     :: Bool -- ^ Include MathML-like entities
      , ExportSettings -> Bool
    exportWithFootnotes    :: Bool -- ^ Include footnotes
      , ExportSettings -> TeXExport
    exportWithLatex        :: TeXExport -- ^ Handling of raw TeX commands
      , ExportSettings -> Bool
    exportWithPlanning     :: Bool -- ^ Keep planning info after headlines
      , ExportSettings -> Bool
    exportWithTags         :: Bool -- ^ Keep tags as part of headlines
      , ExportSettings -> Bool
    exportWithTables       :: Bool -- ^ Include tables
      , ExportSettings -> Bool
    exportWithTodoKeywords :: Bool -- ^ Keep TODO keywords in headers
      }

    instance Default ExportSettings where
      def :: ExportSettings
    def = ExportSettings
    defaultExportSettings

    defaultExportSettings :: ExportSettings
    defaultExportSettings :: ExportSettings
    defaultExportSettings = ExportSettings
      { exportArchivedTrees :: ArchivedTreesOption
    exportArchivedTrees = ArchivedTreesOption
    ArchivedTreesHeadlineOnly
      , exportDrawers :: Either [Text] [Text]
    exportDrawers = [Text] -> Either [Text] [Text]
    forall a b. a -> Either a b
    Left [Text
    "LOGBOOK"]
      , exportEmphasizedText :: Bool
    exportEmphasizedText = Bool
    True
      , exportHeadlineLevels :: Int
    exportHeadlineLevels = Int
    3
      , exportPreserveBreaks :: Bool
    exportPreserveBreaks = Bool
    False
      , exportSmartQuotes :: Bool
    exportSmartQuotes = Bool
    False
      , exportSpecialStrings :: Bool
    exportSpecialStrings = Bool
    True
      , exportSubSuperscripts :: Bool
    exportSubSuperscripts = Bool
    True
      , exportWithAuthor :: Bool
    exportWithAuthor = Bool
    True
      , exportWithCreator :: Bool
    exportWithCreator = Bool
    True
      , exportWithEmail :: Bool
    exportWithEmail = Bool
    True
      , exportWithEntities :: Bool
    exportWithEntities = Bool
    True
      , exportWithFootnotes :: Bool
    exportWithFootnotes = Bool
    True
      , exportWithLatex :: TeXExport
    exportWithLatex = TeXExport
    TeXExport
      , exportWithPlanning :: Bool
    exportWithPlanning = Bool
    False
      , exportWithTags :: Bool
    exportWithTags = Bool
    True
      , exportWithTables :: Bool
    exportWithTables = Bool
    True
      , exportWithTodoKeywords :: Bool
    exportWithTodoKeywords = Bool
    True
      }