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

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

    Parsers for Org-mode inline elements.
    -}
    module Text.Pandoc.Readers.Org.Inlines
      ( inline
      , inlines
      , addToNotesTable
      , linkTarget
      ) where

    import Text.Pandoc.Readers.Org.BlockStarts (endOfBlock, noteMarker)
    import Text.Pandoc.Readers.Org.ParserState
    import Text.Pandoc.Readers.Org.Parsing
    import Text.Pandoc.Readers.Org.Shared (cleanLinkText, isImageFilename,
                                           originalLang, translateLang, exportsCode)

    import Text.Pandoc.Builder (Inlines)
    import qualified Text.Pandoc.Builder as B
    import Text.Pandoc.Class.PandocMonad (PandocMonad)
    import Text.Pandoc.Definition
    import Text.Pandoc.Options
    import Text.Pandoc.Readers.LaTeX (inlineCommand, rawLaTeXInline)
    import Text.Pandoc.Shared (underlineSpan)
    import Text.TeXMath (DisplayType (..), readTeX, writePandoc)
    import qualified Text.TeXMath.Readers.MathML.EntityMap as MathMLEntityMap

    import Control.Monad (guard, mplus, mzero, unless, void, when)
    import Control.Monad.Trans (lift)
    import Data.Char (isAlphaNum, isSpace)
    import Data.List (intersperse)
    import qualified Data.Map as M
    import Data.Text (Text)
    import qualified Data.Text as T

    --
    -- Functions acting on the parser state
    --
    recordAnchorId :: PandocMonad m => Text -> OrgParser m ()
    recordAnchorId :: Text -> OrgParser m ()
    recordAnchorId i :: Text
    i = (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
    $ \s :: OrgParserState
    s ->
      OrgParserState
    s{ orgStateAnchorIds :: [Text]
    orgStateAnchorIds = Text
    i Text -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    : OrgParserState -> [Text]
    orgStateAnchorIds OrgParserState
    s }

    pushToInlineCharStack :: PandocMonad m => Char -> OrgParser m ()
    pushToInlineCharStack :: Char -> OrgParser m ()
    pushToInlineCharStack c :: Char
    c = (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
    $ \s :: OrgParserState
    s ->
      OrgParserState
    s{ orgStateEmphasisCharStack :: [Char]
    orgStateEmphasisCharStack = Char
    cChar -> [Char] -> [Char]
    forall a. a -> [a] -> [a]
    :OrgParserState -> [Char]
    orgStateEmphasisCharStack OrgParserState
    s }

    popInlineCharStack :: PandocMonad m => OrgParser m ()
    popInlineCharStack :: OrgParser m ()
    popInlineCharStack = (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
    $ \s :: OrgParserState
    s ->
      OrgParserState
    s{ orgStateEmphasisCharStack :: [Char]
    orgStateEmphasisCharStack = Int -> [Char] -> [Char]
    forall a. Int -> [a] -> [a]
    drop 1 ([Char] -> [Char])
    -> (OrgParserState -> [Char]) -> OrgParserState -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OrgParserState -> [Char]
    orgStateEmphasisCharStack (OrgParserState -> [Char]) -> OrgParserState -> [Char]
    forall a b. (a -> b) -> a -> b
    $ OrgParserState
    s }

    surroundingEmphasisChar :: PandocMonad m => OrgParser m [Char]
    surroundingEmphasisChar :: OrgParser m [Char]
    surroundingEmphasisChar =
      Int -> [Char] -> [Char]
    forall a. Int -> [a] -> [a]
    take 1 ([Char] -> [Char])
    -> (OrgParserState -> [Char]) -> OrgParserState -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> [Char] -> [Char]
    forall a. Int -> [a] -> [a]
    drop 1 ([Char] -> [Char])
    -> (OrgParserState -> [Char]) -> OrgParserState -> [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OrgParserState -> [Char]
    orgStateEmphasisCharStack (OrgParserState -> [Char])
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    -> OrgParser m [Char]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState

    startEmphasisNewlinesCounting :: PandocMonad m => Int -> OrgParser m ()
    startEmphasisNewlinesCounting :: Int -> OrgParser m ()
    startEmphasisNewlinesCounting maxNewlines :: Int
    maxNewlines = (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
    $ \s :: OrgParserState
    s ->
      OrgParserState
    s{ orgStateEmphasisNewlines :: Maybe Int
    orgStateEmphasisNewlines = Int -> Maybe Int
    forall a. a -> Maybe a
    Just Int
    maxNewlines }

    decEmphasisNewlinesCount :: PandocMonad m => OrgParser m ()
    decEmphasisNewlinesCount :: OrgParser m ()
    decEmphasisNewlinesCount = (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
    $ \s :: OrgParserState
    s ->
      OrgParserState
    s{ orgStateEmphasisNewlines :: Maybe Int
    orgStateEmphasisNewlines = (\n :: Int
    n -> Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - 1) (Int -> Int) -> Maybe Int -> Maybe Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> OrgParserState -> Maybe Int
    orgStateEmphasisNewlines OrgParserState
    s }

    newlinesCountWithinLimits :: PandocMonad m => OrgParser m Bool
    newlinesCountWithinLimits :: OrgParser m Bool
    newlinesCountWithinLimits = do
      OrgParserState
    st <- ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      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
    $ ((Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < 0) (Int -> Bool) -> Maybe Int -> Maybe Bool
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> OrgParserState -> Maybe Int
    orgStateEmphasisNewlines OrgParserState
    st) Maybe Bool -> Maybe Bool -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Bool -> Maybe Bool
    forall a. a -> Maybe a
    Just Bool
    True

    resetEmphasisNewlines :: PandocMonad m => OrgParser m ()
    resetEmphasisNewlines :: OrgParser m ()
    resetEmphasisNewlines = (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
    $ \s :: OrgParserState
    s ->
      OrgParserState
    s{ orgStateEmphasisNewlines :: Maybe Int
    orgStateEmphasisNewlines = Maybe Int
    forall a. Maybe a
    Nothing }

    addToNotesTable :: PandocMonad m => OrgNoteRecord -> OrgParser m ()
    addToNotesTable :: OrgNoteRecord -> OrgParser m ()
    addToNotesTable note :: OrgNoteRecord
    note = do
      OrgNoteTable
    oldnotes <- OrgParserState -> OrgNoteTable
    orgStateNotes' (OrgParserState -> OrgNoteTable)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) OrgNoteTable
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      (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
    $ \s :: OrgParserState
    s -> OrgParserState
    s{ orgStateNotes' :: OrgNoteTable
    orgStateNotes' = OrgNoteRecord
    noteOrgNoteRecord -> OrgNoteTable -> OrgNoteTable
    forall a. a -> [a] -> [a]
    :OrgNoteTable
    oldnotes }

    -- | Parse a single Org-mode inline element
    inline :: PandocMonad m => OrgParser m (F Inlines)
    inline :: OrgParser m (F Inlines)
    inline =
      [OrgParser m (F Inlines)] -> OrgParser m (F Inlines)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice [ OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    whitespace
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    linebreak
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    cite
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    footnote
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    linkOrImage
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    anchor
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inlineCodeBlock
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    str
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    endline
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    emphasizedText
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    code
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    math
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    displayMath
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    verbatim
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    subscript
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    superscript
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inlineLaTeX
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    exportSnippet
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    macro
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    smart
             , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    symbol
             ] OrgParser m (F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* (Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (m :: * -> *). PandocMonad m => OrgParser m Bool
    newlinesCountWithinLimits)
      OrgParser m (F Inlines) -> [Char] -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> "inline"

    -- | Read the rest of the input as inlines.
    inlines :: PandocMonad m => OrgParser m (F Inlines)
    inlines :: OrgParser m (F Inlines)
    inlines = F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> F Inlines)
    -> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> OrgParser m (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inline

    -- treat these as potentially non-text when parsing inline:
    specialChars :: [Char]
    specialChars :: [Char]
    specialChars = "\"$'()*+-,./:;<=>@[\\]^_{|}~"

    whitespace :: PandocMonad m => OrgParser m (F Inlines)
    whitespace :: OrgParser m (F Inlines)
    whitespace = Inlines -> F Inlines
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Inlines
    B.space F Inlines
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    skipMany1 ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    spaceChar
                              OrgParser m (F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    updateLastPreCharPos
                              OrgParser m (F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    updateLastForbiddenCharPos
                 OrgParser m (F Inlines) -> [Char] -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> "whitespace"

    linebreak :: PandocMonad m => OrgParser m (F Inlines)
    linebreak :: OrgParser m (F Inlines)
    linebreak = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Inlines -> F Inlines
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure Inlines
    B.linebreak F Inlines
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor 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]
    string "\\\\" OrgParser m (F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces OrgParser m (F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall (m :: * -> *). Monad m => OrgParser m Char
    newline

    str :: PandocMonad m => OrgParser m (F Inlines)
    str :: OrgParser m (F Inlines)
    str = Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines) -> (Text -> Inlines) -> Text -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Inlines
    B.str (Text -> F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT 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 ([Char]
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf ([Char]
     -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char)
    -> [Char]
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall a b. (a -> b) -> a -> b
    $ [Char]
    specialChars [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ "\n\r ")
          OrgParser m (F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasLastStrPosition st) =>
    ParserT s st m ()
    updateLastStrPos

    -- | An endline character that can be treated as a space, not a structural
    -- break.  This should reflect the values of the Emacs variable
    -- @org-element-pagaraph-separate@.
    endline :: PandocMonad m => OrgParser m (F Inlines)
    endline :: OrgParser m (F Inlines)
    endline = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      OrgParser m Char
    forall (m :: * -> *). Monad m => OrgParser m Char
    newline
      ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    endOfBlock
      ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). PandocMonad m => OrgParser m ()
    decEmphasisNewlinesCount
      Bool -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (m :: * -> *). PandocMonad m => OrgParser m Bool
    newlinesCountWithinLimits
      ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    updateLastPreCharPos
      Bool
    useHardBreaks <- ExportSettings -> Bool
    exportPreserveBreaks (ExportSettings -> Bool)
    -> (OrgParserState -> ExportSettings) -> OrgParserState -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OrgParserState -> ExportSettings
    orgStateExportSettings (OrgParserState -> Bool)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a s. Monad m => a -> m (Future s a)
    returnF (if Bool
    useHardBreaks then Inlines
    B.linebreak else Inlines
    B.softbreak)

    --
    -- Citations
    --

    -- The state of citations is a bit confusing due to the lack of an official
    -- syntax and multiple syntaxes coexisting.  The pandocOrgCite syntax was the
    -- first to be implemented here and is almost identical to Markdown's citation
    -- syntax.  The org-ref package is in wide use to handle citations, but the
    -- syntax is a bit limiting and not quite as simple to write.  The
    -- semi-official Org-mode citation syntax is based on John MacFarlane's Pandoc
    -- sytax and Org-oriented enhancements contributed by Richard Lawrence and
    -- others.  It's dubbed Berkeley syntax due the place of activity of its main
    -- contributors.  All this should be consolidated once an official Org-mode
    -- citation syntax has emerged.

    cite :: PandocMonad m => OrgParser m (F Inlines)
    cite :: OrgParser m (F Inlines)
    cite = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    berkeleyCite OrgParser m (F Inlines)
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> do
      Extension
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_citations
      (cs :: F [Citation]
    cs, raw :: Text
    raw) <- ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) (F [Citation])
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F [Citation], Text)
    forall (m :: * -> *) st a.
    Monad m =>
    ParsecT Text st m a -> ParsecT Text st m (a, Text)
    withRaw (ParsecT
       Text OrgParserState (ReaderT OrgParserLocal m) (F [Citation])
     -> ParsecT
          Text
          OrgParserState
          (ReaderT OrgParserLocal m)
          (F [Citation], Text))
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F [Citation])
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F [Citation], Text)
    forall a b. (a -> b) -> a -> b
    $ [ParsecT
       Text OrgParserState (ReaderT OrgParserLocal m) (F [Citation])]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F [Citation])
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice
                   [ ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) (F [Citation])
    forall (m :: * -> *). PandocMonad m => OrgParser m (F [Citation])
    pandocOrgCite
                   , ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) (F [Citation])
    forall (m :: * -> *). PandocMonad m => OrgParser m (F [Citation])
    orgRefCite
                   , ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) (F [Citation])
    forall (m :: * -> *). PandocMonad m => OrgParser m (F [Citation])
    berkeleyTextualCite
                   ]
      F Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> OrgParser m (F Inlines))
    -> F Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ ([Citation] -> Inlines -> Inlines)
    -> Inlines -> [Citation] -> Inlines
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip [Citation] -> Inlines -> Inlines
    B.cite (Text -> Inlines
    B.text Text
    raw) ([Citation] -> Inlines) -> F [Citation] -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F [Citation]
    cs

    -- | A citation in Pandoc Org-mode style (@[prefix \@citekey suffix]@).
    pandocOrgCite :: PandocMonad m => OrgParser m (F [Citation])
    pandocOrgCite :: OrgParser m (F [Citation])
    pandocOrgCite = OrgParser m (F [Citation]) -> OrgParser m (F [Citation])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F [Citation]) -> OrgParser m (F [Citation]))
    -> OrgParser m (F [Citation]) -> OrgParser m (F [Citation])
    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
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m (F [Citation]) -> OrgParser m (F [Citation])
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> OrgParser m (F [Citation])
    forall (m :: * -> *). PandocMonad m => OrgParser m (F [Citation])
    citeList OrgParser m (F [Citation])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m (F [Citation])
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces OrgParser m (F [Citation])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m (F [Citation])
    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 ']'

    orgRefCite :: PandocMonad m => OrgParser m (F [Citation])
    orgRefCite :: OrgParser m (F [Citation])
    orgRefCite = OrgParser m (F [Citation]) -> OrgParser m (F [Citation])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F [Citation]) -> OrgParser m (F [Citation]))
    -> OrgParser m (F [Citation]) -> OrgParser m (F [Citation])
    forall a b. (a -> b) -> a -> b
    $ [OrgParser m (F [Citation])] -> OrgParser m (F [Citation])
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice
      [ OrgParser m (F [Citation])
    forall (m :: * -> *). PandocMonad m => OrgParser m (F [Citation])
    normalOrgRefCite
      , (Citation -> [Citation])
    -> Future OrgParserState Citation -> F [Citation]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (Citation -> [Citation] -> [Citation]
    forall a. a -> [a] -> [a]
    :[]) (Future OrgParserState Citation -> F [Citation])
    -> ParsecT
         Text
         OrgParserState
         (ReaderT OrgParserLocal m)
         (Future OrgParserState Citation)
    -> OrgParser m (F [Citation])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT
      Text
      OrgParserState
      (ReaderT OrgParserLocal m)
      (Future OrgParserState Citation)
    forall (m :: * -> *).
    PandocMonad m =>
    OrgParser m (Future OrgParserState Citation)
    linkLikeOrgRefCite
      ]

    normalOrgRefCite :: PandocMonad m => OrgParser m (F [Citation])
    normalOrgRefCite :: OrgParser m (F [Citation])
    normalOrgRefCite = OrgParser m (F [Citation]) -> OrgParser m (F [Citation])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F [Citation]) -> OrgParser m (F [Citation]))
    -> OrgParser m (F [Citation]) -> OrgParser m (F [Citation])
    forall a b. (a -> b) -> a -> b
    $ do
      CitationMode
    mode <- OrgParser m CitationMode
    forall (m :: * -> *). PandocMonad m => OrgParser m CitationMode
    orgRefCiteMode
      Future OrgParserState Citation
    firstCitation <- CitationMode -> OrgParser m (Future OrgParserState Citation)
    forall (m :: * -> *).
    PandocMonad m =>
    CitationMode -> OrgParser m (Future OrgParserState Citation)
    orgRefCiteList CitationMode
    mode
      [Future OrgParserState Citation]
    moreCitations <- OrgParser m (Future OrgParserState Citation)
    -> ParsecT
         Text
         OrgParserState
         (ReaderT OrgParserLocal m)
         [Future OrgParserState Citation]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (OrgParser m (Future OrgParserState Citation)
    -> OrgParser m (Future OrgParserState Citation)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (Future OrgParserState Citation)
     -> OrgParser m (Future OrgParserState Citation))
    -> OrgParser m (Future OrgParserState Citation)
    -> OrgParser m (Future OrgParserState Citation)
    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 (Future OrgParserState Citation)
    -> OrgParser m (Future OrgParserState Citation)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> CitationMode -> OrgParser m (Future OrgParserState Citation)
    forall (m :: * -> *).
    PandocMonad m =>
    CitationMode -> OrgParser m (Future OrgParserState Citation)
    orgRefCiteList CitationMode
    mode)
      F [Citation] -> OrgParser m (F [Citation])
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F [Citation] -> OrgParser m (F [Citation]))
    -> ([Future OrgParserState Citation] -> F [Citation])
    -> [Future OrgParserState Citation]
    -> OrgParser m (F [Citation])
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Future OrgParserState Citation] -> F [Citation]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence ([Future OrgParserState Citation] -> OrgParser m (F [Citation]))
    -> [Future OrgParserState Citation] -> OrgParser m (F [Citation])
    forall a b. (a -> b) -> a -> b
    $ Future OrgParserState Citation
    firstCitation Future OrgParserState Citation
    -> [Future OrgParserState Citation]
    -> [Future OrgParserState Citation]
    forall a. a -> [a] -> [a]
    : [Future OrgParserState Citation]
    moreCitations
     where
      -- | A list of org-ref style citation keys, parsed as citation of the given
      -- citation mode.
      orgRefCiteList :: PandocMonad m => CitationMode -> OrgParser m (F Citation)
      orgRefCiteList :: CitationMode -> OrgParser m (Future OrgParserState Citation)
    orgRefCiteList citeMode :: CitationMode
    citeMode = OrgParser m (Future OrgParserState Citation)
    -> OrgParser m (Future OrgParserState Citation)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (Future OrgParserState Citation)
     -> OrgParser m (Future OrgParserState Citation))
    -> OrgParser m (Future OrgParserState Citation)
    -> OrgParser m (Future OrgParserState Citation)
    forall a b. (a -> b) -> a -> b
    $ do
        Text
    key <- OrgParser m Text
    forall (m :: * -> *). PandocMonad m => OrgParser m Text
    orgRefCiteKey
        Citation -> OrgParser m (Future OrgParserState Citation)
    forall (m :: * -> *) a s. Monad m => a -> m (Future s a)
    returnF Citation :: Text
    -> [Inline] -> [Inline] -> CitationMode -> Int -> Int -> Citation
    Citation
         { citationId :: Text
    citationId      = Text
    key
         , citationPrefix :: [Inline]
    citationPrefix  = [Inline]
    forall a. Monoid a => a
    mempty
         , citationSuffix :: [Inline]
    citationSuffix  = [Inline]
    forall a. Monoid a => a
    mempty
         , citationMode :: CitationMode
    citationMode    = CitationMode
    citeMode
         , citationNoteNum :: Int
    citationNoteNum = 0
         , citationHash :: Int
    citationHash    = 0
         }

    -- | Read an Berkeley-style Org-mode citation.  Berkeley citation style was
    -- develop and adjusted to Org-mode style by John MacFarlane and Richard
    -- Lawrence, respectively, both philosophers at UC Berkeley.
    berkeleyCite :: PandocMonad m => OrgParser m (F Inlines)
    berkeleyCite :: OrgParser m (F Inlines)
    berkeleyCite = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      F BerkeleyCitationList
    bcl <- OrgParser m (F BerkeleyCitationList)
    forall (m :: * -> *).
    PandocMonad m =>
    OrgParser m (F BerkeleyCitationList)
    berkeleyCitationList
      F Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> OrgParser m (F Inlines))
    -> F Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
        Bool
    parens <- BerkeleyCitationList -> Bool
    berkeleyCiteParens (BerkeleyCitationList -> Bool)
    -> F BerkeleyCitationList -> Future OrgParserState Bool
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F BerkeleyCitationList
    bcl
        Maybe Inlines
    prefix <- BerkeleyCitationList -> Maybe Inlines
    berkeleyCiteCommonPrefix (BerkeleyCitationList -> Maybe Inlines)
    -> F BerkeleyCitationList -> Future OrgParserState (Maybe Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F BerkeleyCitationList
    bcl
        Maybe Inlines
    suffix <- BerkeleyCitationList -> Maybe Inlines
    berkeleyCiteCommonSuffix (BerkeleyCitationList -> Maybe Inlines)
    -> F BerkeleyCitationList -> Future OrgParserState (Maybe Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F BerkeleyCitationList
    bcl
        [Citation]
    citationList <- BerkeleyCitationList -> [Citation]
    berkeleyCiteCitations (BerkeleyCitationList -> [Citation])
    -> F BerkeleyCitationList -> F [Citation]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F BerkeleyCitationList
    bcl
        Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines) -> Inlines -> F Inlines
    forall a b. (a -> b) -> a -> b
    $
          if Bool
    parens
          then [Citation] -> Inlines
    toCite
               ([Citation] -> Inlines)
    -> ([Citation] -> [Citation]) -> [Citation] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([Citation] -> [Citation])
    -> (Inlines -> [Citation] -> [Citation])
    -> Maybe Inlines
    -> [Citation]
    -> [Citation]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe [Citation] -> [Citation]
    forall a. a -> a
    id ((Citation -> Citation) -> [Citation] -> [Citation]
    forall a. (a -> a) -> [a] -> [a]
    alterFirst ((Citation -> Citation) -> [Citation] -> [Citation])
    -> (Inlines -> Citation -> Citation)
    -> Inlines
    -> [Citation]
    -> [Citation]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inlines -> Citation -> Citation
    prependPrefix) Maybe Inlines
    prefix
               ([Citation] -> [Citation])
    -> ([Citation] -> [Citation]) -> [Citation] -> [Citation]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([Citation] -> [Citation])
    -> (Inlines -> [Citation] -> [Citation])
    -> Maybe Inlines
    -> [Citation]
    -> [Citation]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe [Citation] -> [Citation]
    forall a. a -> a
    id ((Citation -> Citation) -> [Citation] -> [Citation]
    forall a. (a -> a) -> [a] -> [a]
    alterLast ((Citation -> Citation) -> [Citation] -> [Citation])
    -> (Inlines -> Citation -> Citation)
    -> Inlines
    -> [Citation]
    -> [Citation]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inlines -> Citation -> Citation
    appendSuffix) Maybe Inlines
    suffix
               ([Citation] -> Inlines) -> [Citation] -> Inlines
    forall a b. (a -> b) -> a -> b
    $ [Citation]
    citationList
          else Inlines -> (Inlines -> Inlines) -> Maybe Inlines -> Inlines
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Inlines
    forall a. Monoid a => a
    mempty (Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> " ") Maybe Inlines
    prefix
                 Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> [Citation] -> Inlines
    toListOfCites ((Citation -> Citation) -> [Citation] -> [Citation]
    forall a b. (a -> b) -> [a] -> [b]
    map Citation -> Citation
    toInTextMode [Citation]
    citationList)
                 Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines -> (Inlines -> Inlines) -> Maybe Inlines -> Inlines
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Inlines
    forall a. Monoid a => a
    mempty (", " Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <>) Maybe Inlines
    suffix
     where
       toCite :: [Citation] -> Inlines
       toCite :: [Citation] -> Inlines
    toCite cs :: [Citation]
    cs = [Citation] -> Inlines -> Inlines
    B.cite [Citation]
    cs Inlines
    forall a. Monoid a => a
    mempty

       toListOfCites :: [Citation] -> Inlines
       toListOfCites :: [Citation] -> Inlines
    toListOfCites = [Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([Inlines] -> Inlines)
    -> ([Citation] -> [Inlines]) -> [Citation] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inlines -> [Inlines] -> [Inlines]
    forall a. a -> [a] -> [a]
    intersperse ", " ([Inlines] -> [Inlines])
    -> ([Citation] -> [Inlines]) -> [Citation] -> [Inlines]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Citation -> Inlines) -> [Citation] -> [Inlines]
    forall a b. (a -> b) -> [a] -> [b]
    map (\c :: Citation
    c -> [Citation] -> Inlines -> Inlines
    B.cite [Citation
    c] Inlines
    forall a. Monoid a => a
    mempty)

       toInTextMode :: Citation -> Citation
       toInTextMode :: Citation -> Citation
    toInTextMode c :: Citation
    c = Citation
    c { citationMode :: CitationMode
    citationMode = CitationMode
    AuthorInText }

       alterFirst, alterLast :: (a -> a) -> [a] -> [a]
       alterFirst :: (a -> a) -> [a] -> [a]
    alterFirst _ []     = []
       alterFirst f :: a -> a
    f (c :: a
    c:cs :: [a]
    cs) = a -> a
    f a
    c a -> [a] -> [a]
    forall a. a -> [a] -> [a]
    : [a]
    cs
       alterLast :: (a -> a) -> [a] -> [a]
    alterLast  f :: a -> a
    f = [a] -> [a]
    forall a. [a] -> [a]
    reverse ([a] -> [a]) -> ([a] -> [a]) -> [a] -> [a]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (a -> a) -> [a] -> [a]
    forall a. (a -> a) -> [a] -> [a]
    alterFirst a -> a
    f ([a] -> [a]) -> ([a] -> [a]) -> [a] -> [a]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [a] -> [a]
    forall a. [a] -> [a]
    reverse

       prependPrefix, appendSuffix :: Inlines -> Citation -> Citation
       prependPrefix :: Inlines -> Citation -> Citation
    prependPrefix pre :: Inlines
    pre c :: Citation
    c = Citation
    c { citationPrefix :: [Inline]
    citationPrefix = Inlines -> [Inline]
    forall a. Many a -> [a]
    B.toList Inlines
    pre [Inline] -> [Inline] -> [Inline]
    forall a. Semigroup a => a -> a -> a
    <> Citation -> [Inline]
    citationPrefix Citation
    c }
       appendSuffix :: Inlines -> Citation -> Citation
    appendSuffix  suf :: Inlines
    suf c :: Citation
    c = Citation
    c { citationSuffix :: [Inline]
    citationSuffix = Citation -> [Inline]
    citationSuffix Citation
    c [Inline] -> [Inline] -> [Inline]
    forall a. Semigroup a => a -> a -> a
    <> Inlines -> [Inline]
    forall a. Many a -> [a]
    B.toList Inlines
    suf }

    data BerkeleyCitationList = BerkeleyCitationList
      { BerkeleyCitationList -> Bool
    berkeleyCiteParens       :: Bool
      , BerkeleyCitationList -> Maybe Inlines
    berkeleyCiteCommonPrefix :: Maybe Inlines
      , BerkeleyCitationList -> Maybe Inlines
    berkeleyCiteCommonSuffix :: Maybe Inlines
      , BerkeleyCitationList -> [Citation]
    berkeleyCiteCitations    :: [Citation]
      }
    berkeleyCitationList :: PandocMonad m => OrgParser m (F BerkeleyCitationList)
    berkeleyCitationList :: OrgParser m (F BerkeleyCitationList)
    berkeleyCitationList = OrgParser m (F BerkeleyCitationList)
    -> OrgParser m (F BerkeleyCitationList)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F BerkeleyCitationList)
     -> OrgParser m (F BerkeleyCitationList))
    -> OrgParser m (F BerkeleyCitationList)
    -> OrgParser m (F BerkeleyCitationList)
    forall a b. (a -> b) -> a -> b
    $ do
      Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '['
      Bool
    parens <- [ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice [ Bool
    False Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). PandocMonad m => OrgParser m ()
    berkeleyBareTag, Bool
    True Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). PandocMonad m => OrgParser m ()
    berkeleyParensTag ]
      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) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      Maybe (F Inlines)
    commonPrefix <- ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe (F Inlines))
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m (Maybe a)
    optionMaybe (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
     -> ParsecT
          Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines))
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    citationListPart ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    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 ';')
      F [Citation]
    citations    <- OrgParser m (F [Citation])
    forall (m :: * -> *). PandocMonad m => OrgParser m (F [Citation])
    citeList
      Maybe (F Inlines)
    commonSuffix <- ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe (F Inlines))
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m (Maybe a)
    optionMaybe (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    citationListPart)
      Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ']'
      F BerkeleyCitationList -> OrgParser m (F BerkeleyCitationList)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Bool
    -> Maybe Inlines
    -> Maybe Inlines
    -> [Citation]
    -> BerkeleyCitationList
    BerkeleyCitationList Bool
    parens
        (Maybe Inlines
     -> Maybe Inlines -> [Citation] -> BerkeleyCitationList)
    -> Future OrgParserState (Maybe Inlines)
    -> Future
         OrgParserState
         (Maybe Inlines -> [Citation] -> BerkeleyCitationList)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe (F Inlines) -> Future OrgParserState (Maybe Inlines)
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence Maybe (F Inlines)
    commonPrefix
        Future
      OrgParserState
      (Maybe Inlines -> [Citation] -> BerkeleyCitationList)
    -> Future OrgParserState (Maybe Inlines)
    -> Future OrgParserState ([Citation] -> BerkeleyCitationList)
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Maybe (F Inlines) -> Future OrgParserState (Maybe Inlines)
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence Maybe (F Inlines)
    commonSuffix
        Future OrgParserState ([Citation] -> BerkeleyCitationList)
    -> F [Citation] -> F BerkeleyCitationList
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> F [Citation]
    citations)
     where
       citationListPart :: PandocMonad m => OrgParser m (F Inlines)
       citationListPart :: OrgParser m (F Inlines)
    citationListPart = ([F Inlines] -> F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> F Inlines)
    -> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat) (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
     -> OrgParser m (F Inlines))
    -> (OrgParser m (F Inlines)
        -> ParsecT
             Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines])
    -> OrgParser m (F Inlines)
    -> OrgParser m (F Inlines)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
     -> ParsecT
          Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines])
    -> (OrgParser m (F Inlines)
        -> ParsecT
             Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines])
    -> OrgParser m (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OrgParser m (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
         ParserT Text OrgParserState (ReaderT OrgParserLocal m) (Bool, Text)
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' ParserT Text OrgParserState (ReaderT OrgParserLocal m) (Bool, Text)
    forall s (m :: * -> *) st.
    (Stream s m Char, HasLastStrPosition st) =>
    ParserT s st m (Bool, Text)
    citeKey
         ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy ([Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf ";]")
         OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inline

    berkeleyBareTag :: PandocMonad m => OrgParser m ()
    berkeleyBareTag :: OrgParser m ()
    berkeleyBareTag = 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
    $ OrgParser m () -> OrgParser m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void OrgParser m ()
    forall (m :: * -> *). PandocMonad m => OrgParser m ()
    berkeleyBareTag'

    berkeleyParensTag :: PandocMonad m => OrgParser m ()
    berkeleyParensTag :: OrgParser m ()
    berkeleyParensTag = OrgParser m () -> OrgParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m () -> OrgParser m ())
    -> (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [()]
        -> OrgParser m ())
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [()]
    -> OrgParser m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . 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
    $ Char
    -> Char
    -> OrgParser m ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [()]
    forall (m :: * -> *) a.
    PandocMonad m =>
    Char -> Char -> OrgParser m a -> OrgParser m [a]
    enclosedByPair1 '(' ')' OrgParser m ()
    forall (m :: * -> *). PandocMonad m => OrgParser m ()
    berkeleyBareTag'

    berkeleyBareTag' :: PandocMonad m => OrgParser m ()
    berkeleyBareTag' :: OrgParser m ()
    berkeleyBareTag' = 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
    $ ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> OrgParser m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void ([Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "cite")

    berkeleyTextualCite :: PandocMonad m => OrgParser m (F [Citation])
    berkeleyTextualCite :: OrgParser m (F [Citation])
    berkeleyTextualCite = OrgParser m (F [Citation]) -> OrgParser m (F [Citation])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F [Citation]) -> OrgParser m (F [Citation]))
    -> OrgParser m (F [Citation]) -> OrgParser m (F [Citation])
    forall a b. (a -> b) -> a -> b
    $ do
      (suppressAuthor :: Bool
    suppressAuthor, key :: Text
    key) <- ParserT Text OrgParserState (ReaderT OrgParserLocal m) (Bool, Text)
    forall s (m :: * -> *) st.
    (Stream s m Char, HasLastStrPosition st) =>
    ParserT s st m (Bool, Text)
    citeKey
      [Citation] -> OrgParser m (F [Citation])
    forall (m :: * -> *) a s. Monad m => a -> m (Future s a)
    returnF ([Citation] -> OrgParser m (F [Citation]))
    -> (Citation -> [Citation])
    -> Citation
    -> OrgParser m (F [Citation])
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Citation -> [Citation]
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Citation -> OrgParser m (F [Citation]))
    -> Citation -> OrgParser m (F [Citation])
    forall a b. (a -> b) -> a -> b
    $ Citation :: Text
    -> [Inline] -> [Inline] -> CitationMode -> Int -> Int -> Citation
    Citation
        { citationId :: Text
    citationId      = Text
    key
        , citationPrefix :: [Inline]
    citationPrefix  = [Inline]
    forall a. Monoid a => a
    mempty
        , citationSuffix :: [Inline]
    citationSuffix  = [Inline]
    forall a. Monoid a => a
    mempty
        , citationMode :: CitationMode
    citationMode    = if Bool
    suppressAuthor then CitationMode
    SuppressAuthor else CitationMode
    AuthorInText
        , citationNoteNum :: Int
    citationNoteNum = 0
        , citationHash :: Int
    citationHash    = 0
        }

    -- The following is what a Berkeley-style bracketed textual citation parser
    -- would look like.  However, as these citations are a subset of Pandoc's Org
    -- citation style, this isn't used.
    -- berkeleyBracketedTextualCite :: PandocMonad m => OrgParser m (F [Citation])
    -- berkeleyBracketedTextualCite = try . (fmap head) $
    --   enclosedByPair1 '[' ']' berkeleyTextualCite

    -- | Read a link-like org-ref style citation.  The citation includes pre and
    -- post text.  However, multiple citations are not possible due to limitations
    -- in the syntax.
    linkLikeOrgRefCite :: PandocMonad m => OrgParser m (F Citation)
    linkLikeOrgRefCite :: OrgParser m (Future OrgParserState Citation)
    linkLikeOrgRefCite = OrgParser m (Future OrgParserState Citation)
    -> OrgParser m (Future OrgParserState Citation)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (Future OrgParserState Citation)
     -> OrgParser m (Future OrgParserState Citation))
    -> OrgParser m (Future OrgParserState Citation)
    -> OrgParser m (Future OrgParserState Citation)
    forall a b. (a -> b) -> a -> b
    $ do
      [Char]
    _    <- [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "[["
      CitationMode
    mode <- OrgParser m CitationMode
    forall (m :: * -> *). PandocMonad m => OrgParser m CitationMode
    orgRefCiteMode
      Text
    key  <- OrgParser m Text
    forall (m :: * -> *). PandocMonad m => OrgParser m Text
    orgRefCiteKey
      [Char]
    _    <- [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "]["
      F Inlines
    pre  <- F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> F Inlines)
    -> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    manyTill ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inline (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
    try (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    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]
    string "::")
      Bool
    spc  <- Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option Bool
    False (Bool
    True Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    spaceChar)
      F Inlines
    suf  <- F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> F Inlines)
    -> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    manyTill ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inline (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
    try (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    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]
    string "]]")
      Future OrgParserState Citation
    -> OrgParser m (Future OrgParserState Citation)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Future OrgParserState Citation
     -> OrgParser m (Future OrgParserState Citation))
    -> Future OrgParserState Citation
    -> OrgParser m (Future OrgParserState Citation)
    forall a b. (a -> b) -> a -> b
    $ do
        Inlines
    pre' <- F Inlines
    pre
        Inlines
    suf' <- F Inlines
    suf
        Citation -> Future OrgParserState Citation
    forall (m :: * -> *) a. Monad m => a -> m a
    return Citation :: Text
    -> [Inline] -> [Inline] -> CitationMode -> Int -> Int -> Citation
    Citation
          { citationId :: Text
    citationId      = Text
    key
          , citationPrefix :: [Inline]
    citationPrefix  = Inlines -> [Inline]
    forall a. Many a -> [a]
    B.toList Inlines
    pre'
          , citationSuffix :: [Inline]
    citationSuffix  = Inlines -> [Inline]
    forall a. Many a -> [a]
    B.toList (if Bool
    spc then Inlines
    B.space Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    suf' else Inlines
    suf')
          , citationMode :: CitationMode
    citationMode    = CitationMode
    mode
          , citationNoteNum :: Int
    citationNoteNum = 0
          , citationHash :: Int
    citationHash    = 0
          }

    -- | Read a citation key.  The characters allowed in citation keys are taken
    -- from the `org-ref-cite-re` variable in `org-ref.el`.
    orgRefCiteKey :: PandocMonad m => OrgParser m Text
    orgRefCiteKey :: OrgParser m Text
    orgRefCiteKey =
      let citeKeySpecialChars :: [Char]
    citeKeySpecialChars = "-_:\\./," :: String
          isCiteKeySpecialChar :: Char -> Bool
    isCiteKeySpecialChar c :: Char
    c = Char
    c Char -> [Char] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [Char]
    citeKeySpecialChars
          isCiteKeyChar :: Char -> Bool
    isCiteKeyChar c :: Char
    c = Char -> Bool
    isAlphaNum Char
    c Bool -> Bool -> Bool
    || Char -> Bool
    isCiteKeySpecialChar Char
    c
          endOfCitation :: ParsecT Text u (ReaderT OrgParserLocal m) Char
    endOfCitation = ParsecT Text u (ReaderT OrgParserLocal m) Char
    -> ParsecT Text u (ReaderT OrgParserLocal m) Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text u (ReaderT OrgParserLocal m) Char
     -> ParsecT Text u (ReaderT OrgParserLocal m) Char)
    -> ParsecT Text u (ReaderT OrgParserLocal m) Char
    -> ParsecT Text u (ReaderT OrgParserLocal m) Char
    forall a b. (a -> b) -> a -> b
    $ do
            ParsecT Text u (ReaderT OrgParserLocal m) Char
    -> ParsecT Text u (ReaderT OrgParserLocal m) [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParsecT Text u (ReaderT OrgParserLocal m) Char
     -> ParsecT Text u (ReaderT OrgParserLocal m) [Char])
    -> ParsecT Text u (ReaderT OrgParserLocal m) Char
    -> ParsecT Text u (ReaderT OrgParserLocal m) [Char]
    forall a b. (a -> b) -> a -> b
    $ (Char -> Bool) -> ParsecT Text u (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy Char -> Bool
    isCiteKeySpecialChar
            (Char -> Bool) -> ParsecT Text u (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy ((Char -> Bool) -> ParsecT Text u (ReaderT OrgParserLocal m) Char)
    -> (Char -> Bool) -> ParsecT Text u (ReaderT OrgParserLocal m) Char
    forall a b. (a -> b) -> a -> b
    $ Bool -> Bool
    not (Bool -> Bool) -> (Char -> Bool) -> Char -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Char -> Bool
    isCiteKeyChar
      in 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 -> Bool)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy Char -> Bool
    isCiteKeyChar ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m Text
    forall end s (m :: * -> *) t st.
    (Show end, Stream s m t) =>
    ParserT s st m Char -> ParserT s st m end -> ParserT s st m Text
    `many1TillChar` 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 u. ParsecT Text u (ReaderT OrgParserLocal m) Char
    endOfCitation

    -- | Supported citation types.  Only a small subset of org-ref types is
    -- supported for now.  TODO: rewrite this, use LaTeX reader as template.
    orgRefCiteMode :: PandocMonad m => OrgParser m CitationMode
    orgRefCiteMode :: OrgParser m CitationMode
    orgRefCiteMode =
      [OrgParser m CitationMode] -> OrgParser m CitationMode
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice ([OrgParser m CitationMode] -> OrgParser m CitationMode)
    -> [OrgParser m CitationMode] -> OrgParser m CitationMode
    forall a b. (a -> b) -> a -> b
    $ (([Char], CitationMode) -> OrgParser m CitationMode)
    -> [([Char], CitationMode)] -> [OrgParser m CitationMode]
    forall a b. (a -> b) -> [a] -> [b]
    map (\(s :: [Char]
    s, mode :: CitationMode
    mode) -> CitationMode
    mode CitationMode
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> OrgParser m CitationMode
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ 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
    try ([Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string [Char]
    s ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> 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 a
    <* Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':'))
        [ ("cite", CitationMode
    AuthorInText)
        , ("citep", CitationMode
    NormalCitation)
        , ("citep*", CitationMode
    NormalCitation)
        , ("citet", CitationMode
    AuthorInText)
        , ("citet*", CitationMode
    AuthorInText)
        , ("citeyear", CitationMode
    SuppressAuthor)
        ]

    citeList :: PandocMonad m => OrgParser m (F [Citation])
    citeList :: OrgParser m (F [Citation])
    citeList = [Future OrgParserState Citation] -> F [Citation]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence ([Future OrgParserState Citation] -> F [Citation])
    -> ParsecT
         Text
         OrgParserState
         (ReaderT OrgParserLocal m)
         [Future OrgParserState Citation]
    -> OrgParser m (F [Citation])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT
      Text
      OrgParserState
      (ReaderT OrgParserLocal m)
      (Future OrgParserState Citation)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT
         Text
         OrgParserState
         (ReaderT OrgParserLocal m)
         [Future OrgParserState Citation]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    sepEndBy1 ParsecT
      Text
      OrgParserState
      (ReaderT OrgParserLocal m)
      (Future OrgParserState Citation)
    forall (m :: * -> *).
    PandocMonad m =>
    OrgParser m (Future OrgParserState Citation)
    citation (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    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
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces)

    citation :: PandocMonad m => OrgParser m (F Citation)
    citation :: OrgParser m (Future OrgParserState Citation)
    citation = OrgParser m (Future OrgParserState Citation)
    -> OrgParser m (Future OrgParserState Citation)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (Future OrgParserState Citation)
     -> OrgParser m (Future OrgParserState Citation))
    -> OrgParser m (Future OrgParserState Citation)
    -> OrgParser m (Future OrgParserState Citation)
    forall a b. (a -> b) -> a -> b
    $ do
      F Inlines
    pref <- ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    prefix
      (suppress_author :: Bool
    suppress_author, key :: Text
    key) <- ParserT Text OrgParserState (ReaderT OrgParserLocal m) (Bool, Text)
    forall s (m :: * -> *) st.
    (Stream s m Char, HasLastStrPosition st) =>
    ParserT s st m (Bool, Text)
    citeKey
      F Inlines
    suff <- ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    suffix
      Future OrgParserState Citation
    -> OrgParser m (Future OrgParserState Citation)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Future OrgParserState Citation
     -> OrgParser m (Future OrgParserState Citation))
    -> Future OrgParserState Citation
    -> OrgParser m (Future OrgParserState Citation)
    forall a b. (a -> b) -> a -> b
    $ do
        Inlines
    x <- F Inlines
    pref
        Inlines
    y <- F Inlines
    suff
        Citation -> Future OrgParserState Citation
    forall (m :: * -> *) a. Monad m => a -> m a
    return Citation :: Text
    -> [Inline] -> [Inline] -> CitationMode -> Int -> Int -> Citation
    Citation
          { citationId :: Text
    citationId      = Text
    key
          , citationPrefix :: [Inline]
    citationPrefix  = Inlines -> [Inline]
    forall a. Many a -> [a]
    B.toList Inlines
    x
          , citationSuffix :: [Inline]
    citationSuffix  = Inlines -> [Inline]
    forall a. Many a -> [a]
    B.toList Inlines
    y
          , citationMode :: CitationMode
    citationMode    = if Bool
    suppress_author
                              then CitationMode
    SuppressAuthor
                              else CitationMode
    NormalCitation
          , citationNoteNum :: Int
    citationNoteNum = 0
          , citationHash :: Int
    citationHash    = 0
          }
     where
       prefix :: ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    prefix = F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> F Inlines)
    -> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    manyTill ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inline (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
    -> 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
    <|> (']' Char
    -> ParserT
         Text OrgParserState (ReaderT OrgParserLocal m) (Bool, Text)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParserT Text OrgParserState (ReaderT OrgParserLocal m) (Bool, Text)
    -> ParserT
         Text OrgParserState (ReaderT OrgParserLocal m) (Bool, Text)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead ParserT Text OrgParserState (ReaderT OrgParserLocal m) (Bool, Text)
    forall s (m :: * -> *) st.
    (Stream s m Char, HasLastStrPosition st) =>
    ParserT s st m (Bool, Text)
    citeKey))
       suffix :: ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    suffix = ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
     -> ParsecT
          Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines))
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
         Bool
    hasSpace <- Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option Bool
    False (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    nonspaceChar ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    True)
         ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
         F Inlines
    rest <- F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> F Inlines)
    -> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                 ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy ([Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf ";]") ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inline)
         F Inlines
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines
     -> ParsecT
          Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines))
    -> F Inlines
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ if Bool
    hasSpace
                  then (Inlines
    B.space Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <>) (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    rest
                  else F Inlines
    rest

    footnote :: PandocMonad m => OrgParser m (F Inlines)
    footnote :: OrgParser m (F Inlines)
    footnote = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inlineNote OrgParser m (F Inlines)
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    referencedNote

    inlineNote :: PandocMonad m => OrgParser m (F Inlines)
    inlineNote :: OrgParser m (F Inlines)
    inlineNote = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "[fn:"
      Text
    ref <- 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
    manyChar ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    alphaNum
      Char -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':'
      Future OrgParserState Blocks
    note <- (Inlines -> Blocks) -> F Inlines -> Future OrgParserState Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Inlines -> Blocks
    B.para (F Inlines -> Future OrgParserState Blocks)
    -> ([F Inlines] -> F Inlines)
    -> [F Inlines]
    -> Future OrgParserState Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> F Inlines)
    -> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> Future OrgParserState Blocks)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> ParsecT
         Text
         OrgParserState
         (ReaderT OrgParserLocal m)
         (Future OrgParserState Blocks)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> OrgParser m (F Inlines)
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall end s (m :: * -> *) t st a.
    (Show end, Stream s m t) =>
    ParserT s st m a -> ParserT s st m end -> ParserT s st m [a]
    many1Till OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inline (Char -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ']')
      Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    unless (Text -> Bool
    T.null Text
    ref) (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall a b. (a -> b) -> a -> b
    $
           OrgNoteRecord
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *).
    PandocMonad m =>
    OrgNoteRecord -> OrgParser m ()
    addToNotesTable ("fn:" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    ref, Future OrgParserState Blocks
    note)
      F Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> OrgParser m (F Inlines))
    -> F Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Blocks -> Inlines
    B.note (Blocks -> Inlines) -> Future OrgParserState Blocks -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Future OrgParserState Blocks
    note

    referencedNote :: PandocMonad m => OrgParser m (F Inlines)
    referencedNote :: OrgParser m (F Inlines)
    referencedNote = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    ref <- OrgParser m Text
    forall (m :: * -> *). Monad m => OrgParser m Text
    noteMarker
      F Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> OrgParser m (F Inlines))
    -> F Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
        OrgNoteTable
    notes <- (OrgParserState -> OrgNoteTable)
    -> Future OrgParserState OrgNoteTable
    forall s a. (s -> a) -> Future s a
    asksF OrgParserState -> OrgNoteTable
    orgStateNotes'
        case Text -> OrgNoteTable -> Maybe (Future OrgParserState Blocks)
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup Text
    ref OrgNoteTable
    notes of
          Nothing   -> Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines) -> (Text -> Inlines) -> Text -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Inlines
    B.str (Text -> F Inlines) -> Text -> F Inlines
    forall a b. (a -> b) -> a -> b
    $ "[" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    ref Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> "]"
          Just contents :: Future OrgParserState Blocks
    contents  -> do
            OrgParserState
    st <- Future OrgParserState OrgParserState
    forall s. Future s s
    askF
            let contents' :: Blocks
    contents' = Future OrgParserState Blocks -> OrgParserState -> Blocks
    forall s a. Future s a -> s -> a
    runF Future OrgParserState Blocks
    contents OrgParserState
    st{ orgStateNotes' :: OrgNoteTable
    orgStateNotes' = [] }
            Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines) -> Inlines -> F Inlines
    forall a b. (a -> b) -> a -> b
    $ Blocks -> Inlines
    B.note Blocks
    contents'

    linkOrImage :: PandocMonad m => OrgParser m (F Inlines)
    linkOrImage :: OrgParser m (F Inlines)
    linkOrImage = OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    explicitOrImageLink
                  OrgParser m (F Inlines)
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    selflinkOrImage
                  OrgParser m (F Inlines)
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    angleLink
                  OrgParser m (F Inlines)
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    plainLink
                  OrgParser m (F Inlines) -> [Char] -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> "link or image"

    explicitOrImageLink :: PandocMonad m => OrgParser m (F Inlines)
    explicitOrImageLink :: OrgParser m (F Inlines)
    explicitOrImageLink = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '['
      F Text
    srcF   <- Text -> OrgParser m (F Text)
    forall (m :: * -> *). Text -> OrgParser m (F Text)
    applyCustomLinkFormat (Text -> OrgParser m (F Text))
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> OrgParser m (F Text)
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *). PandocMonad m => OrgParser m Text
    possiblyEmptyLinkTarget
      Text
    descr  <- ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *) b a.
    (PandocMonad m, Show b) =>
    OrgParser m a -> OrgParser m b -> OrgParser m Text
    enclosedRaw (Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '[') (Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ']')
      F Inlines
    titleF <- OrgParser m (F Inlines) -> Text -> OrgParser m (F Inlines)
    forall (m :: * -> *) a.
    Monad m =>
    OrgParser m a -> Text -> OrgParser m a
    parseFromString ([F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> OrgParser m (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inline) Text
    descr
      Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ']'
      F Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> OrgParser m (F Inlines))
    -> F Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
        Text
    src <- F Text
    srcF
        Inlines
    title <- F Inlines
    titleF
        case Text -> Maybe Text
    cleanLinkText Text
    descr of
          Just imgSrc :: Text
    imgSrc | Text -> Bool
    isImageFilename Text
    imgSrc ->
            Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines)
    -> (Inlines -> Inlines) -> Inlines -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text -> Inlines -> Inlines
    B.link Text
    src "" (Inlines -> F Inlines) -> Inlines -> F Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Text -> Inlines -> Inlines
    B.image Text
    imgSrc Text
    forall a. Monoid a => a
    mempty Inlines
    forall a. Monoid a => a
    mempty
          _ ->
            Text -> Inlines -> F Inlines
    linkToInlinesF Text
    src Inlines
    title

    selflinkOrImage :: PandocMonad m => OrgParser m (F Inlines)
    selflinkOrImage :: OrgParser m (F Inlines)
    selflinkOrImage = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    target <- 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
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *). PandocMonad m => OrgParser m Text
    linkTarget ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal 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 ']'
      case Text -> Maybe Text
    cleanLinkText Text
    target of
        Nothing        -> case Text -> Maybe (Char, Text)
    T.uncons Text
    target of
                            Just ('#', _) -> Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a s. Monad m => a -> m (Future s a)
    returnF (Inlines -> OrgParser m (F Inlines))
    -> Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Text -> Text -> Inlines -> Inlines
    B.link Text
    target "" (Text -> Inlines
    B.str Text
    target)
                            _             -> F Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> OrgParser m (F Inlines))
    -> F Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Text -> Inlines -> F Inlines
    internalLink Text
    target (Text -> Inlines
    B.str Text
    target)
        Just nonDocTgt :: Text
    nonDocTgt -> if Text -> Bool
    isImageFilename Text
    nonDocTgt
                          then Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a s. Monad m => a -> m (Future s a)
    returnF (Inlines -> OrgParser m (F Inlines))
    -> Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Text -> Text -> Inlines -> Inlines
    B.image Text
    nonDocTgt "" ""
                          else Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a s. Monad m => a -> m (Future s a)
    returnF (Inlines -> OrgParser m (F Inlines))
    -> Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Text -> Text -> Inlines -> Inlines
    B.link Text
    nonDocTgt "" (Text -> Inlines
    B.str Text
    target)

    plainLink :: PandocMonad m => OrgParser m (F Inlines)
    plainLink :: OrgParser m (F Inlines)
    plainLink = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      (orig :: Text
    orig, src :: Text
    src) <- ParserT Text OrgParserState (ReaderT OrgParserLocal m) (Text, Text)
    forall s (m :: * -> *) st.
    Stream s m Char =>
    ParserT s st m (Text, Text)
    uri
      Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a s. Monad m => a -> m (Future s a)
    returnF (Inlines -> OrgParser m (F Inlines))
    -> Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Text -> Text -> Inlines -> Inlines
    B.link Text
    src "" (Text -> Inlines
    B.str Text
    orig)

    angleLink :: PandocMonad m => OrgParser m (F Inlines)
    angleLink :: OrgParser m (F Inlines)
    angleLink = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '<'
      F Inlines
    link <- OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    plainLink
      Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '>'
      F Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Inlines
    link

    linkTarget :: PandocMonad m => OrgParser m Text
    linkTarget :: OrgParser m Text
    linkTarget = [Char] -> Text
    T.pack ([Char] -> Text)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> OrgParser m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Char
    -> Char
    -> OrgParser m Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall (m :: * -> *) a.
    PandocMonad m =>
    Char -> Char -> OrgParser m a -> OrgParser m [a]
    enclosedByPair1 '[' ']' ([Char] -> OrgParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf "\n\r[]")

    possiblyEmptyLinkTarget :: PandocMonad m => OrgParser m Text
    possiblyEmptyLinkTarget :: OrgParser m Text
    possiblyEmptyLinkTarget = 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
    forall (m :: * -> *). PandocMonad m => OrgParser m Text
    linkTarget OrgParser m Text -> OrgParser m Text -> OrgParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ("" Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> OrgParser m Text
    forall (f :: * -> *) a b. Functor 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]
    string "[]")

    applyCustomLinkFormat :: Text -> OrgParser m (F Text)
    applyCustomLinkFormat :: Text -> OrgParser m (F Text)
    applyCustomLinkFormat link :: Text
    link = do
      let (linkType :: Text
    linkType, rest :: Text
    rest) = (Char -> Bool) -> Text -> (Text, Text)
    T.break (Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == ':') Text
    link
      F Text -> OrgParser m (F Text)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Text -> OrgParser m (F Text)) -> F Text -> OrgParser m (F Text)
    forall a b. (a -> b) -> a -> b
    $ do
        Maybe (Text -> Text)
    formatter <- Text -> Map Text (Text -> Text) -> Maybe (Text -> Text)
    forall k a. Ord k => k -> Map k a -> Maybe a
    M.lookup Text
    linkType (Map Text (Text -> Text) -> Maybe (Text -> Text))
    -> Future OrgParserState (Map Text (Text -> Text))
    -> Future OrgParserState (Maybe (Text -> Text))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (OrgParserState -> Map Text (Text -> Text))
    -> Future OrgParserState (Map Text (Text -> Text))
    forall s a. (s -> a) -> Future s a
    asksF OrgParserState -> Map Text (Text -> Text)
    orgStateLinkFormatters
        Text -> F Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> F Text) -> Text -> F Text
    forall a b. (a -> b) -> a -> b
    $ Text -> ((Text -> Text) -> Text) -> Maybe (Text -> Text) -> Text
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Text
    link ((Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $ Int -> Text -> Text
    T.drop 1 Text
    rest) Maybe (Text -> Text)
    formatter

    -- | Take a link and return a function which produces new inlines when given
    -- description inlines.
    linkToInlinesF :: Text -> Inlines -> F Inlines
    linkToInlinesF :: Text -> Inlines -> F Inlines
    linkToInlinesF linkStr :: Text
    linkStr =
      case Text -> Maybe (Char, Text)
    T.uncons Text
    linkStr of
        Nothing       -> Inlines -> F Inlines
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (Inlines -> F Inlines)
    -> (Inlines -> Inlines) -> Inlines -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text -> Inlines -> Inlines
    B.link Text
    forall a. Monoid a => a
    mempty ""       -- wiki link (empty by convention)
        Just ('#', _) -> Inlines -> F Inlines
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (Inlines -> F Inlines)
    -> (Inlines -> Inlines) -> Inlines -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text -> Inlines -> Inlines
    B.link Text
    linkStr ""      -- document-local fraction
        _             -> case Text -> Maybe Text
    cleanLinkText Text
    linkStr of
          Just extTgt :: Text
    extTgt -> Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines)
    -> (Inlines -> Inlines) -> Inlines -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text -> Inlines -> Inlines
    B.link Text
    extTgt ""
          Nothing     -> Text -> Inlines -> F Inlines
    internalLink Text
    linkStr  -- other internal link

    internalLink :: Text -> Inlines -> F Inlines
    internalLink :: Text -> Inlines -> F Inlines
    internalLink link :: Text
    link title :: Inlines
    title = do
      Bool
    anchorB <- (Text
    link Text -> [Text] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem`) ([Text] -> Bool)
    -> Future OrgParserState [Text] -> Future OrgParserState Bool
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (OrgParserState -> [Text]) -> Future OrgParserState [Text]
    forall s a. (s -> a) -> Future s a
    asksF OrgParserState -> [Text]
    orgStateAnchorIds
      if Bool
    anchorB
        then Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines) -> Inlines -> F Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Text -> Inlines -> Inlines
    B.link ("#" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    link) "" Inlines
    title
        else Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines) -> Inlines -> F Inlines
    forall a b. (a -> b) -> a -> b
    $ Inlines -> Inlines
    B.emph Inlines
    title

    -- | Parse an anchor like @<<anchor-id>>@ and return an empty span with
    -- @anchor-id@ set as id.  Legal anchors in org-mode are defined through
    -- @org-target-regexp@, which is fairly liberal.  Since no link is created if
    -- @anchor-id@ contains spaces, we are more restrictive in what is accepted as
    -- an anchor.

    anchor :: PandocMonad m => OrgParser m (F Inlines)
    anchor :: OrgParser m (F Inlines)
    anchor =  OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    anchorId <- ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall u. ParsecT Text u (ReaderT OrgParserLocal m) Text
    parseAnchor
      Text -> OrgParser m ()
    forall (m :: * -> *). PandocMonad m => Text -> OrgParser m ()
    recordAnchorId Text
    anchorId
      Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a s. Monad m => a -> m (Future s a)
    returnF (Inlines -> OrgParser m (F Inlines))
    -> Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Attr -> Inlines -> Inlines
    B.spanWith (Text -> Text
    solidify Text
    anchorId, [], []) Inlines
    forall a. Monoid a => a
    mempty
     where
           parseAnchor :: ParsecT Text u (ReaderT OrgParserLocal m) Text
    parseAnchor = [Char] -> ParsecT Text u (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "<<"
                         ParsecT Text u (ReaderT OrgParserLocal m) [Char]
    -> ParsecT Text u (ReaderT OrgParserLocal m) Text
    -> ParsecT Text u (ReaderT OrgParserLocal m) Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParserT Text u (ReaderT OrgParserLocal m) Char
    -> ParsecT Text u (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char ([Char] -> ParserT Text u (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf "\t\n\r<>\"' ")
                         ParsecT Text u (ReaderT OrgParserLocal m) Text
    -> ParsecT Text u (ReaderT OrgParserLocal m) [Char]
    -> ParsecT Text u (ReaderT OrgParserLocal m) Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* [Char] -> ParsecT Text u (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string ">>"
                         ParsecT Text u (ReaderT OrgParserLocal m) Text
    -> ParsecT Text u (ReaderT OrgParserLocal m) ()
    -> ParsecT Text u (ReaderT OrgParserLocal m) Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text u (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces

    -- | Replace every char but [a-zA-Z0-9_.-:] with a hyphen '-'.  This mirrors
    -- the org function @org-export-solidify-link-text@.

    solidify :: Text -> Text
    solidify :: Text -> Text
    solidify = (Char -> Char) -> Text -> Text
    T.map Char -> Char
    replaceSpecialChar
     where replaceSpecialChar :: Char -> Char
    replaceSpecialChar c :: Char
    c
               | Char -> Bool
    isAlphaNum Char
    c    = Char
    c
               | Char
    c Char -> [Char] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` ("_.-:" :: String) = Char
    c
               | Bool
    otherwise       = '-'

    -- | Parses an inline code block and marks it as an babel block.
    inlineCodeBlock :: PandocMonad m => OrgParser m (F Inlines)
    inlineCodeBlock :: OrgParser m (F Inlines)
    inlineCodeBlock = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "src_"
      Text
    lang <- 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 (m :: * -> *). Monad m => OrgParser m Char
    orgArgWordChar
      [(Text, Text)]
    opts <- [(Text, Text)]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [(Text, Text)]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [(Text, Text)]
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option [] (ParsecT
       Text OrgParserState (ReaderT OrgParserLocal m) [(Text, Text)]
     -> ParsecT
          Text OrgParserState (ReaderT OrgParserLocal m) [(Text, Text)])
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [(Text, Text)]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [(Text, Text)]
    forall a b. (a -> b) -> a -> b
    $ Char
    -> Char
    -> OrgParser m (Text, Text)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [(Text, Text)]
    forall (m :: * -> *) a.
    PandocMonad m =>
    Char -> Char -> OrgParser m a -> OrgParser m [a]
    enclosedByPair '[' ']' OrgParser m (Text, Text)
    forall (m :: * -> *). PandocMonad m => OrgParser m (Text, Text)
    inlineBlockOption
      Text
    inlineCode <- [Char] -> Text
    T.pack ([Char] -> Text)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Char
    -> Char
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall (m :: * -> *) a.
    PandocMonad m =>
    Char -> Char -> OrgParser m a -> OrgParser m [a]
    enclosedByPair1 '{' '}' ([Char]
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf "\n\r")
      let attrClasses :: [Text]
    attrClasses = [Text -> Text
    translateLang Text
    lang]
      let attrKeyVal :: [(Text, Text)]
    attrKeyVal  = Text -> [(Text, Text)]
    originalLang Text
    lang [(Text, Text)] -> [(Text, Text)] -> [(Text, Text)]
    forall a. Semigroup a => a -> a -> a
    <> [(Text, Text)]
    opts
      let codeInlineBlck :: Inlines
    codeInlineBlck = Attr -> Text -> Inlines
    B.codeWith ("", [Text]
    attrClasses, [(Text, Text)]
    attrKeyVal) Text
    inlineCode
      Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a s. Monad m => a -> m (Future s a)
    returnF (Inlines -> OrgParser m (F Inlines))
    -> Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ if [(Text, Text)] -> Bool
    exportsCode [(Text, Text)]
    opts then Inlines
    codeInlineBlck else Inlines
    forall a. Monoid a => a
    mempty
     where
       inlineBlockOption :: PandocMonad m => OrgParser m (Text, Text)
       inlineBlockOption :: OrgParser m (Text, Text)
    inlineBlockOption = OrgParser m (Text, Text) -> OrgParser m (Text, Text)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (Text, Text) -> OrgParser m (Text, Text))
    -> OrgParser m (Text, Text) -> OrgParser m (Text, Text)
    forall a b. (a -> b) -> a -> b
    $ do
         Text
    argKey <- OrgParser m Text
    forall (m :: * -> *). Monad m => OrgParser m Text
    orgArgKey
         Text
    paramValue <- Text -> OrgParser m Text -> OrgParser m Text
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option "yes" OrgParser m Text
    forall (m :: * -> *). PandocMonad m => OrgParser m Text
    orgInlineParamValue
         (Text, Text) -> OrgParser m (Text, Text)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text
    argKey, Text
    paramValue)

       orgInlineParamValue :: PandocMonad m => OrgParser m Text
       orgInlineParamValue :: OrgParser m Text
    orgInlineParamValue = 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
    $
         ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
           ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy (Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':')
           ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> 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
    -> OrgParser m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char ([Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf "\t\n\r ]")
           OrgParser m Text
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces

    emphasizedText :: PandocMonad m => OrgParser m (F Inlines)
    emphasizedText :: OrgParser m (F Inlines)
    emphasizedText = do
      OrgParserState
    state <- ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> (OrgParserState -> Bool)
    -> OrgParserState
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ExportSettings -> Bool
    exportEmphasizedText (ExportSettings -> Bool)
    -> (OrgParserState -> ExportSettings) -> OrgParserState -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OrgParserState -> ExportSettings
    orgStateExportSettings (OrgParserState
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> OrgParserState
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall a b. (a -> b) -> a -> b
    $ OrgParserState
    state
      OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ [OrgParser m (F Inlines)] -> OrgParser m (F Inlines)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice
        [ OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    emph
        , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    strong
        , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    strikeout
        , OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    underline
        ]

    enclosedByPair :: PandocMonad m
                   => Char          -- ^ opening char
                   -> Char          -- ^ closing char
                   -> OrgParser m a   -- ^ parser
                   -> OrgParser m [a]
    enclosedByPair :: Char -> Char -> OrgParser m a -> OrgParser m [a]
    enclosedByPair s :: Char
    s e :: Char
    e p :: OrgParser m a
    p = Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    s ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m [a] -> OrgParser m [a]
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> OrgParser m a
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m [a]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    manyTill OrgParser m a
    p (Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    e)

    enclosedByPair1 :: PandocMonad m
                   => Char          -- ^ opening char
                   -> Char          -- ^ closing char
                   -> OrgParser m a   -- ^ parser
                   -> OrgParser m [a]
    enclosedByPair1 :: Char -> Char -> OrgParser m a -> OrgParser m [a]
    enclosedByPair1 s :: Char
    s e :: Char
    e p :: OrgParser m a
    p = Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    s ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m [a] -> OrgParser m [a]
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> OrgParser m a
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m [a]
    forall end s (m :: * -> *) t st a.
    (Show end, Stream s m t) =>
    ParserT s st m a -> ParserT s st m end -> ParserT s st m [a]
    many1Till OrgParser m a
    p (Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    e)

    emph      :: PandocMonad m => OrgParser m (F Inlines)
    emph :: OrgParser m (F Inlines)
    emph      = (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Inlines -> Inlines
    B.emph         (F Inlines -> F Inlines)
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Char -> OrgParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> OrgParser m (F Inlines)
    emphasisBetween '/'

    strong    :: PandocMonad m => OrgParser m (F Inlines)
    strong :: OrgParser m (F Inlines)
    strong    = (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Inlines -> Inlines
    B.strong       (F Inlines -> F Inlines)
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Char -> OrgParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> OrgParser m (F Inlines)
    emphasisBetween '*'

    strikeout :: PandocMonad m => OrgParser m (F Inlines)
    strikeout :: OrgParser m (F Inlines)
    strikeout = (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Inlines -> Inlines
    B.strikeout    (F Inlines -> F Inlines)
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Char -> OrgParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> OrgParser m (F Inlines)
    emphasisBetween '+'

    underline :: PandocMonad m => OrgParser m (F Inlines)
    underline :: OrgParser m (F Inlines)
    underline = (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Inlines -> Inlines
    underlineSpan  (F Inlines -> F Inlines)
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Char -> OrgParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> OrgParser m (F Inlines)
    emphasisBetween '_'

    verbatim  :: PandocMonad m => OrgParser m (F Inlines)
    verbatim :: OrgParser m (F Inlines)
    verbatim  = Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines) -> (Text -> Inlines) -> Text -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Inlines
    B.code     (Text -> F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Text
    verbatimBetween '='

    code      :: PandocMonad m => OrgParser m (F Inlines)
    code :: OrgParser m (F Inlines)
    code      = Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines) -> (Text -> Inlines) -> Text -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Inlines
    B.code     (Text -> F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Text
    verbatimBetween '~'

    subscript   :: PandocMonad m => OrgParser m (F Inlines)
    subscript :: OrgParser m (F Inlines)
    subscript   = (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Inlines -> Inlines
    B.subscript   (F Inlines -> F Inlines)
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (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 (F Inlines) -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    subOrSuperExpr)

    superscript :: PandocMonad m => OrgParser m (F Inlines)
    superscript :: OrgParser m (F Inlines)
    superscript = (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Inlines -> Inlines
    B.superscript (F Inlines -> F Inlines)
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (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 (F Inlines) -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    subOrSuperExpr)

    math      :: PandocMonad m => OrgParser m (F Inlines)
    math :: OrgParser m (F Inlines)
    math      = Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines) -> (Text -> Inlines) -> Text -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Inlines
    B.math      (Text -> F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice [ Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Text
    math1CharBetween '$'
                                                , Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Text
    mathTextBetween '$'
                                                , Text
    -> Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *).
    PandocMonad m =>
    Text -> Text -> OrgParser m Text
    rawMathBetween "\\(" "\\)"
                                                ]

    displayMath :: PandocMonad m => OrgParser m (F Inlines)
    displayMath :: OrgParser m (F Inlines)
    displayMath = Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines) -> (Text -> Inlines) -> Text -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Inlines
    B.displayMath (Text -> F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice [ Text
    -> Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *).
    PandocMonad m =>
    Text -> Text -> OrgParser m Text
    rawMathBetween "\\[" "\\]"
                                                    , Text
    -> Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *).
    PandocMonad m =>
    Text -> Text -> OrgParser m Text
    rawMathBetween "$$"  "$$"
                                                    ]

    updatePositions :: PandocMonad m
                    => Char
                    -> OrgParser m Char
    updatePositions :: Char -> OrgParser m Char
    updatePositions c :: Char
    c = do
      OrgParserState
    st <- ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      let emphasisPreChars :: [Char]
    emphasisPreChars = OrgParserState -> [Char]
    orgStateEmphasisPreChars OrgParserState
    st
      Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    when (Char
    c Char -> [Char] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [Char]
    emphasisPreChars) ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    updateLastPreCharPos
      Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    when (Char
    c Char -> [Char] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [Char]
    emphasisForbiddenBorderChars) ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    updateLastForbiddenCharPos
      Char -> OrgParser m Char
    forall (m :: * -> *) a. Monad m => a -> m a
    return Char
    c

    symbol :: PandocMonad m => OrgParser m (F Inlines)
    symbol :: OrgParser m (F Inlines)
    symbol = Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines) -> (Char -> Inlines) -> Char -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Inlines
    B.str (Text -> Inlines) -> (Char -> Text) -> Char -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Char -> Text
    T.singleton (Char -> F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ([Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf [Char]
    specialChars ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> (Char
        -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    updatePositions)

    emphasisBetween :: PandocMonad m
                    => Char
                    -> OrgParser m (F Inlines)
    emphasisBetween :: Char -> OrgParser m (F Inlines)
    emphasisBetween c :: Char
    c = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Int -> OrgParser m ()
    forall (m :: * -> *). PandocMonad m => Int -> OrgParser m ()
    startEmphasisNewlinesCounting Int
    emphasisAllowedNewlines
      F Inlines
    res <- OrgParser m Char -> OrgParser m Char -> OrgParser m (F Inlines)
    forall (m :: * -> *) b a.
    (PandocMonad m, Show b) =>
    OrgParser m a -> OrgParser m b -> OrgParser m (F Inlines)
    enclosedInlines (Char -> OrgParser m Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    emphasisStart Char
    c) (Char -> OrgParser m Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    emphasisEnd Char
    c)
      Bool
    isTopLevelEmphasis <- [Char] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null ([Char] -> Bool)
    -> (OrgParserState -> [Char]) -> OrgParserState -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OrgParserState -> [Char]
    orgStateEmphasisCharStack (OrgParserState -> Bool)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      Bool -> OrgParser m () -> OrgParser m ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    when Bool
    isTopLevelEmphasis
           OrgParser m ()
    forall (m :: * -> *). PandocMonad m => OrgParser m ()
    resetEmphasisNewlines
      F Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Inlines
    res

    verbatimBetween :: PandocMonad m
                    => Char
                    -> OrgParser m Text
    verbatimBetween :: Char -> OrgParser m Text
    verbatimBetween c :: Char
    c = 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 -> OrgParser m Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    emphasisStart Char
    c OrgParser m Char -> OrgParser m Text -> OrgParser m Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *>
      Int -> OrgParser m Char -> OrgParser m Char -> OrgParser m Text
    forall (m :: * -> *) a.
    PandocMonad m =>
    Int -> OrgParser m Char -> OrgParser m a -> OrgParser m Text
    many1TillNOrLessNewlines 1 OrgParser m Char
    verbatimChar (Char -> OrgParser m Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    emphasisEnd Char
    c)
     where
       verbatimChar :: OrgParser m Char
    verbatimChar = [Char] -> OrgParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf "\n\r" OrgParser m Char -> (Char -> OrgParser m Char) -> OrgParser m Char
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Char -> OrgParser m Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    updatePositions

    -- | Parses a raw string delimited by @c@ using Org's math rules
    mathTextBetween :: PandocMonad m
                      => Char
                      -> OrgParser m Text
    mathTextBetween :: Char -> OrgParser m Text
    mathTextBetween c :: Char
    c = 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
    $ do
      Char -> OrgParser m Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    mathStart Char
    c
      Text
    body <- Int -> OrgParser m Char -> OrgParser m Char -> OrgParser m Text
    forall (m :: * -> *) a.
    PandocMonad m =>
    Int -> OrgParser m Char -> OrgParser m a -> OrgParser m Text
    many1TillNOrLessNewlines Int
    mathAllowedNewlines
                                       ([Char] -> OrgParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf (Char
    cChar -> [Char] -> [Char]
    forall a. a -> [a] -> [a]
    :"\n\r"))
                                       (OrgParser m Char -> OrgParser m Char
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead (OrgParser m Char -> OrgParser m Char)
    -> OrgParser m Char -> OrgParser m Char
    forall a b. (a -> b) -> a -> b
    $ Char -> OrgParser m Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    mathEnd Char
    c)
      Char
    final <- Char -> OrgParser m Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    mathEnd Char
    c
      Text -> OrgParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> OrgParser m Text) -> Text -> OrgParser m Text
    forall a b. (a -> b) -> a -> b
    $ Text -> Char -> Text
    T.snoc Text
    body Char
    final

    -- | Parse a single character between @c@ using math rules
    math1CharBetween :: PandocMonad m
                     => Char
                    -> OrgParser m Text
    math1CharBetween :: Char -> OrgParser m Text
    math1CharBetween c :: Char
    c = 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
    $ do
      Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c
      Char
    res <- [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf ([Char]
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char)
    -> [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall a b. (a -> b) -> a -> b
    $ Char
    cChar -> [Char] -> [Char]
    forall a. a -> [a] -> [a]
    :[Char]
    mathForbiddenBorderChars
      Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c
      ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) t u.
    (Stream s m t, Show t) =>
    ParsecT s u m ()
    eof ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    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
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ 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 ([Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf [Char]
    mathPostChars)
      Text -> OrgParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> OrgParser m Text) -> Text -> OrgParser m Text
    forall a b. (a -> b) -> a -> b
    $ Char -> Text
    T.singleton Char
    res

    rawMathBetween :: PandocMonad m
                   => Text
                   -> Text
                   -> OrgParser m Text
    rawMathBetween :: Text -> Text -> OrgParser m Text
    rawMathBetween s :: Text
    s e :: Text
    e = 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
    $ Text -> OrgParser m Text
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Text -> ParsecT s u m Text
    textStr Text
    s OrgParser m Text -> OrgParser m Text -> OrgParser m Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m Text -> 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 ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    anyChar (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
    $ Text -> OrgParser m Text
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Text -> ParsecT s u m Text
    textStr Text
    e)

    -- | Parses the start (opening character) of emphasis
    emphasisStart :: PandocMonad m => Char -> OrgParser m Char
    emphasisStart :: Char -> OrgParser m Char
    emphasisStart c :: Char
    c = OrgParser m Char -> OrgParser m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Char -> OrgParser m Char)
    -> OrgParser m Char -> OrgParser m Char
    forall a b. (a -> b) -> a -> b
    $ do
      Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (m :: * -> *). PandocMonad m => OrgParser m Bool
    afterEmphasisPreChar
      Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall s (m :: * -> *) a st.
    (Stream s m a, HasLastStrPosition st) =>
    ParserT s st m Bool
    notAfterString
      Char -> OrgParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c
      OrgParser m Char -> OrgParser m Char
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead ([Char] -> OrgParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf [Char]
    emphasisForbiddenBorderChars)
      Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m ()
    pushToInlineCharStack Char
    c
      -- nested inlines are allowed, so mark this position as one which might be
      -- followed by another inline.
      ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    updateLastPreCharPos
      Char -> OrgParser m Char
    forall (m :: * -> *) a. Monad m => a -> m a
    return Char
    c

    -- | Parses the closing character of emphasis
    emphasisEnd :: PandocMonad m => Char -> OrgParser m Char
    emphasisEnd :: Char -> OrgParser m Char
    emphasisEnd c :: Char
    c = OrgParser m Char -> OrgParser m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Char -> OrgParser m Char)
    -> OrgParser m Char -> OrgParser m Char
    forall a b. (a -> b) -> a -> b
    $ do
      Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (m :: * -> *). PandocMonad m => OrgParser m Bool
    notAfterForbiddenBorderChar
      Char -> OrgParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c
      ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) t u.
    (Stream s m t, Show t) =>
    ParsecT s u m ()
    eof ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> () ()
    -> OrgParser m Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ OrgParser m Char -> OrgParser m Char
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead OrgParser m Char
    acceptablePostChars
      ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasLastStrPosition st) =>
    ParserT s st m ()
    updateLastStrPos
      ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). PandocMonad m => OrgParser m ()
    popInlineCharStack
      Char -> OrgParser m Char
    forall (m :: * -> *) a. Monad m => a -> m a
    return Char
    c
     where
      acceptablePostChars :: OrgParser m Char
    acceptablePostChars = do
        [Char]
    emphasisPostChars <- OrgParserState -> [Char]
    orgStateEmphasisPostChars (OrgParserState -> [Char])
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
        ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall (m :: * -> *). PandocMonad m => OrgParser m [Char]
    surroundingEmphasisChar ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ([Char] -> OrgParser m Char) -> OrgParser m Char
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \x :: [Char]
    x -> [Char] -> OrgParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf ([Char]
    x [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    emphasisPostChars)

    mathStart :: PandocMonad m => Char -> OrgParser m Char
    mathStart :: Char -> OrgParser m Char
    mathStart c :: Char
    c = OrgParser m Char -> OrgParser m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Char -> OrgParser m Char)
    -> OrgParser m Char -> OrgParser m Char
    forall a b. (a -> b) -> a -> b
    $
      Char -> OrgParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c OrgParser m Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m Char
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* OrgParser m Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' ([Char] -> OrgParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf (Char
    cChar -> [Char] -> [Char]
    forall a. a -> [a] -> [a]
    :[Char]
    mathForbiddenBorderChars))

    mathEnd :: PandocMonad m => Char -> OrgParser m Char
    mathEnd :: Char -> OrgParser m Char
    mathEnd c :: Char
    c = OrgParser m Char -> OrgParser m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Char -> OrgParser m Char)
    -> OrgParser m Char -> OrgParser m Char
    forall a b. (a -> b) -> a -> b
    $ do
      Char
    res <- [Char] -> OrgParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf (Char
    cChar -> [Char] -> [Char]
    forall a. a -> [a] -> [a]
    :[Char]
    mathForbiddenBorderChars)
      Char -> OrgParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c
      ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) t u.
    (Stream s m t, Show t) =>
    ParsecT s u m ()
    eof ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> () ()
    -> OrgParser m Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ OrgParser m Char -> OrgParser m Char
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead ([Char] -> OrgParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf [Char]
    mathPostChars)
      Char -> OrgParser m Char
    forall (m :: * -> *) a. Monad m => a -> m a
    return Char
    res

    enclosedInlines :: (PandocMonad m, Show b) => OrgParser m a
                    -> OrgParser m b
                    -> OrgParser m (F Inlines)
    enclosedInlines :: OrgParser m a -> OrgParser m b -> OrgParser m (F Inlines)
    enclosedInlines start :: OrgParser m a
    start end :: OrgParser m b
    end = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $
      F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> F Inlines)
    -> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> OrgParser m a
    -> OrgParser m b
    -> OrgParser m (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall end s (m :: * -> *) st t a.
    (Show end, Stream s m Char) =>
    ParserT s st m t
    -> ParserT s st m end -> ParserT s st m a -> ParserT s st m [a]
    enclosed OrgParser m a
    start OrgParser m b
    end OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inline

    enclosedRaw :: (PandocMonad m, Show b) => OrgParser m a
                -> OrgParser m b
                -> OrgParser m Text
    enclosedRaw :: OrgParser m a -> OrgParser m b -> OrgParser m Text
    enclosedRaw start :: OrgParser m a
    start end :: OrgParser m b
    end = 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
    $
      OrgParser m a
    start OrgParser m a -> OrgParser m Text -> OrgParser m Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> (OrgParser m Text
    onSingleLine OrgParser m Text -> OrgParser m Text -> OrgParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> OrgParser m Text
    spanningTwoLines)
     where onSingleLine :: OrgParser m Text
    onSingleLine = 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
    $ ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m b -> OrgParser m Text
    forall end s (m :: * -> *) t st.
    (Show end, Stream s m t) =>
    ParserT s st m Char -> ParserT s st m end -> ParserT s st m Text
    many1TillChar ([Char]
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf "\n\r") OrgParser m b
    end
           spanningTwoLines :: OrgParser m Text
    spanningTwoLines = 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
    $
             OrgParser m Text
    forall (m :: * -> *). Monad m => OrgParser m Text
    anyLine OrgParser m Text -> (Text -> OrgParser m Text) -> OrgParser m Text
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= \f :: Text
    f -> Text -> Text -> Text
    forall a. Monoid a => a -> a -> a
    mappend (Text
    f Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> " ") (Text -> Text) -> OrgParser m Text -> OrgParser m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> OrgParser m Text
    onSingleLine

    -- | Like many1Till, but parses at most @n+1@ lines.  @p@ must not consume
    --   newlines.
    many1TillNOrLessNewlines :: PandocMonad m => Int
                             -> OrgParser m Char
                             -> OrgParser m a
                             -> OrgParser m Text
    many1TillNOrLessNewlines :: Int -> OrgParser m Char -> OrgParser m a -> OrgParser m Text
    many1TillNOrLessNewlines n :: Int
    n p :: OrgParser m Char
    p end :: OrgParser m a
    end = 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
    $
      Maybe Int
    -> [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall a.
    (Eq a, Num a) =>
    Maybe a
    -> [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    nMoreLines (Int -> Maybe Int
    forall a. a -> Maybe a
    Just Int
    n) [Char]
    forall a. Monoid a => a
    mempty ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ([Char] -> OrgParser m Text) -> OrgParser m Text
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= [Char] -> OrgParser m Text
    forall (f :: * -> *). Alternative f => [Char] -> f Text
    oneOrMore
     where
       nMoreLines :: Maybe a
    -> [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    nMoreLines Nothing  cs :: [Char]
    cs = [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall (m :: * -> *) a. Monad m => a -> m a
    return [Char]
    cs
       nMoreLines (Just 0) cs :: [Char]
    cs = 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
    try (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall a b. (a -> b) -> a -> b
    $ ([Char]
    cs [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++) ([Char] -> [Char])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    finalLine
       nMoreLines k :: Maybe a
    k        cs :: [Char]
    cs = 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
    try (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall a b. (a -> b) -> a -> b
    $ (Maybe a
    -> [Char]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe a, [Char])
    forall p a.
    p
    -> [Char]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe a, [Char])
    final Maybe a
    k [Char]
    cs ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) (Maybe a, [Char])
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe a, [Char])
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe a, [Char])
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Maybe a
    -> [Char]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe a, [Char])
    forall b (f :: * -> *).
    (Num b, Functor f) =>
    f b
    -> [Char]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (f b, [Char])
    rest Maybe a
    k [Char]
    cs)
                                      ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) (Maybe a, [Char])
    -> ((Maybe a, [Char])
        -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= (Maybe a
     -> [Char]
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char])
    -> (Maybe a, [Char])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall a b c. (a -> b -> c) -> (a, b) -> c
    uncurry Maybe a
    -> [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    nMoreLines
       final :: p
    -> [Char]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe a, [Char])
    final _ cs :: [Char]
    cs = (\x :: [Char]
    x -> (Maybe a
    forall a. Maybe a
    Nothing,      [Char]
    cs [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    x)) ([Char] -> (Maybe a, [Char]))
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe a, [Char])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> 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
    try ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    finalLine
       rest :: f b
    -> [Char]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (f b, [Char])
    rest  m :: f b
    m cs :: [Char]
    cs = (\x :: [Char]
    x -> (b -> b
    forall a. Num a => a -> a
    minus1 (b -> b) -> f b -> f b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> f b
    m, [Char]
    cs [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    x [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ "\n")) ([Char] -> (f b, [Char]))
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (f b, [Char])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> 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
    try (OrgParser m Char
    -> OrgParser m Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    manyTill OrgParser m Char
    p OrgParser m Char
    forall (m :: * -> *). Monad m => OrgParser m Char
    newline)
       finalLine :: ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    finalLine = 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
    try (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall a b. (a -> b) -> a -> b
    $ OrgParser m Char
    -> OrgParser m a
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    manyTill OrgParser m Char
    p OrgParser m a
    end
       minus1 :: a -> a
    minus1 k :: a
    k = a
    k a -> a -> a
    forall a. Num a => a -> a -> a
    - 1
       oneOrMore :: [Char] -> f Text
    oneOrMore cs :: [Char]
    cs = [Char] -> Text
    T.pack [Char]
    cs Text -> f () -> f Text
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Bool -> f ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> Bool
    not (Bool -> Bool) -> Bool -> Bool
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [Char]
    cs)

    -- Org allows customization of the way it reads emphasis.  We use the defaults
    -- here (see, e.g., the Emacs Lisp variable `org-emphasis-regexp-components`
    -- for details).

    -- | Chars not allowed at the (inner) border of emphasis
    emphasisForbiddenBorderChars :: [Char]
    emphasisForbiddenBorderChars :: [Char]
    emphasisForbiddenBorderChars = "\t\n\r "

    -- | The maximum number of newlines within
    emphasisAllowedNewlines :: Int
    emphasisAllowedNewlines :: Int
    emphasisAllowedNewlines = 1

    -- LaTeX-style math: see `org-latex-regexps` for details

    -- | Chars allowed after an inline ($...$) math statement
    mathPostChars :: [Char]
    mathPostChars :: [Char]
    mathPostChars = "\t\n \"'),-.:;?"

    -- | Chars not allowed at the (inner) border of math
    mathForbiddenBorderChars :: [Char]
    mathForbiddenBorderChars :: [Char]
    mathForbiddenBorderChars = "\t\n\r ,;.$"

    -- | Maximum number of newlines in an inline math statement
    mathAllowedNewlines :: Int
    mathAllowedNewlines :: Int
    mathAllowedNewlines = 2

    -- | Whether we are right behind a char allowed before emphasis
    afterEmphasisPreChar :: PandocMonad m => OrgParser m Bool
    afterEmphasisPreChar :: OrgParser m Bool
    afterEmphasisPreChar = do
      SourcePos
    pos <- ParsecT Text OrgParserState (ReaderT OrgParserLocal m) SourcePos
    forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
    getPosition
      Maybe SourcePos
    lastPrePos <- OrgParserState -> Maybe SourcePos
    orgStateLastPreCharPos (OrgParserState -> Maybe SourcePos)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe SourcePos)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      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
    $ Bool -> (SourcePos -> Bool) -> Maybe SourcePos -> Bool
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe Bool
    True (SourcePos -> SourcePos -> Bool
    forall a. Eq a => a -> a -> Bool
    == SourcePos
    pos) Maybe SourcePos
    lastPrePos

    -- | Whether the parser is right after a forbidden border char
    notAfterForbiddenBorderChar :: PandocMonad m => OrgParser m Bool
    notAfterForbiddenBorderChar :: OrgParser m Bool
    notAfterForbiddenBorderChar = do
      SourcePos
    pos <- ParsecT Text OrgParserState (ReaderT OrgParserLocal m) SourcePos
    forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
    getPosition
      Maybe SourcePos
    lastFBCPos <- OrgParserState -> Maybe SourcePos
    orgStateLastForbiddenCharPos (OrgParserState -> Maybe SourcePos)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe SourcePos)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      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
    $ Maybe SourcePos
    lastFBCPos Maybe SourcePos -> Maybe SourcePos -> Bool
    forall a. Eq a => a -> a -> Bool
    /= SourcePos -> Maybe SourcePos
    forall a. a -> Maybe a
    Just SourcePos
    pos

    -- | Read a sub- or superscript expression
    subOrSuperExpr :: PandocMonad m => OrgParser m (F Inlines)
    subOrSuperExpr :: OrgParser m (F Inlines)
    subOrSuperExpr = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $
      OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    simpleSubOrSuperText OrgParser m (F Inlines)
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    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) Text]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice [ Char
    -> Char
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) st.
    Stream s m Char =>
    Char -> Char -> ParserT s st m Char -> ParserT s st m Text
    charsInBalanced '{' '}' ([Char]
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf "\n\r")
              , (Char, Char) -> Text -> Text
    enclosing ('(', ')') (Text -> Text)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Char
    -> Char
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) st.
    Stream s m Char =>
    Char -> Char -> ParserT s st m Char -> ParserT s st m Text
    charsInBalanced '(' ')' ([Char]
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf "\n\r")
              ] ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> (Text -> OrgParser m (F Inlines)) -> OrgParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= OrgParser m (F Inlines) -> Text -> OrgParser m (F Inlines)
    forall (m :: * -> *) a.
    Monad m =>
    OrgParser m a -> Text -> OrgParser m a
    parseFromString ([F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> OrgParser m (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inline))
     where enclosing :: (Char, Char) -> Text -> Text
    enclosing (left :: Char
    left, right :: Char
    right) s :: Text
    s = Char -> Text -> Text
    T.cons Char
    left (Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $ Text -> Char -> Text
    T.snoc Text
    s Char
    right

    simpleSubOrSuperText :: PandocMonad m => OrgParser m (F Inlines)
    simpleSubOrSuperText :: OrgParser m (F Inlines)
    simpleSubOrSuperText = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      OrgParserState
    state <- ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> (OrgParserState -> Bool)
    -> OrgParserState
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ExportSettings -> Bool
    exportSubSuperscripts (ExportSettings -> Bool)
    -> (OrgParserState -> ExportSettings) -> OrgParserState -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OrgParserState -> ExportSettings
    orgStateExportSettings (OrgParserState
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> OrgParserState
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall a b. (a -> b) -> a -> b
    $ OrgParserState
    state
      Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines) -> (Text -> Inlines) -> Text -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Inlines
    B.str (Text -> F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
        [ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice [ Text -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Text -> ParsecT s u m Text
    textStr "*"
               , Text -> Text -> Text
    forall a. Monoid a => a -> a -> a
    mappend (Text -> Text -> Text)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Text -> Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option "" (Char -> Text
    T.singleton (Char -> Text)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf "+-")
                         ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) (Text -> Text)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT 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 ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    alphaNum
               ]

    inlineLaTeX :: PandocMonad m => OrgParser m (F Inlines)
    inlineLaTeX :: OrgParser m (F Inlines)
    inlineLaTeX = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    cmd <- OrgParser m Text
    forall (m :: * -> *). PandocMonad m => OrgParser m Text
    inlineLaTeXCommand
      Maybe Inlines
    ils <- (ReaderT OrgParserLocal m (Maybe Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe Inlines)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (ReaderT OrgParserLocal m (Maybe Inlines)
     -> ParsecT
          Text OrgParserState (ReaderT OrgParserLocal m) (Maybe Inlines))
    -> (m (Maybe Inlines) -> ReaderT OrgParserLocal m (Maybe Inlines))
    -> m (Maybe Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe Inlines)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . m (Maybe Inlines) -> ReaderT OrgParserLocal m (Maybe Inlines)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift) (m (Maybe Inlines)
     -> ParsecT
          Text OrgParserState (ReaderT OrgParserLocal m) (Maybe Inlines))
    -> m (Maybe Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Maybe Inlines)
    forall a b. (a -> b) -> a -> b
    $ Text -> m (Maybe Inlines)
    forall (m :: * -> *). PandocMonad m => Text -> m (Maybe Inlines)
    parseAsInlineLaTeX Text
    cmd
      OrgParser m (F Inlines)
    -> (Inlines -> OrgParser m (F Inlines))
    -> Maybe Inlines
    -> OrgParser m (F Inlines)
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe OrgParser m (F Inlines)
    forall (m :: * -> *) a. MonadPlus m => m a
    mzero Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a s. Monad m => a -> m (Future s a)
    returnF (Maybe Inlines -> OrgParser m (F Inlines))
    -> Maybe Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $
         Text -> Maybe Inlines
    parseAsMathMLSym Text
    cmd Maybe Inlines -> Maybe Inlines -> Maybe Inlines
    forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
    `mplus` Text -> Maybe Inlines
    parseAsMath Text
    cmd Maybe Inlines -> Maybe Inlines -> Maybe Inlines
    forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
    `mplus` Maybe Inlines
    ils
     where
       parseAsMath :: Text -> Maybe Inlines
       parseAsMath :: Text -> Maybe Inlines
    parseAsMath cs :: Text
    cs = [Inline] -> Inlines
    forall a. [a] -> Many a
    B.fromList ([Inline] -> Inlines) -> Maybe [Inline] -> Maybe Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Text -> Maybe [Inline]
    texMathToPandoc Text
    cs

       parseAsInlineLaTeX :: PandocMonad m => Text -> m (Maybe Inlines)
       parseAsInlineLaTeX :: Text -> m (Maybe Inlines)
    parseAsInlineLaTeX cs :: Text
    cs = Either ParseError Inlines -> Maybe Inlines
    forall a b. Either a b -> Maybe b
    maybeRight (Either ParseError Inlines -> Maybe Inlines)
    -> m (Either ParseError Inlines) -> m (Maybe Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Inlines
    -> ParserState -> [Char] -> Text -> m (Either ParseError Inlines)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> u -> [Char] -> s -> m (Either ParseError a)
    runParserT ParsecT Text ParserState m Inlines
    forall (m :: * -> *).
    PandocMonad m =>
    ParserT Text ParserState m Inlines
    inlineCommand ParserState
    state "" Text
    cs

       parseAsMathMLSym :: Text -> Maybe Inlines
       parseAsMathMLSym :: Text -> Maybe Inlines
    parseAsMathMLSym cs :: Text
    cs = Text -> Inlines
    B.str (Text -> Inlines) -> Maybe Text -> Maybe Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Text -> Maybe Text
    MathMLEntityMap.getUnicode (Text -> Text
    clean Text
    cs)
        -- drop initial backslash and any trailing "{}"
        where clean :: Text -> Text
    clean = (Char -> Bool) -> Text -> Text
    T.dropWhileEnd (Char -> [Char] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` ("{}" :: String)) (Text -> Text) -> (Text -> Text) -> Text -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> Text -> Text
    T.drop 1

       state :: ParserState
       state :: ParserState
    state = ParserState
    forall a. Default a => a
    def{ stateOptions :: ReaderOptions
    stateOptions = ReaderOptions
    forall a. Default a => a
    def{ readerExtensions :: Extensions
    readerExtensions =
                        Extension -> Extensions -> Extensions
    enableExtension Extension
    Ext_raw_tex (ReaderOptions -> Extensions
    readerExtensions ReaderOptions
    forall a. Default a => a
    def) } }

       texMathToPandoc :: Text -> Maybe [Inline]
       texMathToPandoc :: Text -> Maybe [Inline]
    texMathToPandoc cs :: Text
    cs = Either Text [Exp] -> Maybe [Exp]
    forall a b. Either a b -> Maybe b
    maybeRight (Text -> Either Text [Exp]
    readTeX Text
    cs) Maybe [Exp] -> ([Exp] -> Maybe [Inline]) -> Maybe [Inline]
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= DisplayType -> [Exp] -> Maybe [Inline]
    writePandoc DisplayType
    DisplayInline

    maybeRight :: Either a b -> Maybe b
    maybeRight :: Either a b -> Maybe b
    maybeRight = (a -> Maybe b) -> (b -> Maybe b) -> Either a b -> Maybe b
    forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
    either (Maybe b -> a -> Maybe b
    forall a b. a -> b -> a
    const Maybe b
    forall a. Maybe a
    Nothing) b -> Maybe b
    forall a. a -> Maybe a
    Just

    inlineLaTeXCommand :: PandocMonad m => OrgParser m Text
    inlineLaTeXCommand :: OrgParser m Text
    inlineLaTeXCommand = 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
    $ do
      Text
    rest <- OrgParser m Text
    forall (m :: * -> *) s u. Monad m => ParsecT s u m s
    getInput
      OrgParserState
    st <- ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      Either ParseError Text
    parsed <- (ReaderT OrgParserLocal m (Either ParseError Text)
    -> ParsecT
         Text
         OrgParserState
         (ReaderT OrgParserLocal m)
         (Either ParseError Text)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (ReaderT OrgParserLocal m (Either ParseError Text)
     -> ParsecT
          Text
          OrgParserState
          (ReaderT OrgParserLocal m)
          (Either ParseError Text))
    -> (m (Either ParseError Text)
        -> ReaderT OrgParserLocal m (Either ParseError Text))
    -> m (Either ParseError Text)
    -> ParsecT
         Text
         OrgParserState
         (ReaderT OrgParserLocal m)
         (Either ParseError Text)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . m (Either ParseError Text)
    -> ReaderT OrgParserLocal m (Either ParseError Text)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift) (m (Either ParseError Text)
     -> ParsecT
          Text
          OrgParserState
          (ReaderT OrgParserLocal m)
          (Either ParseError Text))
    -> m (Either ParseError Text)
    -> ParsecT
         Text
         OrgParserState
         (ReaderT OrgParserLocal m)
         (Either ParseError Text)
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text OrgParserState m Text
    -> OrgParserState -> [Char] -> Text -> m (Either ParseError Text)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> u -> [Char] -> s -> m (Either ParseError a)
    runParserT ParsecT Text OrgParserState m Text
    forall (m :: * -> *) s.
    (PandocMonad m, HasMacros s, HasReaderOptions s) =>
    ParserT Text s m Text
    rawLaTeXInline OrgParserState
    st "source" Text
    rest
      case Either ParseError Text
    parsed of
        Right cs :: Text
    cs -> do
          -- drop any trailing whitespace, those are not be part of the command as
          -- far as org mode is concerned.
          let cmdNoSpc :: Text
    cmdNoSpc = (Char -> Bool) -> Text -> Text
    T.dropWhileEnd Char -> Bool
    isSpace Text
    cs
          let len :: Int
    len = Text -> Int
    T.length Text
    cmdNoSpc
          Int
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    Int -> ParsecT s u m a -> ParsecT s u m [a]
    count Int
    len ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    anyChar
          Text -> OrgParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return Text
    cmdNoSpc
        _ -> OrgParser m Text
    forall (m :: * -> *) a. MonadPlus m => m a
    mzero

    exportSnippet :: PandocMonad m => OrgParser m (F Inlines)
    exportSnippet :: OrgParser m (F Inlines)
    exportSnippet = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "@@"
      Text
    format <- ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall end s (m :: * -> *) t st.
    (Show end, Stream s m t) =>
    ParserT s st m Char -> ParserT s st m end -> ParserT s st m Text
    many1TillChar (ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    alphaNum ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParserT 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
    <|> Char -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '-') (Char -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':')
      Text
    snippet <- ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal 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 ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    anyChar (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
    try (ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char])
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    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]
    string "@@")
      Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a s. Monad m => a -> m (Future s a)
    returnF (Inlines -> OrgParser m (F Inlines))
    -> Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Text -> Text -> Inlines
    B.rawInline Text
    format Text
    snippet

    macro :: PandocMonad m => OrgParser m (F Inlines)
    macro :: OrgParser m (F Inlines)
    macro = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Int
    recursionDepth <- OrgParserState -> Int
    orgStateMacroDepth (OrgParserState -> Int)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> Bool
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall a b. (a -> b) -> a -> b
    $ Int
    recursionDepth Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < 15
      [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "{{{"
      Text
    name <- 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
    manyChar ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    alphaNum
      [Text]
    args <- ([] [Text]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Text]
    forall (f :: * -> *) a b. Functor 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]
    string "}}}")
              ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Text]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Text]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Text]
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Char -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '(' ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Text]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Text]
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall st. ParserT Text st (ReaderT OrgParserLocal m) Text
    argument ParserT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Text]
    forall s (m :: * -> *) t u a end.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
    `sepBy` Char -> ParserT 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) [Text]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Text]
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text OrgParserState (ReaderT OrgParserLocal m) [Char]
    forall u. ParsecT Text u (ReaderT OrgParserLocal m) [Char]
    eoa
      Maybe MacroExpander
    expander <- Text -> OrgParserState -> Maybe MacroExpander
    lookupMacro Text
    name (OrgParserState -> Maybe MacroExpander)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    -> ParsecT
         Text
         OrgParserState
         (ReaderT OrgParserLocal m)
         (Maybe MacroExpander)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) OrgParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      case Maybe MacroExpander
    expander of
        Nothing -> OrgParser m (F Inlines)
    forall (m :: * -> *) a. MonadPlus m => m a
    mzero
        Just fn :: MacroExpander
    fn -> do
          (OrgParserState -> OrgParserState)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((OrgParserState -> OrgParserState)
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> (OrgParserState -> OrgParserState)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall a b. (a -> b) -> a -> b
    $ \s :: OrgParserState
    s -> OrgParserState
    s { orgStateMacroDepth :: Int
    orgStateMacroDepth = Int
    recursionDepth Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + 1 }
          F Inlines
    res <- OrgParser m (F Inlines) -> Text -> OrgParser m (F Inlines)
    forall (m :: * -> *) a.
    Monad m =>
    OrgParser m a -> Text -> OrgParser m a
    parseFromString ([F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> OrgParser m (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inline) (Text -> OrgParser m (F Inlines))
    -> Text -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ MacroExpander
    fn [Text]
    args
          (OrgParserState -> OrgParserState)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((OrgParserState -> OrgParserState)
     -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ())
    -> (OrgParserState -> OrgParserState)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall a b. (a -> b) -> a -> b
    $ \s :: OrgParserState
    s -> OrgParserState
    s { orgStateMacroDepth :: Int
    orgStateMacroDepth = Int
    recursionDepth }
          F Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Inlines
    res
     where
      argument :: ParserT Text st (ReaderT OrgParserLocal m) Text
    argument = ParserT Text st (ReaderT OrgParserLocal m) Char
    -> ParserT Text st (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    manyChar (ParserT Text st (ReaderT OrgParserLocal m) Char
     -> ParserT Text st (ReaderT OrgParserLocal m) Text)
    -> ParserT Text st (ReaderT OrgParserLocal m) Char
    -> ParserT Text st (ReaderT OrgParserLocal m) Text
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text st (ReaderT OrgParserLocal m) [Char]
    -> ParsecT Text st (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy ParsecT Text st (ReaderT OrgParserLocal m) [Char]
    forall u. ParsecT Text u (ReaderT OrgParserLocal m) [Char]
    eoa ParsecT Text st (ReaderT OrgParserLocal m) ()
    -> ParserT Text st (ReaderT OrgParserLocal m) Char
    -> ParserT Text st (ReaderT OrgParserLocal m) Char
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> [Char] -> ParserT Text st (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf ","
      eoa :: ParsecT Text u (ReaderT OrgParserLocal m) [Char]
    eoa = [Char] -> ParsecT Text u (ReaderT OrgParserLocal m) [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string ")}}}"

    smart :: PandocMonad m => OrgParser m (F Inlines)
    smart :: OrgParser m (F Inlines)
    smart = [OrgParser m (F Inlines)] -> OrgParser m (F Inlines)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice [OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    doubleQuoted, OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    singleQuoted, OrgParser m (F Inlines)
    forall s.
    ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) (Future s Inlines)
    orgApostrophe, OrgParser m (F Inlines)
    orgDash, OrgParser m (F Inlines)
    orgEllipses]
      where
        orgDash :: OrgParser m (F Inlines)
    orgDash = do
          Bool -> OrgParser m ()
    forall (m :: * -> *). PandocMonad m => Bool -> OrgParser m ()
    guardOrSmartEnabled (Bool -> OrgParser m ())
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    -> OrgParser m ()
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< (ExportSettings -> Bool)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (m :: * -> *) a.
    Monad m =>
    (ExportSettings -> a) -> OrgParser m a
    getExportSetting ExportSettings -> Bool
    exportSpecialStrings
          Inlines -> F Inlines
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (Inlines -> F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Inlines
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Inlines
    forall st s (m :: * -> *).
    (HasReaderOptions st, Stream s m Char) =>
    ParserT s st m Inlines
    dash OrgParser m (F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    updatePositions '-'
        orgEllipses :: OrgParser m (F Inlines)
    orgEllipses = do
          Bool -> OrgParser m ()
    forall (m :: * -> *). PandocMonad m => Bool -> OrgParser m ()
    guardOrSmartEnabled (Bool -> OrgParser m ())
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    -> OrgParser m ()
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< (ExportSettings -> Bool)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (m :: * -> *) a.
    Monad m =>
    (ExportSettings -> a) -> OrgParser m a
    getExportSetting ExportSettings -> Bool
    exportSpecialStrings
          Inlines -> F Inlines
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (Inlines -> F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Inlines
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Inlines
    forall s (m :: * -> *) st.
    Stream s m Char =>
    ParserT s st m Inlines
    ellipses OrgParser m (F Inlines)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    updatePositions '.'
        orgApostrophe :: ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) (Future s Inlines)
    orgApostrophe = do
          Extension -> OrgParser m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_smart
          (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
    -> 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
    <|> Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '\8217') ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* OrgParser m ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    updateLastPreCharPos
                                       ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* OrgParser m ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    updateLastForbiddenCharPos
          Inlines
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Future s Inlines)
    forall (m :: * -> *) a s. Monad m => a -> m (Future s a)
    returnF (Text -> Inlines
    B.str "\x2019")

    guardOrSmartEnabled :: PandocMonad m => Bool -> OrgParser m ()
    guardOrSmartEnabled :: Bool -> OrgParser m ()
    guardOrSmartEnabled b :: Bool
    b = do
      Bool
    smartExtension <- Extension -> Extensions -> Bool
    extensionEnabled Extension
    Ext_smart (Extensions -> Bool)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) Extensions
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (ReaderOptions -> Extensions)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) Extensions
    forall st s (m :: * -> *) t b.
    (HasReaderOptions st, Stream s m t) =>
    (ReaderOptions -> b) -> ParserT s st m b
    getOption ReaderOptions -> Extensions
    readerExtensions
      Bool -> OrgParser m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool
    b Bool -> Bool -> Bool
    || Bool
    smartExtension)

    singleQuoted :: PandocMonad m => OrgParser m (F Inlines)
    singleQuoted :: OrgParser m (F Inlines)
    singleQuoted = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Bool -> OrgParser m ()
    forall (m :: * -> *). PandocMonad m => Bool -> OrgParser m ()
    guardOrSmartEnabled (Bool -> OrgParser m ())
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    -> OrgParser m ()
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< (ExportSettings -> Bool)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (m :: * -> *) a.
    Monad m =>
    (ExportSettings -> a) -> OrgParser m a
    getExportSetting ExportSettings -> Bool
    exportSmartQuotes
      OrgParser m ()
    forall st (m :: * -> *) s.
    (HasLastStrPosition st, HasQuoteContext st m, Stream s m Char) =>
    ParserT s st m ()
    singleQuoteStart
      Char -> OrgParser m Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    updatePositions '\''
      QuoteContext -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall st (m :: * -> *) s a.
    HasQuoteContext st m =>
    QuoteContext -> ParsecT s st m a -> ParsecT s st m a
    withQuoteContext QuoteContext
    InSingleQuote (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $
        (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Inlines -> Inlines
    B.singleQuoted (F Inlines -> F Inlines)
    -> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> F Inlines)
    -> ([F Inlines] -> F Inlines) -> [F Inlines] -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
          OrgParser m (F Inlines)
    -> OrgParser m ()
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall end s (m :: * -> *) t st a.
    (Show end, Stream s m t) =>
    ParserT s st m a -> ParserT s st m end -> ParserT s st m [a]
    many1Till OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inline (OrgParser m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    singleQuoteEnd OrgParser m () -> OrgParser m Char -> OrgParser m ()
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Char -> OrgParser m Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    updatePositions '\'')

    -- doubleQuoted will handle regular double-quoted sections, as well
    -- as dialogues with an open double-quote without a close double-quote
    -- in the same paragraph.
    doubleQuoted :: PandocMonad m => OrgParser m (F Inlines)
    doubleQuoted :: OrgParser m (F Inlines)
    doubleQuoted = OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Bool -> OrgParser m ()
    forall (m :: * -> *). PandocMonad m => Bool -> OrgParser m ()
    guardOrSmartEnabled (Bool -> OrgParser m ())
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    -> OrgParser m ()
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< (ExportSettings -> Bool)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Bool
    forall (m :: * -> *) a.
    Monad m =>
    (ExportSettings -> a) -> OrgParser m a
    getExportSetting ExportSettings -> Bool
    exportSmartQuotes
      OrgParser m ()
    forall st (m :: * -> *) s.
    (HasQuoteContext st m, Stream s m Char) =>
    ParserT s st m ()
    doubleQuoteStart
      Char -> OrgParser m Char
    forall (m :: * -> *). PandocMonad m => Char -> OrgParser m Char
    updatePositions '"'
      F Inlines
    contents <- [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    -> OrgParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> OrgParser m (F Inlines)
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ OrgParser m () -> OrgParser m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy OrgParser m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    doubleQuoteEnd OrgParser m ()
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> OrgParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => OrgParser m (F Inlines)
    inline)
      let doubleQuotedContent :: OrgParser m (F Inlines)
    doubleQuotedContent = QuoteContext -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall st (m :: * -> *) s a.
    HasQuoteContext st m =>
    QuoteContext -> ParsecT s st m a -> ParsecT s st m a
    withQuoteContext QuoteContext
    InDoubleQuote (OrgParser m (F Inlines) -> OrgParser m (F Inlines))
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
            OrgParser m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    doubleQuoteEnd
            OrgParser m ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    updateLastForbiddenCharPos
            F Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> OrgParser m (F Inlines))
    -> (F Inlines -> F Inlines) -> F Inlines -> OrgParser m (F Inlines)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Inlines -> Inlines
    B.doubleQuoted (F Inlines -> F Inlines)
    -> (F Inlines -> F Inlines) -> F Inlines -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> OrgParser m (F Inlines))
    -> F Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ F Inlines
    contents
      let leftQuoteAndContent :: OrgParser m (F Inlines)
    leftQuoteAndContent = F Inlines -> OrgParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> OrgParser m (F Inlines))
    -> F Inlines -> OrgParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Inlines -> F Inlines
    forall (f :: * -> *) a. Applicative f => a -> f a
    pure (Text -> Inlines
    B.str "\8220") F Inlines -> F Inlines -> F Inlines
    forall a. Semigroup a => a -> a -> a
    <> F Inlines
    contents
      OrgParser m (F Inlines)
    doubleQuotedContent OrgParser m (F Inlines)
    -> OrgParser m (F Inlines) -> OrgParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> OrgParser m (F Inlines)
    leftQuoteAndContent