    {-# LANGUAGE RelaxedPolyRec      #-}
    {-# LANGUAGE ScopedTypeVariables #-}
    {-# LANGUAGE TupleSections       #-}
    {-# LANGUAGE OverloadedStrings   #-}
    {-# LANGUAGE ViewPatterns        #-}
    {- |
       Module      : Text.Pandoc.Readers.Markdown
       Copyright   : Copyright (C) 2006-2020 John MacFarlane
       License     : GNU GPL, version 2 or above

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

    Conversion of markdown-formatted plain text to 'Pandoc' document.
    -}
    module Text.Pandoc.Readers.Markdown ( readMarkdown, yamlToMeta ) where

    import Control.Monad
    import Control.Monad.Except (throwError)
    import Data.Char (isAlphaNum, isPunctuation, isSpace)
    import Data.List (transpose, elemIndex, sortOn)
    import qualified Data.Map as M
    import Data.Maybe
    import qualified Data.Set as Set
    import Data.Text (Text)
    import qualified Data.Text as T
    import qualified Data.Text.Lazy as TL
    import qualified Data.ByteString.Lazy as BL
    import System.FilePath (addExtension, takeExtension)
    import Text.HTML.TagSoup
    import Text.Pandoc.Builder (Blocks, Inlines)
    import qualified Text.Pandoc.Builder as B
    import Text.Pandoc.Class.PandocMonad (PandocMonad (..), report)
    import Text.Pandoc.Definition
    import Text.Pandoc.Emoji (emojiToInline)
    import Text.Pandoc.Error
    import Text.Pandoc.Logging
    import Text.Pandoc.Options
    import Text.Pandoc.Parsing hiding (tableWith)
    import Text.Pandoc.Readers.HTML (htmlInBalanced, htmlTag, isBlockTag,
                                     isCommentTag, isInlineTag, isTextTag)
    import Text.Pandoc.Readers.LaTeX (applyMacros, rawLaTeXBlock, rawLaTeXInline)
    import Text.Pandoc.Shared
    import qualified Text.Pandoc.UTF8 as UTF8
    import Text.Pandoc.XML (fromEntities)
    import Text.Pandoc.Readers.Metadata (yamlBsToMeta)

    type MarkdownParser m = ParserT Text ParserState m

    -- | Read markdown from an input string and return a Pandoc document.
    readMarkdown :: PandocMonad m
                 => ReaderOptions -- ^ Reader options
                 -> Text      -- ^ String to parse (assuming @'\n'@ line endings)
                 -> m Pandoc
    readMarkdown :: ReaderOptions -> Text -> m Pandoc
    readMarkdown opts :: ReaderOptions
    opts s :: Text
    s = do
      Either PandocError Pandoc
    parsed <- ParserT Text ParserState m Pandoc
    -> ParserState -> Text -> m (Either PandocError Pandoc)
    forall s (m :: * -> *) st a.
    (Stream s m Char, ToText s) =>
    ParserT s st m a -> st -> s -> m (Either PandocError a)
    readWithM ParserT Text ParserState m Pandoc
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Pandoc
    parseMarkdown ParserState
    forall a. Default a => a
    def{ stateOptions :: ReaderOptions
    stateOptions = ReaderOptions
    opts }
                   (Text -> Text
    crFilter Text
    s Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> "\n\n")
      case Either PandocError Pandoc
    parsed of
        Right result :: Pandoc
    result -> Pandoc -> m Pandoc
    forall (m :: * -> *) a. Monad m => a -> m a
    return Pandoc
    result
        Left e :: PandocError
    e       -> PandocError -> m Pandoc
    forall e (m :: * -> *) a. MonadError e m => e -> m a
    throwError PandocError
    e

    -- | Read a YAML string and convert it to pandoc metadata.
    -- String scalars in the YAML are parsed as Markdown.
    yamlToMeta :: PandocMonad m
               => ReaderOptions
               -> BL.ByteString
               -> m Meta
    yamlToMeta :: ReaderOptions -> ByteString -> m Meta
    yamlToMeta opts :: ReaderOptions
    opts bstr :: ByteString
    bstr = do
      let parser :: ParsecT Text ParserState m Meta
    parser = do
            F Meta
    meta <- ParserT Text ParserState m (F Blocks)
    -> ByteString -> ParserT Text ParserState m (F Meta)
    forall (m :: * -> *).
    PandocMonad m =>
    ParserT Text ParserState m (F Blocks)
    -> ByteString -> ParserT Text ParserState m (F Meta)
    yamlBsToMeta ParserT Text ParserState m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    parseBlocks ByteString
    bstr
            Meta -> ParsecT Text ParserState m Meta
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Meta -> ParsecT Text ParserState m Meta)
    -> Meta -> ParsecT Text ParserState m Meta
    forall a b. (a -> b) -> a -> b
    $ F Meta -> ParserState -> Meta
    forall s a. Future s a -> s -> a
    runF F Meta
    meta ParserState
    defaultParserState
      Either PandocError Meta
    parsed <- ParsecT Text ParserState m Meta
    -> ParserState -> Text -> m (Either PandocError Meta)
    forall s (m :: * -> *) st a.
    (Stream s m Char, ToText s) =>
    ParserT s st m a -> st -> s -> m (Either PandocError a)
    readWithM ParsecT Text ParserState m Meta
    parser ParserState
    forall a. Default a => a
    def{ stateOptions :: ReaderOptions
    stateOptions = ReaderOptions
    opts } ""
      case Either PandocError Meta
    parsed of
        Right result :: Meta
    result -> Meta -> m Meta
    forall (m :: * -> *) a. Monad m => a -> m a
    return Meta
    result
        Left e :: PandocError
    e       -> PandocError -> m Meta
    forall e (m :: * -> *) a. MonadError e m => e -> m a
    throwError PandocError
    e

    --
    -- Constants and data structure definitions
    --

    isBulletListMarker :: Char -> Bool
    isBulletListMarker :: Char -> Bool
    isBulletListMarker '*' = Bool
    True
    isBulletListMarker '+' = Bool
    True
    isBulletListMarker '-' = Bool
    True
    isBulletListMarker _   = Bool
    False

    isHruleChar :: Char -> Bool
    isHruleChar :: Char -> Bool
    isHruleChar '*' = Bool
    True
    isHruleChar '-' = Bool
    True
    isHruleChar '_' = Bool
    True
    isHruleChar _   = Bool
    False

    setextHChars :: [Char]
    setextHChars :: [Char]
    setextHChars = "=-"

    isBlank :: Char -> Bool
    isBlank :: Char -> Bool
    isBlank ' '  = Bool
    True
    isBlank '\t' = Bool
    True
    isBlank '\n' = Bool
    True
    isBlank _    = Bool
    False

    --
    -- auxiliary functions
    --

    -- | Succeeds when we're in list context.
    inList :: PandocMonad m => MarkdownParser m ()
    inList :: MarkdownParser m ()
    inList = do
      ParserContext
    ctx <- ParserState -> ParserContext
    stateParserContext (ParserState -> ParserContext)
    -> ParsecT Text ParserState m ParserState
    -> ParsecT Text ParserState m ParserContext
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      Bool -> MarkdownParser m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (ParserContext
    ctx ParserContext -> ParserContext -> Bool
    forall a. Eq a => a -> a -> Bool
    == ParserContext
    ListItemState)

    spnl :: PandocMonad m => ParserT Text st m ()
    spnl :: ParserT Text st m ()
    spnl = ParserT Text st m () -> ParserT Text st m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParserT Text st m () -> ParserT Text st m ())
    -> ParserT Text st m () -> ParserT Text st m ()
    forall a b. (a -> b) -> a -> b
    $ do
      ParserT Text st m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      ParsecT Text st m Char -> ParserT Text st m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParsecT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
      ParserT Text st m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      ParsecT Text st m Char -> ParserT Text st 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 st m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '\n')

    spnl' :: PandocMonad m => ParserT Text st m Text
    spnl' :: ParserT Text st m Text
    spnl' = ParserT Text st m Text -> ParserT Text st m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParserT Text st m Text -> ParserT Text st m Text)
    -> ParserT Text st m Text -> ParserT Text st m Text
    forall a b. (a -> b) -> a -> b
    $ do
      [Char]
    xs <- ParsecT Text st m Char -> ParsecT Text st m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many ParsecT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
      [Char]
    ys <- [Char] -> ParsecT Text st m [Char] -> ParsecT Text st m [Char]
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option "" (ParsecT Text st m [Char] -> ParsecT Text st m [Char])
    -> ParsecT Text st m [Char] -> ParsecT Text st m [Char]
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text st m [Char] -> ParsecT Text st m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text st m [Char] -> ParsecT Text st m [Char])
    -> ParsecT Text st m [Char] -> ParsecT Text st m [Char]
    forall a b. (a -> b) -> a -> b
    $ (:) (Char -> [Char] -> [Char])
    -> ParsecT Text st m Char -> ParsecT Text st m ([Char] -> [Char])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
                                  ParsecT Text st m ([Char] -> [Char])
    -> ParsecT Text st m [Char] -> ParsecT Text st m [Char]
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> (ParsecT Text st m Char -> ParsecT Text st m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many ParsecT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar ParsecT Text st m [Char]
    -> ParsecT Text st m () -> ParsecT Text st m [Char]
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text st m Char -> ParsecT Text st 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 st m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '\n'))
      Text -> ParserT Text st m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> ParserT Text st m Text) -> Text -> ParserT Text st m Text
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Text
    T.pack ([Char] -> Text) -> [Char] -> Text
    forall a b. (a -> b) -> a -> b
    $ [Char]
    xs [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    ys

    indentSpaces :: PandocMonad m => MarkdownParser m Text
    indentSpaces :: MarkdownParser m Text
    indentSpaces = MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
      Int
    tabStop <- (ReaderOptions -> Int) -> ParserT Text ParserState m Int
    forall st s (m :: * -> *) t b.
    (HasReaderOptions st, Stream s m t) =>
    (ReaderOptions -> b) -> ParserT s st m b
    getOption ReaderOptions -> Int
    readerTabStop
      Int -> ParsecT Text ParserState m Char -> MarkdownParser m Text
    forall s (m :: * -> *) st.
    (Stream s m Char, Monad m) =>
    Int -> ParsecT s st m Char -> ParsecT s st m Text
    countChar Int
    tabStop (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ' ') MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
        Text -> MarkdownParser m Text
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Text -> ParsecT s u m Text
    textStr "\t" MarkdownParser m Text -> [Char] -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> "indentation"

    nonindentSpaces :: PandocMonad m => MarkdownParser m Text
    nonindentSpaces :: MarkdownParser m Text
    nonindentSpaces = do
      Int
    n <- MarkdownParser m Int
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
    skipNonindentSpaces
      Text -> MarkdownParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> MarkdownParser m Text) -> Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ Int -> Text -> Text
    T.replicate Int
    n " "

    -- returns number of spaces parsed
    skipNonindentSpaces :: PandocMonad m => MarkdownParser m Int
    skipNonindentSpaces :: MarkdownParser m Int
    skipNonindentSpaces = do
      Int
    tabStop <- (ReaderOptions -> Int) -> MarkdownParser m Int
    forall st s (m :: * -> *) t b.
    (HasReaderOptions st, Stream s m t) =>
    (ReaderOptions -> b) -> ParserT s st m b
    getOption ReaderOptions -> Int
    readerTabStop
      Int -> MarkdownParser m Int
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m Int
    gobbleAtMostSpaces (Int
    tabStop Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - 1) MarkdownParser m Int
    -> ParsecT Text ParserState m () -> MarkdownParser m Int
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar

    litChar :: PandocMonad m => MarkdownParser m Char
    litChar :: MarkdownParser m Char
    litChar = MarkdownParser m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    escapedChar'
           MarkdownParser m Char
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    characterReference
           MarkdownParser m Char
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> [Char] -> MarkdownParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf "\n"
           MarkdownParser m Char
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline MarkdownParser m Char
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Char -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy MarkdownParser m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline ParsecT Text ParserState m ()
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Char -> MarkdownParser m Char
    forall (m :: * -> *) a. Monad m => a -> m a
    return ' ')

    -- | Parse a sequence of inline elements between square brackets,
    -- including inlines between balanced pairs of square brackets.
    inlinesInBalancedBrackets :: PandocMonad m => MarkdownParser m (F Inlines)
    inlinesInBalancedBrackets :: MarkdownParser m (F Inlines)
    inlinesInBalancedBrackets =
      MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '[' ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m ((), Text)
    -> ParsecT Text ParserState m ((), Text)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m ((), Text)
    forall (m :: * -> *) st a.
    Monad m =>
    ParsecT Text st m a -> ParsecT Text st m (a, Text)
    withRaw (Int -> ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m ()
    go 1) ParsecT Text ParserState m ((), Text)
    -> (((), Text) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>=
              MarkdownParser m (F Inlines)
    -> Text -> MarkdownParser m (F Inlines)
    forall s (m :: * -> *) st r.
    (Stream s m Char, IsString s) =>
    ParserT s st m r -> Text -> ParserT s st m r
    parseFromString MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlines (Text -> MarkdownParser m (F Inlines))
    -> (((), Text) -> Text)
    -> ((), Text)
    -> MarkdownParser m (F Inlines)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text
    stripBracket (Text -> Text) -> (((), Text) -> Text) -> ((), Text) -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ((), Text) -> Text
    forall a b. (a, b) -> b
    snd
      where stripBracket :: Text -> Text
    stripBracket t :: Text
    t = case Text -> Maybe (Text, Char)
    T.unsnoc Text
    t of
              Just (t' :: Text
    t', ']') -> Text
    t'
              _              -> Text
    t
            go :: PandocMonad m => Int -> MarkdownParser m ()
            go :: Int -> MarkdownParser m ()
    go 0 = () -> MarkdownParser m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
            go openBrackets :: Int
    openBrackets =
              (() () -> ParsecT Text ParserState m (F Inlines) -> MarkdownParser m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ (ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    escapedChar ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState 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 ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    code ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState 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 ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    rawHtmlInline ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState 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 ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    rawLaTeXInline') MarkdownParser m () -> MarkdownParser m () -> MarkdownParser m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Int -> MarkdownParser m ()
    forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m ()
    go Int
    openBrackets)
              MarkdownParser m () -> MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
              (do Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ']'
                  Bool -> MarkdownParser m () -> MarkdownParser m ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    Control.Monad.when (Int
    openBrackets Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > 1) (MarkdownParser m () -> MarkdownParser m ())
    -> MarkdownParser m () -> MarkdownParser m ()
    forall a b. (a -> b) -> a -> b
    $ Int -> MarkdownParser m ()
    forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m ()
    go (Int
    openBrackets Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - 1))
              MarkdownParser m () -> MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
              (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '[' ParsecT Text ParserState m Char
    -> MarkdownParser m () -> MarkdownParser m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Int -> MarkdownParser m ()
    forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m ()
    go (Int
    openBrackets Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + 1))
              MarkdownParser m () -> MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
              (ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    anyChar ParsecT Text ParserState m Char
    -> MarkdownParser m () -> MarkdownParser m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Int -> MarkdownParser m ()
    forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m ()
    go Int
    openBrackets)

    --
    -- document structure
    --

    rawTitleBlockLine :: PandocMonad m => MarkdownParser m Text
    rawTitleBlockLine :: MarkdownParser m Text
    rawTitleBlockLine = do
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '%'
      ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      Text
    first <- MarkdownParser m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine
      [Text]
    rest <- MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (MarkdownParser m Text -> ParsecT Text ParserState m [Text])
    -> MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
                              ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
                              ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
                              MarkdownParser m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine
      Text -> MarkdownParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> MarkdownParser m Text) -> Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    trim (Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $ [Text] -> Text
    T.unlines (Text
    firstText -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    :[Text]
    rest)

    titleLine :: PandocMonad m => MarkdownParser m (F Inlines)
    titleLine :: MarkdownParser m (F Inlines)
    titleLine = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    raw <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    rawTitleBlockLine
      F Inlines
    res <- MarkdownParser m (F Inlines)
    -> Text -> MarkdownParser m (F Inlines)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlines Text
    raw
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser 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
    res

    authorsLine :: PandocMonad m => MarkdownParser m (F [Inlines])
    authorsLine :: MarkdownParser m (F [Inlines])
    authorsLine = MarkdownParser m (F [Inlines]) -> MarkdownParser m (F [Inlines])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F [Inlines]) -> MarkdownParser m (F [Inlines]))
    -> MarkdownParser m (F [Inlines]) -> MarkdownParser m (F [Inlines])
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    raw <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    rawTitleBlockLine
      let sep :: ParsecT Text u m Char
    sep = (Char -> ParsecT Text u m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ';' ParsecT Text u m Char
    -> ParsecT Text u m () -> ParsecT Text u m Char
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text u m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    spaces) ParsecT Text u m Char
    -> ParsecT Text u m Char -> ParsecT Text u m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text u m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
      let pAuthors :: ParsecT Text ParserState m [F Inlines]
    pAuthors = ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [F Inlines]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    sepEndBy
                (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 ParserState m [F Inlines]
    -> ParsecT Text ParserState m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many
                     (ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text ParserState m (F Inlines)
     -> ParsecT Text ParserState m (F Inlines))
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall u. ParsecT Text u m Char
    sep ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline))
                ParsecT Text ParserState m Char
    forall u. ParsecT Text u m Char
    sep
      [F Inlines] -> F [Inlines]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence ([F Inlines] -> F [Inlines])
    -> ParsecT Text ParserState m [F Inlines]
    -> MarkdownParser m (F [Inlines])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m [F Inlines]
    -> Text -> ParsecT Text ParserState m [F Inlines]
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' ParsecT Text ParserState m [F Inlines]
    pAuthors Text
    raw

    dateLine :: PandocMonad m => MarkdownParser m (F Inlines)
    dateLine :: MarkdownParser m (F Inlines)
    dateLine = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    raw <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    rawTitleBlockLine
      F Inlines
    res <- MarkdownParser m (F Inlines)
    -> Text -> MarkdownParser m (F Inlines)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlines Text
    raw
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser 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
    res

    titleBlock :: PandocMonad m => MarkdownParser m ()
    titleBlock :: MarkdownParser m ()
    titleBlock = MarkdownParser m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    pandocTitleBlock MarkdownParser m () -> MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    mmdTitleBlock

    pandocTitleBlock :: PandocMonad m => MarkdownParser m ()
    pandocTitleBlock :: MarkdownParser m ()
    pandocTitleBlock = MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m () -> MarkdownParser m ())
    -> MarkdownParser m () -> MarkdownParser m ()
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> MarkdownParser m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_pandoc_title_block
      ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '%')
      F Inlines
    title <- F Inlines
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option F Inlines
    forall a. Monoid a => a
    mempty ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    titleLine
      F [Inlines]
    author <- F [Inlines]
    -> ParsecT Text ParserState m (F [Inlines])
    -> ParsecT Text ParserState m (F [Inlines])
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option ([Inlines] -> F [Inlines]
    forall (m :: * -> *) a. Monad m => a -> m a
    return []) ParsecT Text ParserState m (F [Inlines])
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F [Inlines])
    authorsLine
      F Inlines
    date <- F Inlines
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option F Inlines
    forall a. Monoid a => a
    mempty ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    dateLine
      ParsecT Text ParserState m Text -> MarkdownParser m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParsecT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      let meta' :: F Meta
    meta' = do Inlines
    title' <- F Inlines
    title
                     [Inlines]
    author' <- F [Inlines]
    author
                     Inlines
    date' <- F Inlines
    date
                     Meta -> F Meta
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Meta -> F Meta) -> Meta -> F Meta
    forall a b. (a -> b) -> a -> b
    $
                         (if Inlines -> Bool
    forall a. Many a -> Bool
    B.isNull Inlines
    title' then Meta -> Meta
    forall a. a -> a
    id else Text -> Inlines -> Meta -> Meta
    forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
    B.setMeta "title" Inlines
    title')
                       (Meta -> Meta) -> (Meta -> Meta) -> Meta -> Meta
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (if [Inlines] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [Inlines]
    author' then Meta -> Meta
    forall a. a -> a
    id else Text -> [Inlines] -> Meta -> Meta
    forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
    B.setMeta "author" [Inlines]
    author')
                       (Meta -> Meta) -> (Meta -> Meta) -> Meta -> Meta
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (if Inlines -> Bool
    forall a. Many a -> Bool
    B.isNull Inlines
    date' then Meta -> Meta
    forall a. a -> a
    id else Text -> Inlines -> Meta -> Meta
    forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
    B.setMeta "date" Inlines
    date')
                       (Meta -> Meta) -> Meta -> Meta
    forall a b. (a -> b) -> a -> b
    $ Meta
    nullMeta
      (ParserState -> ParserState) -> MarkdownParser m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> MarkdownParser m ())
    -> (ParserState -> ParserState) -> MarkdownParser m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateMeta' :: F Meta
    stateMeta' = ParserState -> F Meta
    stateMeta' ParserState
    st F Meta -> F Meta -> F Meta
    forall a. Semigroup a => a -> a -> a
    <> F Meta
    meta' }

    yamlMetaBlock :: PandocMonad m => MarkdownParser m (F Blocks)
    yamlMetaBlock :: MarkdownParser m (F Blocks)
    yamlMetaBlock = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_yaml_metadata_block
      [Char] -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "---"
      ParserT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
      ParserT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy ParserT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline  -- if --- is followed by a blank it's an HRULE
      [Text]
    rawYamlLines <- ParsecT Text ParserState m Text
    -> ParserT Text ParserState m ()
    -> ParsecT Text ParserState m [Text]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    manyTill ParsecT Text ParserState m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine ParserT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    stopLine
      -- by including --- and ..., we allow yaml blocks with just comments:
      let rawYaml :: Text
    rawYaml = [Text] -> Text
    T.unlines ("---" Text -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    : ([Text]
    rawYamlLines [Text] -> [Text] -> [Text]
    forall a. [a] -> [a] -> [a]
    ++ ["..."]))
      ParsecT Text ParserState m Text -> ParserT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParsecT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      F Meta
    newMetaF <- MarkdownParser m (F Blocks)
    -> ByteString -> ParserT Text ParserState m (F Meta)
    forall (m :: * -> *).
    PandocMonad m =>
    ParserT Text ParserState m (F Blocks)
    -> ByteString -> ParserT Text ParserState m (F Meta)
    yamlBsToMeta MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    parseBlocks
                  (ByteString -> ParserT Text ParserState m (F Meta))
    -> ByteString -> ParserT Text ParserState m (F Meta)
    forall a b. (a -> b) -> a -> b
    $ Text -> ByteString
    UTF8.fromTextLazy (Text -> ByteString) -> Text -> ByteString
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    TL.fromStrict Text
    rawYaml
      -- Since `<>` is left-biased, existing values are not touched:
      (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParserT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateMeta' :: F Meta
    stateMeta' = ParserState -> F Meta
    stateMeta' ParserState
    st F Meta -> F Meta -> F Meta
    forall a. Semigroup a => a -> a -> a
    <> F Meta
    newMetaF }
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Blocks
    forall a. Monoid a => a
    mempty

    stopLine :: PandocMonad m => MarkdownParser m ()
    stopLine :: MarkdownParser m ()
    stopLine = MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m () -> MarkdownParser m ())
    -> MarkdownParser m () -> MarkdownParser m ()
    forall a b. (a -> b) -> a -> b
    $ ([Char] -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "---" ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState 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 ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "...") ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline ParsecT Text ParserState m Char
    -> MarkdownParser m () -> MarkdownParser m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> () -> MarkdownParser m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    mmdTitleBlock :: PandocMonad m => MarkdownParser m ()
    mmdTitleBlock :: MarkdownParser m ()
    mmdTitleBlock = MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m () -> MarkdownParser m ())
    -> MarkdownParser m () -> MarkdownParser m ()
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> MarkdownParser m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_mmd_title_block
      (Text, MetaValue)
    firstPair <- Bool -> MarkdownParser m (Text, MetaValue)
    forall (m :: * -> *).
    PandocMonad m =>
    Bool -> MarkdownParser m (Text, MetaValue)
    kvPair Bool
    False
      [(Text, MetaValue)]
    restPairs <- MarkdownParser m (Text, MetaValue)
    -> ParsecT Text ParserState m [(Text, MetaValue)]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (Bool -> MarkdownParser m (Text, MetaValue)
    forall (m :: * -> *).
    PandocMonad m =>
    Bool -> MarkdownParser m (Text, MetaValue)
    kvPair Bool
    True)
      let kvPairs :: [(Text, MetaValue)]
    kvPairs = (Text, MetaValue)
    firstPair (Text, MetaValue) -> [(Text, MetaValue)] -> [(Text, MetaValue)]
    forall a. a -> [a] -> [a]
    : [(Text, MetaValue)]
    restPairs
      ParserT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      (ParserState -> ParserState) -> MarkdownParser m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> MarkdownParser m ())
    -> (ParserState -> ParserState) -> MarkdownParser m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateMeta' :: F Meta
    stateMeta' = ParserState -> F Meta
    stateMeta' ParserState
    st F Meta -> F Meta -> F Meta
    forall a. Semigroup a => a -> a -> a
    <>
                                 Meta -> F Meta
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Map Text MetaValue -> Meta
    Meta (Map Text MetaValue -> Meta) -> Map Text MetaValue -> Meta
    forall a b. (a -> b) -> a -> b
    $ [(Text, MetaValue)] -> Map Text MetaValue
    forall k a. Ord k => [(k, a)] -> Map k a
    M.fromList [(Text, MetaValue)]
    kvPairs) }

    kvPair :: PandocMonad m => Bool -> MarkdownParser m (Text, MetaValue)
    kvPair :: Bool -> MarkdownParser m (Text, MetaValue)
    kvPair allowEmpty :: Bool
    allowEmpty = MarkdownParser m (Text, MetaValue)
    -> MarkdownParser m (Text, MetaValue)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (Text, MetaValue)
     -> MarkdownParser m (Text, MetaValue))
    -> MarkdownParser m (Text, MetaValue)
    -> MarkdownParser m (Text, MetaValue)
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    key <- ParserT Text ParserState m Char
    -> ParserT Text ParserState m Char
    -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    alphaNum ParserT Text ParserState m Char
    -> ParserT Text ParserState m Char
    -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf "_- ") (Char -> ParserT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':')
      Text
    val <- Text -> Text
    trim (Text -> Text)
    -> ParserT Text ParserState m Text
    -> ParserT Text ParserState m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParserT Text ParserState m Char
    -> ParserT Text ParserState m Char
    -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    anyChar
              (ParserT Text ParserState m Char -> ParserT Text ParserState m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParserT Text ParserState m Char
     -> ParserT Text ParserState m Char)
    -> ParserT Text ParserState m Char
    -> ParserT Text ParserState m Char
    forall a b. (a -> b) -> a -> b
    $ ParserT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline ParserT Text ParserState m Char
    -> ParserT Text ParserState m Char
    -> ParserT Text ParserState m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParserT Text ParserState m Char -> ParserT Text ParserState m Char
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead (ParserT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline ParserT Text ParserState m Char
    -> ParserT Text ParserState m Char
    -> ParserT Text ParserState m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParserT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    nonspaceChar))
      Bool -> ParsecT Text ParserState m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParsecT Text ParserState m ())
    -> Bool -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ Bool
    allowEmpty Bool -> Bool -> Bool
    || Bool -> Bool
    not (Text -> Bool
    T.null Text
    val)
      let key' :: Text
    key' = [Text] -> Text
    T.concat ([Text] -> Text) -> [Text] -> Text
    forall a b. (a -> b) -> a -> b
    $ Text -> [Text]
    T.words (Text -> [Text]) -> Text -> [Text]
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    T.toLower Text
    key
      let val' :: MetaValue
    val' = [Block] -> MetaValue
    MetaBlocks ([Block] -> MetaValue) -> [Block] -> MetaValue
    forall a b. (a -> b) -> a -> b
    $ Blocks -> [Block]
    forall a. Many a -> [a]
    B.toList (Blocks -> [Block]) -> Blocks -> [Block]
    forall a b. (a -> b) -> a -> b
    $ Inlines -> Blocks
    B.plain (Inlines -> Blocks) -> Inlines -> Blocks
    forall a b. (a -> b) -> a -> b
    $ Text -> Inlines
    B.text Text
    val
      (Text, MetaValue) -> MarkdownParser m (Text, MetaValue)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text
    key',MetaValue
    val')

    parseMarkdown :: PandocMonad m => MarkdownParser m Pandoc
    parseMarkdown :: MarkdownParser m Pandoc
    parseMarkdown = do
      ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    titleBlock
      F Blocks
    blocks <- MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    parseBlocks
      ParserState
    st <- ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      -- check for notes with no corresponding note references
      let notesUsed :: Set Text
    notesUsed = ParserState -> Set Text
    stateNoteRefs ParserState
    st
      let notesDefined :: [Text]
    notesDefined = Map Text (SourcePos, F Blocks) -> [Text]
    forall k a. Map k a -> [k]
    M.keys (ParserState -> Map Text (SourcePos, F Blocks)
    stateNotes' ParserState
    st)
      (Text -> ParsecT Text ParserState m ())
    -> [Text] -> ParsecT Text ParserState m ()
    forall (t :: * -> *) (m :: * -> *) a b.
    (Foldable t, Monad m) =>
    (a -> m b) -> t a -> m ()
    mapM_ (\n :: Text
    n -> Bool
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    unless (Text
    n Text -> Set Text -> Bool
    forall a. Ord a => a -> Set a -> Bool
    `Set.member` Set Text
    notesUsed) (ParsecT Text ParserState m () -> ParsecT Text ParserState m ())
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $
                    case Text
    -> Map Text (SourcePos, F Blocks) -> Maybe (SourcePos, F Blocks)
    forall k a. Ord k => k -> Map k a -> Maybe a
    M.lookup Text
    n (ParserState -> Map Text (SourcePos, F Blocks)
    stateNotes' ParserState
    st) of
                       Just (pos :: SourcePos
    pos, _) -> LogMessage -> ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
    report (Text -> SourcePos -> LogMessage
    NoteDefinedButNotUsed Text
    n SourcePos
    pos)
                       Nothing -> PandocError -> ParsecT Text ParserState m ()
    forall e (m :: * -> *) a. MonadError e m => e -> m a
    throwError (PandocError -> ParsecT Text ParserState m ())
    -> PandocError -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $
                         Text -> PandocError
    PandocShouldNeverHappenError "note not found")
             [Text]
    notesDefined
      let doc :: Pandoc
    doc = Future ParserState Pandoc -> ParserState -> Pandoc
    forall s a. Future s a -> s -> a
    runF (do Pandoc _ bs :: [Block]
    bs <- Blocks -> Pandoc
    B.doc (Blocks -> Pandoc) -> F Blocks -> Future ParserState Pandoc
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Blocks
    blocks
                         Meta
    meta <- ParserState -> F Meta
    stateMeta' ParserState
    st
                         Pandoc -> Future ParserState Pandoc
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Pandoc -> Future ParserState Pandoc)
    -> Pandoc -> Future ParserState Pandoc
    forall a b. (a -> b) -> a -> b
    $ Meta -> [Block] -> Pandoc
    Pandoc Meta
    meta [Block]
    bs) ParserState
    st
      ParsecT Text ParserState m ()
    forall (m :: * -> *) st s.
    (PandocMonad m, HasLogMessages st) =>
    ParserT s st m ()
    reportLogMessages
      Pandoc -> MarkdownParser m Pandoc
    forall (m :: * -> *) a. Monad m => a -> m a
    return Pandoc
    doc

    referenceKey :: PandocMonad m => MarkdownParser m (F Blocks)
    referenceKey :: MarkdownParser m (F Blocks)
    referenceKey = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      SourcePos
    pos <- ParsecT Text ParserState m SourcePos
    forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
    getPosition
      MarkdownParser m Int
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
    skipNonindentSpaces
      (_,raw :: Text
    raw) <- MarkdownParser m (F Inlines, Text)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F Inlines, Text)
    reference
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':'
      ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '[')
      let sourceURL :: ParsecT Text ParserState m Text
    sourceURL = ([Text] -> Text)
    -> ParsecT Text ParserState m [Text]
    -> ParsecT Text ParserState m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Text] -> Text
    T.unwords (ParsecT Text ParserState m [Text]
     -> ParsecT Text ParserState m Text)
    -> ParsecT Text ParserState m [Text]
    -> ParsecT Text ParserState m Text
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParsecT Text ParserState m Text
     -> ParsecT Text ParserState m [Text])
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m Text -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text ParserState m Text
     -> ParsecT Text ParserState m Text)
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall a b. (a -> b) -> a -> b
    $ do
                        ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
                        ParsecT Text ParserState m Text -> ParserT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' ParsecT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    referenceTitle
                        ParserT Text ParserState m Attr -> ParserT Text ParserState 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 ParserState m Attr -> ParserT Text ParserState m ())
    -> ParserT Text ParserState m Attr -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_link_attributes ParserT Text ParserState m ()
    -> ParserT Text ParserState m Attr
    -> ParserT Text ParserState m Attr
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParserT Text ParserState m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    attributes
                        ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' (() ()
    -> MarkdownParser m (F Inlines, Text)
    -> ParserT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ MarkdownParser m (F Inlines, Text)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F Inlines, Text)
    reference)
                        ParsecT Text ParserState m Char -> ParsecT Text ParserState m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char (ParsecT Text ParserState m Char
     -> ParsecT Text ParserState m Text)
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Text
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    space ParserT Text ParserState m ()
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    litChar
      let betweenAngles :: ParsecT Text ParserState m Text
    betweenAngles = ParsecT Text ParserState m Text -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text ParserState m Text
     -> ParsecT Text ParserState m Text)
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall a b. (a -> b) -> a -> b
    $ Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '<' ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Text
    forall s (m :: * -> *) t st a.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
    manyTillChar ParsecT Text ParserState m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    litChar (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '>')
      Text
    src <- ParsecT Text ParserState m Text -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT Text ParserState m Text
    betweenAngles ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m Text
    sourceURL
      Text
    tit <- Text
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m 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 ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    referenceTitle
      Attr
    attr   <- Attr
    -> ParserT Text ParserState m Attr
    -> ParserT Text ParserState m Attr
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option Attr
    nullAttr (ParserT Text ParserState m Attr
     -> ParserT Text ParserState m Attr)
    -> ParserT Text ParserState m Attr
    -> ParserT Text ParserState m Attr
    forall a b. (a -> b) -> a -> b
    $ ParserT Text ParserState m Attr -> ParserT Text ParserState m Attr
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParserT Text ParserState m Attr
     -> ParserT Text ParserState m Attr)
    -> ParserT Text ParserState m Attr
    -> ParserT Text ParserState m Attr
    forall a b. (a -> b) -> a -> b
    $
                  do Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_link_attributes
                     ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
                     ParserT Text ParserState m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    attributes
      [Attr -> Attr]
    addKvs <- [Attr -> Attr]
    -> ParsecT Text ParserState m [Attr -> Attr]
    -> ParsecT Text ParserState m [Attr -> Attr]
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option [] (ParsecT Text ParserState m [Attr -> Attr]
     -> ParsecT Text ParserState m [Attr -> Attr])
    -> ParsecT Text ParserState m [Attr -> Attr]
    -> ParsecT Text ParserState m [Attr -> Attr]
    forall a b. (a -> b) -> a -> b
    $ Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_mmd_link_attributes
                              ParserT Text ParserState m ()
    -> ParsecT Text ParserState m [Attr -> Attr]
    -> ParsecT Text ParserState m [Attr -> Attr]
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m (Attr -> Attr)
    -> ParsecT Text ParserState m [Attr -> Attr]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParsecT Text ParserState m (Attr -> Attr)
    -> ParsecT Text ParserState m (Attr -> Attr)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text ParserState m (Attr -> Attr)
     -> ParsecT Text ParserState m (Attr -> Attr))
    -> ParsecT Text ParserState m (Attr -> Attr)
    -> ParsecT Text ParserState m (Attr -> Attr)
    forall a b. (a -> b) -> a -> b
    $ ParserT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    spnl ParserT Text ParserState m ()
    -> ParsecT Text ParserState m (Attr -> Attr)
    -> ParsecT Text ParserState m (Attr -> Attr)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m (Attr -> Attr)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (Attr -> Attr)
    keyValAttr)
      ParsecT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      let attr' :: Attr
    attr'  = Attr -> Attr
    extractIdClass (Attr -> Attr) -> Attr -> Attr
    forall a b. (a -> b) -> a -> b
    $ (Attr -> (Attr -> Attr) -> Attr) -> Attr -> [Attr -> Attr] -> Attr
    forall (t :: * -> *) b a.
    Foldable t =>
    (b -> a -> b) -> b -> t a -> b
    foldl (\x :: Attr
    x f :: Attr -> Attr
    f -> Attr -> Attr
    f Attr
    x) Attr
    attr [Attr -> Attr]
    addKvs
          target :: (Text, Text)
    target = (Text -> Text
    escapeURI (Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    trimr Text
    src, Text
    tit)
      ParserState
    st <- ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      let oldkeys :: KeyTable
    oldkeys = ParserState -> KeyTable
    stateKeys ParserState
    st
      let key :: Key
    key = Text -> Key
    toKey Text
    raw
      case Key -> KeyTable -> Maybe ((Text, Text), Attr)
    forall k a. Ord k => k -> Map k a -> Maybe a
    M.lookup Key
    key KeyTable
    oldkeys of
        Just (t :: (Text, Text)
    t,a :: Attr
    a) | Bool -> Bool
    not ((Text, Text)
    t (Text, Text) -> (Text, Text) -> Bool
    forall a. Eq a => a -> a -> Bool
    == (Text, Text)
    target Bool -> Bool -> Bool
    && Attr
    a Attr -> Attr -> Bool
    forall a. Eq a => a -> a -> Bool
    == Attr
    attr') ->
          -- We don't warn on two duplicate keys if the targets are also
          -- the same. This can happen naturally with --reference-location=block
          -- or section. See #3701.
          LogMessage -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasLogMessages st) =>
    LogMessage -> ParserT s st m ()
    logMessage (LogMessage -> ParserT Text ParserState m ())
    -> LogMessage -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ Text -> SourcePos -> LogMessage
    DuplicateLinkReference Text
    raw SourcePos
    pos
        _ -> () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
      (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParserT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \s :: ParserState
    s -> ParserState
    s { stateKeys :: KeyTable
    stateKeys = Key -> ((Text, Text), Attr) -> KeyTable -> KeyTable
    forall k a. Ord k => k -> a -> Map k a -> Map k a
    M.insert Key
    key ((Text, Text)
    target, Attr
    attr') KeyTable
    oldkeys }
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    forall a. Monoid a => a
    mempty

    referenceTitle :: PandocMonad m => MarkdownParser m Text
    referenceTitle :: MarkdownParser m Text
    referenceTitle = MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
      ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      Char -> MarkdownParser m Text
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> MarkdownParser m Text
    quotedTitle '"' MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Char -> MarkdownParser m Text
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> MarkdownParser m Text
    quotedTitle '\'' MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Char
    -> Char -> ParsecT Text ParserState m Char -> MarkdownParser m Text
    forall s (m :: * -> *) st.
    Stream s m Char =>
    Char -> Char -> ParserT s st m Char -> ParserT s st m Text
    charsInBalanced '(' ')' ParsecT Text ParserState m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    litChar

    -- A link title in quotes
    quotedTitle :: PandocMonad m => Char -> MarkdownParser m Text
    quotedTitle :: Char -> MarkdownParser m Text
    quotedTitle c :: Char
    c = MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c
      ParsecT Text ParserState m () -> ParsecT Text ParserState 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 ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    spaces
      let pEnder :: ParsecT Text u m ()
    pEnder = ParsecT Text u m () -> ParsecT Text u m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text u m () -> ParsecT Text u m ())
    -> ParsecT Text u m () -> ParsecT Text u m ()
    forall a b. (a -> b) -> a -> b
    $ Char -> ParsecT Text u m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c ParsecT Text u m Char -> ParsecT Text u m () -> ParsecT Text u m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text u m Char -> ParsecT Text u m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy ((Char -> Bool) -> ParsecT Text u m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy Char -> Bool
    isAlphaNum)
      let regChunk :: MarkdownParser m Text
    regChunk = ParsecT Text ParserState m Char -> MarkdownParser 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf ['\\','\n','&',Char
    c]) MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Int -> ParsecT Text ParserState m Char -> MarkdownParser m Text
    forall s (m :: * -> *) st.
    (Stream s m Char, Monad m) =>
    Int -> ParsecT s st m Char -> ParsecT s st m Text
    countChar 1 ParsecT Text ParserState m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    litChar
      let nestedChunk :: MarkdownParser m Text
    nestedChunk = (\x :: Text
    x -> Char -> Text
    T.singleton Char
    c Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    x Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Char -> Text
    T.singleton Char
    c) (Text -> Text) -> MarkdownParser m Text -> MarkdownParser m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Char -> MarkdownParser m Text
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> MarkdownParser m Text
    quotedTitle Char
    c
      [Text] -> Text
    T.unwords ([Text] -> Text) -> ([Text] -> [Text]) -> [Text] -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> [Text]
    T.words (Text -> [Text]) -> ([Text] -> Text) -> [Text] -> [Text]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Text] -> Text
    T.concat ([Text] -> Text)
    -> ParsecT Text ParserState m [Text] -> MarkdownParser m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m Text
    -> ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m [Text]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    manyTill (MarkdownParser m Text
    nestedChunk MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m Text
    regChunk) ParsecT Text ParserState m ()
    forall u. ParsecT Text u m ()
    pEnder

    -- | PHP Markdown Extra style abbreviation key.  Currently
    -- we just skip them, since Pandoc doesn't have an element for
    -- an abbreviation.
    abbrevKey :: PandocMonad m => MarkdownParser m (F Blocks)
    abbrevKey :: MarkdownParser m (F Blocks)
    abbrevKey = do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_abbreviations
      MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
        Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '*'
        MarkdownParser m (F Inlines, Text)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F Inlines, Text)
    reference
        Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':'
        ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ((Char -> Bool) -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy (Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    /= '\n'))
        ParserT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
        F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    forall a. Monoid a => a
    mempty

    noteMarker :: PandocMonad m => MarkdownParser m Text
    noteMarker :: MarkdownParser m Text
    noteMarker = [Char] -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "[^" ParsecT Text ParserState m [Char]
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParserT Text ParserState m Char
    -> ParserT Text ParserState m Char -> MarkdownParser 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 -> Bool) -> ParserT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy ((Char -> Bool) -> ParserT Text ParserState m Char)
    -> (Char -> Bool) -> ParserT Text ParserState 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
    isBlank) (Char -> ParserT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ']')

    rawLine :: PandocMonad m => MarkdownParser m Text
    rawLine :: MarkdownParser m Text
    rawLine = MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
      ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
      MarkdownParser m Text -> ParsecT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' (MarkdownParser m Text -> ParsecT Text ParserState m ())
    -> MarkdownParser m Text -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Int
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
    skipNonindentSpaces MarkdownParser m Int
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    noteMarker
      MarkdownParser m Text -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    indentSpaces
      MarkdownParser m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine

    rawLines :: PandocMonad m => MarkdownParser m Text
    rawLines :: MarkdownParser m Text
    rawLines = do
      Text
    first <- MarkdownParser m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine
      [Text]
    rest <- MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    rawLine
      Text -> MarkdownParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> MarkdownParser m Text) -> Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ [Text] -> Text
    T.unlines (Text
    firstText -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    :[Text]
    rest)

    noteBlock :: PandocMonad m => MarkdownParser m (F Blocks)
    noteBlock :: MarkdownParser m (F Blocks)
    noteBlock = do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_footnotes
      MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
         SourcePos
    pos <- ParsecT Text ParserState m SourcePos
    forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
    getPosition
         MarkdownParser m Int
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
    skipNonindentSpaces
         Text
    ref <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    noteMarker
         Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':'
         ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
         MarkdownParser m Text -> ParserT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    indentSpaces
         Text
    first <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    rawLines
         [Text]
    rest <- MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (MarkdownParser m Text -> ParsecT Text ParserState m [Text])
    -> MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    indentSpaces MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    rawLines
         let raw :: Text
    raw = [Text] -> Text
    T.unlines (Text
    firstText -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    :[Text]
    rest) Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> "\n"
         MarkdownParser m Text -> ParserT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional MarkdownParser m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
         F Blocks
    parsed <- MarkdownParser m (F Blocks) -> Text -> MarkdownParser m (F Blocks)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    parseBlocks Text
    raw
         Map Text (SourcePos, F Blocks)
    oldnotes <- ParserState -> Map Text (SourcePos, F Blocks)
    stateNotes' (ParserState -> Map Text (SourcePos, F Blocks))
    -> ParsecT Text ParserState m ParserState
    -> ParsecT Text ParserState m (Map Text (SourcePos, F Blocks))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
         case Text
    -> Map Text (SourcePos, F Blocks) -> Maybe (SourcePos, F Blocks)
    forall k a. Ord k => k -> Map k a -> Maybe a
    M.lookup Text
    ref Map Text (SourcePos, F Blocks)
    oldnotes of
           Just _  -> LogMessage -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasLogMessages st) =>
    LogMessage -> ParserT s st m ()
    logMessage (LogMessage -> ParserT Text ParserState m ())
    -> LogMessage -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ Text -> SourcePos -> LogMessage
    DuplicateNoteReference Text
    ref SourcePos
    pos
           Nothing -> () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
         (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParserT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \s :: ParserState
    s -> ParserState
    s { stateNotes' :: Map Text (SourcePos, F Blocks)
    stateNotes' =
           Text
    -> (SourcePos, F Blocks)
    -> Map Text (SourcePos, F Blocks)
    -> Map Text (SourcePos, F Blocks)
    forall k a. Ord k => k -> a -> Map k a -> Map k a
    M.insert Text
    ref (SourcePos
    pos, F Blocks
    parsed) Map Text (SourcePos, F Blocks)
    oldnotes }
         F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Blocks
    forall a. Monoid a => a
    mempty

    --
    -- parsing blocks
    --

    parseBlocks :: PandocMonad m => MarkdownParser m (F Blocks)
    parseBlocks :: MarkdownParser m (F Blocks)
    parseBlocks = [F Blocks] -> F Blocks
    forall a. Monoid a => [a] -> a
    mconcat ([F Blocks] -> F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    -> MarkdownParser m (F Blocks)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Blocks)
    -> ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m [F Blocks]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    manyTill MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    block ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u.
    (Stream s m t, Show t) =>
    ParsecT s u m ()
    eof

    block :: PandocMonad m => MarkdownParser m (F Blocks)
    block :: MarkdownParser m (F Blocks)
    block = do
      F Blocks
    res <- [MarkdownParser m (F Blocks)] -> MarkdownParser m (F Blocks)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice [ F Blocks
    forall a. Monoid a => a
    mempty F Blocks
    -> ParsecT Text ParserState m Text -> MarkdownParser m (F Blocks)
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    codeBlockFenced
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    yamlMetaBlock
                   -- note: bulletList needs to be before header because of
                   -- the possibility of empty list items: -
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    bulletList
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    divHtml
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    divFenced
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    header
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    lhsCodeBlock
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    htmlBlock
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    table
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    codeBlockIndented
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    rawTeXBlock
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    lineBlock
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    blockQuote
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *) st.
    PandocMonad m =>
    ParserT Text st m (F Blocks)
    hrule
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    orderedList
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    definitionList
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    noteBlock
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    referenceKey
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    abbrevKey
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    para
                   , MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    plain
                   ] MarkdownParser m (F Blocks)
    -> [Char] -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> "block"
      Text -> ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => Text -> m ()
    trace (Int -> Text -> Text
    T.take 60 (Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $ [Block] -> Text
    forall a. Show a => a -> Text
    tshow ([Block] -> Text) -> [Block] -> Text
    forall a b. (a -> b) -> a -> b
    $ Blocks -> [Block]
    forall a. Many a -> [a]
    B.toList (Blocks -> [Block]) -> Blocks -> [Block]
    forall a b. (a -> b) -> a -> b
    $ F Blocks -> ParserState -> Blocks
    forall s a. Future s a -> s -> a
    runF F Blocks
    res ParserState
    defaultParserState)
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Blocks
    res

    --
    -- header blocks
    --

    header :: PandocMonad m => MarkdownParser m (F Blocks)
    header :: MarkdownParser m (F Blocks)
    header = MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    setextHeader MarkdownParser m (F Blocks)
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    atxHeader MarkdownParser m (F Blocks)
    -> [Char] -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> "header"

    atxChar :: PandocMonad m => MarkdownParser m Char
    atxChar :: MarkdownParser m Char
    atxChar = do
      Extensions
    exts <- (ReaderOptions -> Extensions)
    -> ParserT Text ParserState 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
      Char -> MarkdownParser m Char
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Char -> MarkdownParser m Char) -> Char -> MarkdownParser m Char
    forall a b. (a -> b) -> a -> b
    $ if Extension -> Extensions -> Bool
    extensionEnabled Extension
    Ext_literate_haskell Extensions
    exts
                  then '='
                  else '#'

    atxHeader :: PandocMonad m => MarkdownParser m (F Blocks)
    atxHeader :: MarkdownParser m (F Blocks)
    atxHeader = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      Int
    level <- ([Char] -> Int)
    -> ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Char] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length (MarkdownParser m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    atxChar MarkdownParser m Char
    -> (Char -> ParsecT Text ParserState m [Char])
    -> ParsecT Text ParserState m [Char]
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= MarkdownParser m Char -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (MarkdownParser m Char -> ParsecT Text ParserState m [Char])
    -> (Char -> MarkdownParser m Char)
    -> Char
    -> ParsecT Text ParserState m [Char]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Char -> MarkdownParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char)
      MarkdownParser m Char -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy (MarkdownParser m Char -> ParsecT Text ParserState m ())
    -> MarkdownParser m Char -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_fancy_lists ParsecT Text ParserState m ()
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                      (Char -> MarkdownParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '.' MarkdownParser m Char
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Char -> MarkdownParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ')') -- this would be a list
      Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_space_in_atx_header ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m Char -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy MarkdownParser m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    nonspaceChar
      ParsecT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      (text :: F Inlines
    text, raw :: Text
    raw) <- ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines, Text)
    forall (m :: * -> *) st a.
    Monad m =>
    ParsecT Text st m a -> ParsecT Text st m (a, Text)
    withRaw (ParsecT Text ParserState m (F Inlines)
     -> ParsecT Text ParserState m (F Inlines, Text))
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines, Text)
    forall a b. (a -> b) -> a -> b
    $ do
        Bool
    oldAllowLineBreaks <- ParserState -> Bool
    stateAllowLineBreaks (ParserState -> Bool)
    -> ParsecT Text ParserState m ParserState
    -> ParsecT Text ParserState m Bool
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
        (ParserState -> ParserState) -> ParsecT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParsecT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateAllowLineBreaks :: Bool
    stateAllowLineBreaks = Bool
    False }
        F Inlines
    res <- 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 ParserState m [F Inlines]
    -> ParsecT Text ParserState m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                   ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParsecT Text ParserState m Attr -> ParsecT Text ParserState 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 ParserState m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    atxClosing ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline)
        (ParserState -> ParserState) -> ParsecT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParsecT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateAllowLineBreaks :: Bool
    stateAllowLineBreaks = Bool
    oldAllowLineBreaks }
        F Inlines -> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Inlines
    res
      Attr
    attr <- ParsecT Text ParserState m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    atxClosing
      Attr
    attr' <- Attr -> Inlines -> ParsecT Text ParserState m Attr
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st, HasLogMessages st,
     HasIdentifierList st) =>
    Attr -> Inlines -> ParserT s st m Attr
    registerHeader Attr
    attr (F Inlines -> ParserState -> Inlines
    forall s a. Future s a -> s -> a
    runF F Inlines
    text ParserState
    defaultParserState)
      Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_implicit_header_references
        ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Text -> Attr -> ParsecT Text ParserState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Text -> Attr -> MarkdownParser m ()
    registerImplicitHeader Text
    raw Attr
    attr'
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Attr -> Int -> Inlines -> Blocks
    B.headerWith Attr
    attr' Int
    level (Inlines -> Blocks) -> F Inlines -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    text

    atxClosing :: PandocMonad m => MarkdownParser m Attr
    atxClosing :: MarkdownParser m Attr
    atxClosing = MarkdownParser m Attr -> MarkdownParser m Attr
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Attr -> MarkdownParser m Attr)
    -> MarkdownParser m Attr -> MarkdownParser m Attr
    forall a b. (a -> b) -> a -> b
    $ do
      Attr
    attr' <- Attr -> MarkdownParser m Attr -> MarkdownParser m Attr
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option Attr
    nullAttr
                 (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_mmd_header_identifiers ParserT Text ParserState m ()
    -> MarkdownParser m Attr -> MarkdownParser m Attr
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    mmdHeaderIdentifier)
      ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany (ParsecT Text ParserState m Char -> ParserT Text ParserState m ())
    -> (Char -> ParsecT Text ParserState m Char)
    -> Char
    -> ParserT Text ParserState m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char (Char -> ParserT Text ParserState m ())
    -> ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< ParsecT Text ParserState m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    atxChar
      ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      Attr
    attr <- Attr -> MarkdownParser m Attr -> MarkdownParser m Attr
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option Attr
    attr'
                 (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_header_attributes ParserT Text ParserState m ()
    -> MarkdownParser m Attr -> MarkdownParser m Attr
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    attributes)
      ParserT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      Attr -> MarkdownParser m Attr
    forall (m :: * -> *) a. Monad m => a -> m a
    return Attr
    attr

    setextHeaderEnd :: PandocMonad m => MarkdownParser m Attr
    setextHeaderEnd :: MarkdownParser m Attr
    setextHeaderEnd = MarkdownParser m Attr -> MarkdownParser m Attr
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Attr -> MarkdownParser m Attr)
    -> MarkdownParser m Attr -> MarkdownParser m Attr
    forall a b. (a -> b) -> a -> b
    $ do
      Attr
    attr <- Attr -> MarkdownParser m Attr -> MarkdownParser m Attr
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option Attr
    nullAttr
              (MarkdownParser m Attr -> MarkdownParser m Attr)
    -> MarkdownParser m Attr -> MarkdownParser m Attr
    forall a b. (a -> b) -> a -> b
    $ (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_mmd_header_identifiers ParserT Text ParserState m ()
    -> MarkdownParser m Attr -> MarkdownParser m Attr
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    mmdHeaderIdentifier)
               MarkdownParser m Attr
    -> MarkdownParser m Attr -> MarkdownParser m Attr
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_header_attributes ParserT Text ParserState m ()
    -> MarkdownParser m Attr -> MarkdownParser m Attr
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    attributes)
      ParserT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      Attr -> MarkdownParser m Attr
    forall (m :: * -> *) a. Monad m => a -> m a
    return Attr
    attr

    mmdHeaderIdentifier :: PandocMonad m => MarkdownParser m Attr
    mmdHeaderIdentifier :: MarkdownParser m Attr
    mmdHeaderIdentifier = do
      (_, raw :: Text
    raw) <- MarkdownParser m (F Inlines, Text)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F Inlines, Text)
    reference
      let raw' :: Text
    raw' = Text -> Text
    trim (Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    stripFirstAndLast Text
    raw
      let ident :: Text
    ident = [Text] -> Text
    T.concat ([Text] -> Text) -> [Text] -> Text
    forall a b. (a -> b) -> a -> b
    $ Text -> [Text]
    T.words (Text -> [Text]) -> Text -> [Text]
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    T.toLower Text
    raw'
      let attr :: (Text, [a], [a])
    attr = (Text
    ident, [], [])
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_implicit_header_references
        ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Text -> Attr -> ParserT Text ParserState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Text -> Attr -> MarkdownParser m ()
    registerImplicitHeader Text
    raw' Attr
    forall a a. (Text, [a], [a])
    attr
      ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      Attr -> MarkdownParser m Attr
    forall (m :: * -> *) a. Monad m => a -> m a
    return Attr
    forall a a. (Text, [a], [a])
    attr

    setextHeader :: PandocMonad m => MarkdownParser m (F Blocks)
    setextHeader :: MarkdownParser m (F Blocks)
    setextHeader = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      -- This lookahead prevents us from wasting time parsing Inlines
      -- unless necessary -- it gives a significant performance boost.
      ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
     -> ParsecT Text ParserState m Char)
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall a b. (a -> b) -> a -> b
    $ ParserT Text ParserState m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine ParserT Text ParserState m Text
    -> ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 ([Char] -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf [Char]
    setextHChars) ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
      ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      (text :: F Inlines
    text, raw :: Text
    raw) <- ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines, Text)
    forall (m :: * -> *) st a.
    Monad m =>
    ParsecT Text st m a -> ParsecT Text st m (a, Text)
    withRaw (ParsecT Text ParserState m (F Inlines)
     -> ParsecT Text ParserState m (F Inlines, Text))
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines, Text)
    forall a b. (a -> b) -> a -> b
    $ do
        Bool
    oldAllowLineBreaks <- ParserState -> Bool
    stateAllowLineBreaks (ParserState -> Bool)
    -> ParsecT Text ParserState m ParserState
    -> ParsecT Text ParserState m Bool
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
        (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParserT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateAllowLineBreaks :: Bool
    stateAllowLineBreaks = Bool
    False }
        F Inlines
    res <- 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 ParserState m [F Inlines]
    -> ParsecT Text ParserState m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                   ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParsecT Text ParserState m Attr -> ParserT Text ParserState 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 ParserState m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    setextHeaderEnd ParserT Text ParserState m ()
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline)
        (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParserT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateAllowLineBreaks :: Bool
    stateAllowLineBreaks = Bool
    oldAllowLineBreaks }
        F Inlines -> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Inlines
    res
      Attr
    attr <- ParsecT Text ParserState m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    setextHeaderEnd
      Char
    underlineChar <- [Char] -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf [Char]
    setextHChars
      ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    underlineChar)
      ParserT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      let level :: Int
    level = Int -> Maybe Int -> Int
    forall a. a -> Maybe a -> a
    fromMaybe 0 (Char -> [Char] -> Maybe Int
    forall a. Eq a => a -> [a] -> Maybe Int
    elemIndex Char
    underlineChar [Char]
    setextHChars) Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + 1
      Attr
    attr' <- Attr -> Inlines -> ParsecT Text ParserState m Attr
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st, HasLogMessages st,
     HasIdentifierList st) =>
    Attr -> Inlines -> ParserT s st m Attr
    registerHeader Attr
    attr (F Inlines -> ParserState -> Inlines
    forall s a. Future s a -> s -> a
    runF F Inlines
    text ParserState
    defaultParserState)
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_implicit_header_references
        ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Text -> Attr -> ParserT Text ParserState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Text -> Attr -> MarkdownParser m ()
    registerImplicitHeader Text
    raw Attr
    attr'
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Attr -> Int -> Inlines -> Blocks
    B.headerWith Attr
    attr' Int
    level (Inlines -> Blocks) -> F Inlines -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    text

    registerImplicitHeader :: PandocMonad m => Text -> Attr -> MarkdownParser m ()
    registerImplicitHeader :: Text -> Attr -> MarkdownParser m ()
    registerImplicitHeader raw :: Text
    raw attr :: Attr
    attr@(ident :: Text
    ident, _, _)
      | Text -> Bool
    T.null Text
    raw = () -> MarkdownParser m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
      | Bool
    otherwise = do
          let key :: Key
    key = Text -> Key
    toKey (Text -> Key) -> Text -> Key
    forall a b. (a -> b) -> a -> b
    $ "[" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    raw Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> "]"
          (ParserState -> ParserState) -> MarkdownParser m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> MarkdownParser m ())
    -> (ParserState -> ParserState) -> MarkdownParser m ()
    forall a b. (a -> b) -> a -> b
    $ \s :: ParserState
    s ->
            ParserState
    s { stateHeaderKeys :: KeyTable
    stateHeaderKeys = Key -> ((Text, Text), Attr) -> KeyTable -> KeyTable
    forall k a. Ord k => k -> a -> Map k a -> Map k a
    M.insert Key
    key (("#" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    ident,""), Attr
    attr)
                                         (ParserState -> KeyTable
    stateHeaderKeys ParserState
    s) }

    --
    -- hrule block
    --

    hrule :: PandocMonad m => ParserT Text st m (F Blocks)
    hrule :: ParserT Text st m (F Blocks)
    hrule = ParserT Text st m (F Blocks) -> ParserT Text st m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParserT Text st m (F Blocks) -> ParserT Text st m (F Blocks))
    -> ParserT Text st m (F Blocks) -> ParserT Text st m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      ParserT Text st m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      Char
    start <- (Char -> Bool) -> ParsecT Text st m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy Char -> Bool
    isHruleChar
      Int -> ParsecT Text st m Char -> ParsecT Text st m [Char]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    Int -> ParsecT s u m a -> ParsecT s u m [a]
    count 2 (ParserT Text st m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces ParserT Text st m ()
    -> ParsecT Text st m Char -> ParsecT Text st m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Char -> ParsecT Text st m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    start)
      ParsecT Text st m Char -> ParserT Text st m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany (ParsecT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar ParsecT Text st m Char
    -> ParsecT Text st m Char -> ParsecT Text st 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 st m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    start)
      ParsecT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
      ParsecT Text st m Text -> ParserT Text st m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParsecT Text st m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      F Blocks -> ParserT Text st m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> ParserT Text st m (F Blocks))
    -> F Blocks -> ParserT Text st m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    B.horizontalRule

    --
    -- code blocks
    --

    indentedLine :: PandocMonad m => MarkdownParser m Text
    indentedLine :: MarkdownParser m Text
    indentedLine = MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    indentSpaces MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLineNewline

    blockDelimiter :: PandocMonad m
                   => (Char -> Bool)
                   -> Maybe Int
                   -> ParserT Text ParserState m Int
    blockDelimiter :: (Char -> Bool) -> Maybe Int -> ParserT Text ParserState m Int
    blockDelimiter f :: Char -> Bool
    f len :: Maybe Int
    len = ParserT Text ParserState m Int -> ParserT Text ParserState m Int
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParserT Text ParserState m Int -> ParserT Text ParserState m Int)
    -> ParserT Text ParserState m Int -> ParserT Text ParserState m Int
    forall a b. (a -> b) -> a -> b
    $ do
      ParserT Text ParserState m Int
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
    skipNonindentSpaces
      Char
    c <- ParsecT Text ParserState m Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead ((Char -> Bool) -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy Char -> Bool
    f)
      case Maybe Int
    len of
          Just l :: Int
    l  -> Int
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState 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
    l (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c) ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c) ParsecT Text ParserState m [Char]
    -> ParserT Text ParserState m Int -> ParserT Text ParserState m Int
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Int -> ParserT Text ParserState m Int
    forall (m :: * -> *) a. Monad m => a -> m a
    return Int
    l
          Nothing -> ([Char] -> Int)
    -> ParsecT Text ParserState m [Char]
    -> ParserT Text ParserState m Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + 3) (Int -> Int) -> ([Char] -> Int) -> [Char] -> Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Char] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length) (Int
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    Int -> ParsecT s u m a -> ParsecT s u m [a]
    count 3 (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c) ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c))

    attributes :: PandocMonad m => MarkdownParser m Attr
    attributes :: MarkdownParser m Attr
    attributes = MarkdownParser m Attr -> MarkdownParser m Attr
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Attr -> MarkdownParser m Attr)
    -> MarkdownParser m Attr -> MarkdownParser m Attr
    forall a b. (a -> b) -> a -> b
    $ do
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '{'
      ParserT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    spnl
      [Attr -> Attr]
    attrs <- ParsecT Text ParserState m (Attr -> Attr)
    -> ParsecT Text ParserState m [Attr -> Attr]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParsecT Text ParserState m (Attr -> Attr)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (Attr -> Attr)
    attribute ParsecT Text ParserState m (Attr -> Attr)
    -> ParserT Text ParserState m ()
    -> ParsecT Text ParserState m (Attr -> Attr)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParserT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    spnl)
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '}'
      Attr -> MarkdownParser m Attr
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Attr -> MarkdownParser m Attr) -> Attr -> MarkdownParser m Attr
    forall a b. (a -> b) -> a -> b
    $ (Attr -> (Attr -> Attr) -> Attr) -> Attr -> [Attr -> Attr] -> Attr
    forall (t :: * -> *) b a.
    Foldable t =>
    (b -> a -> b) -> b -> t a -> b
    foldl (\x :: Attr
    x f :: Attr -> Attr
    f -> Attr -> Attr
    f Attr
    x) Attr
    nullAttr [Attr -> Attr]
    attrs

    attribute :: PandocMonad m => MarkdownParser m (Attr -> Attr)
    attribute :: MarkdownParser m (Attr -> Attr)
    attribute = MarkdownParser m (Attr -> Attr)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (Attr -> Attr)
    identifierAttr MarkdownParser m (Attr -> Attr)
    -> MarkdownParser m (Attr -> Attr)
    -> MarkdownParser m (Attr -> Attr)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m (Attr -> Attr)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (Attr -> Attr)
    classAttr MarkdownParser m (Attr -> Attr)
    -> MarkdownParser m (Attr -> Attr)
    -> MarkdownParser m (Attr -> Attr)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m (Attr -> Attr)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (Attr -> Attr)
    keyValAttr MarkdownParser m (Attr -> Attr)
    -> MarkdownParser m (Attr -> Attr)
    -> MarkdownParser m (Attr -> Attr)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m (Attr -> Attr)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (Attr -> Attr)
    specialAttr

    identifier :: PandocMonad m => MarkdownParser m Text
    identifier :: MarkdownParser m Text
    identifier = do
      Char
    first <- ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    letter
      [Char]
    rest <- ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParsecT Text ParserState m Char
     -> ParsecT Text ParserState m [Char])
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    alphaNum ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf "-_:."
      Text -> MarkdownParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> MarkdownParser m Text) -> Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Text
    T.pack (Char
    firstChar -> [Char] -> [Char]
    forall a. a -> [a] -> [a]
    :[Char]
    rest)

    identifierAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr)
    identifierAttr :: MarkdownParser m (Attr -> Attr)
    identifierAttr = MarkdownParser m (Attr -> Attr) -> MarkdownParser m (Attr -> Attr)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (Attr -> Attr)
     -> MarkdownParser m (Attr -> Attr))
    -> MarkdownParser m (Attr -> Attr)
    -> MarkdownParser m (Attr -> Attr)
    forall a b. (a -> b) -> a -> b
    $ do
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '#'
      Text
    result <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    identifier
      (Attr -> Attr) -> MarkdownParser m (Attr -> Attr)
    forall (m :: * -> *) a. Monad m => a -> m a
    return ((Attr -> Attr) -> MarkdownParser m (Attr -> Attr))
    -> (Attr -> Attr) -> MarkdownParser m (Attr -> Attr)
    forall a b. (a -> b) -> a -> b
    $ \(_,cs :: [Text]
    cs,kvs :: [(Text, Text)]
    kvs) -> (Text
    result,[Text]
    cs,[(Text, Text)]
    kvs)

    classAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr)
    classAttr :: MarkdownParser m (Attr -> Attr)
    classAttr = MarkdownParser m (Attr -> Attr) -> MarkdownParser m (Attr -> Attr)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (Attr -> Attr)
     -> MarkdownParser m (Attr -> Attr))
    -> MarkdownParser m (Attr -> Attr)
    -> MarkdownParser m (Attr -> Attr)
    forall a b. (a -> b) -> a -> b
    $ do
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '.'
      Text
    result <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    identifier
      (Attr -> Attr) -> MarkdownParser m (Attr -> Attr)
    forall (m :: * -> *) a. Monad m => a -> m a
    return ((Attr -> Attr) -> MarkdownParser m (Attr -> Attr))
    -> (Attr -> Attr) -> MarkdownParser m (Attr -> Attr)
    forall a b. (a -> b) -> a -> b
    $ \(id' :: Text
    id',cs :: [Text]
    cs,kvs :: [(Text, Text)]
    kvs) -> (Text
    id',[Text]
    cs [Text] -> [Text] -> [Text]
    forall a. [a] -> [a] -> [a]
    ++ [Text
    result],[(Text, Text)]
    kvs)

    keyValAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr)
    keyValAttr :: MarkdownParser m (Attr -> Attr)
    keyValAttr = MarkdownParser m (Attr -> Attr) -> MarkdownParser m (Attr -> Attr)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (Attr -> Attr)
     -> MarkdownParser m (Attr -> Attr))
    -> MarkdownParser m (Attr -> Attr)
    -> MarkdownParser m (Attr -> Attr)
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    key <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    identifier
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '='
      Text
    val <- [Char] -> Text
    T.pack ([Char] -> Text)
    -> ParsecT Text ParserState m [Char] -> MarkdownParser m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    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 (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '"') (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '"') ParsecT Text ParserState m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    litChar
         MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> [Char] -> Text
    T.pack ([Char] -> Text)
    -> ParsecT Text ParserState m [Char] -> MarkdownParser m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    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 (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '\'') (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '\'') ParsecT Text ParserState m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    litChar
         MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser 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 ParserState m [Char] -> MarkdownParser m Text
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ([Char] -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "\"\""))
         MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser 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 ParserState m [Char] -> MarkdownParser m Text
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ([Char] -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "''"))
         MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m Char -> MarkdownParser m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    manyChar (ParsecT Text ParserState m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    escapedChar' ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf " \t\n\r}")
      (Attr -> Attr) -> MarkdownParser m (Attr -> Attr)
    forall (m :: * -> *) a. Monad m => a -> m a
    return ((Attr -> Attr) -> MarkdownParser m (Attr -> Attr))
    -> (Attr -> Attr) -> MarkdownParser m (Attr -> Attr)
    forall a b. (a -> b) -> a -> b
    $ \(id' :: Text
    id',cs :: [Text]
    cs,kvs :: [(Text, Text)]
    kvs) ->
        case Text
    key of
             "id"    -> (Text
    val,[Text]
    cs,[(Text, Text)]
    kvs)
             "class" -> (Text
    id',[Text]
    cs [Text] -> [Text] -> [Text]
    forall a. [a] -> [a] -> [a]
    ++ Text -> [Text]
    T.words Text
    val,[(Text, Text)]
    kvs)
             _       -> (Text
    id',[Text]
    cs,[(Text, Text)]
    kvs [(Text, Text)] -> [(Text, Text)] -> [(Text, Text)]
    forall a. [a] -> [a] -> [a]
    ++ [(Text
    key,Text
    val)])

    specialAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr)
    specialAttr :: MarkdownParser m (Attr -> Attr)
    specialAttr = do
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '-'
      (Attr -> Attr) -> MarkdownParser m (Attr -> Attr)
    forall (m :: * -> *) a. Monad m => a -> m a
    return ((Attr -> Attr) -> MarkdownParser m (Attr -> Attr))
    -> (Attr -> Attr) -> MarkdownParser m (Attr -> Attr)
    forall a b. (a -> b) -> a -> b
    $ \(id' :: Text
    id',cs :: [Text]
    cs,kvs :: [(Text, Text)]
    kvs) -> (Text
    id',[Text]
    cs [Text] -> [Text] -> [Text]
    forall a. [a] -> [a] -> [a]
    ++ ["unnumbered"],[(Text, Text)]
    kvs)

    rawAttribute :: PandocMonad m => MarkdownParser m Text
    rawAttribute :: MarkdownParser m Text
    rawAttribute = do
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '{'
      ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '='
      Text
    format <- ParsecT Text ParserState m Char -> MarkdownParser m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char (ParsecT Text ParserState m Char -> MarkdownParser m Text)
    -> ParsecT Text ParserState m Char -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ (Char -> Bool) -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy (\c :: Char
    c -> Char -> Bool
    isAlphaNum Char
    c Bool -> Bool -> Bool
    || Char
    c Char -> [Char] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` ['-', '_'])
      ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '}'
      Text -> MarkdownParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return Text
    format

    codeBlockFenced :: PandocMonad m => MarkdownParser m (F Blocks)
    codeBlockFenced :: MarkdownParser m (F Blocks)
    codeBlockFenced = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    indentchars <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    nonindentSpaces
      let indentLevel :: Int
    indentLevel = Text -> Int
    T.length Text
    indentchars
      Char
    c <- ParsecT Text ParserState m Char -> ParsecT Text ParserState m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_fenced_code_blocks ParserT Text ParserState m ()
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '~'))
         ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_backtick_code_blocks ParserT Text ParserState m ()
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '`'))
      Int
    size <- (Char -> Bool) -> Maybe Int -> ParserT Text ParserState m Int
    forall (m :: * -> *).
    PandocMonad m =>
    (Char -> Bool) -> Maybe Int -> ParserT Text ParserState m Int
    blockDelimiter (Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == Char
    c) Maybe Int
    forall a. Maybe a
    Nothing
      ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
      Either Text Attr
    rawattr <-
         (Text -> Either Text Attr
    forall a b. a -> Either a b
    Left (Text -> Either Text Attr)
    -> MarkdownParser m Text
    -> ParsecT Text ParserState m (Either Text Attr)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_raw_attribute ParserT Text ParserState m ()
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    rawAttribute))
        ParsecT Text ParserState m (Either Text Attr)
    -> ParsecT Text ParserState m (Either Text Attr)
    -> ParsecT Text ParserState m (Either Text Attr)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
         (Attr -> Either Text Attr
    forall a b. b -> Either a b
    Right (Attr -> Either Text Attr)
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m (Either Text Attr)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Attr
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m Attr
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option ("",[],[])
             (ParsecT Text ParserState m Attr -> ParsecT Text ParserState m Attr
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_fenced_code_attributes ParserT Text ParserState m ()
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m Attr
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    attributes)
              ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m Attr
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ((\x :: Text
    x -> ("",[Text -> Text
    toLanguageId Text
    x],[])) (Text -> Attr)
    -> MarkdownParser m Text -> ParsecT Text ParserState m Attr
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Char -> MarkdownParser m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    nonspaceChar)))
      ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
      Text
    contents <- Text -> [Text] -> Text
    T.intercalate "\n" ([Text] -> Text)
    -> ParsecT Text ParserState m [Text] -> MarkdownParser m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                     MarkdownParser m Text
    -> MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    manyTill (Int -> ParserT Text ParserState m Int
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m Int
    gobbleAtMostSpaces Int
    indentLevel ParserT Text ParserState m Int
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine)
                              (MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
                                (Char -> Bool) -> Maybe Int -> ParserT Text ParserState m Int
    forall (m :: * -> *).
    PandocMonad m =>
    (Char -> Bool) -> Maybe Int -> ParserT Text ParserState m Int
    blockDelimiter (Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == Char
    c) (Int -> Maybe Int
    forall a. a -> Maybe a
    Just Int
    size)
                                MarkdownParser m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines)
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> F Blocks) -> Blocks -> F Blocks
    forall a b. (a -> b) -> a -> b
    $
        case Either Text Attr
    rawattr of
              Left syn :: Text
    syn   -> Text -> Text -> Blocks
    B.rawBlock Text
    syn Text
    contents
              Right attr :: Attr
    attr -> Attr -> Text -> Blocks
    B.codeBlockWith Attr
    attr Text
    contents

    -- correctly handle github language identifiers
    toLanguageId :: Text -> Text
    toLanguageId :: Text -> Text
    toLanguageId = Text -> Text
    T.toLower (Text -> Text) -> (Text -> Text) -> Text -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text
    forall p. (Eq p, IsString p) => p -> p
    go
      where go :: p -> p
    go "c++"         = "cpp"
            go "objective-c" = "objectivec"
            go x :: p
    x             = p
    x

    codeBlockIndented :: PandocMonad m => MarkdownParser m (F Blocks)
    codeBlockIndented :: MarkdownParser m (F Blocks)
    codeBlockIndented = do
      [Text]
    contents <- ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (ParsecT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    indentedLine ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
                         ParsecT Text ParserState m Text -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (do Text
    b <- ParsecT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
                                 Text
    l <- ParsecT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    indentedLine
                                 Text -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> ParsecT Text ParserState m Text)
    -> Text -> ParsecT Text ParserState m Text
    forall a b. (a -> b) -> a -> b
    $ Text
    b Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    l))
      ParsecT Text ParserState m Text -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParsecT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      [Text]
    classes <- (ReaderOptions -> [Text]) -> ParsecT Text ParserState m [Text]
    forall st s (m :: * -> *) t b.
    (HasReaderOptions st, Stream s m t) =>
    (ReaderOptions -> b) -> ParserT s st m b
    getOption ReaderOptions -> [Text]
    readerIndentedCodeClasses
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> F Blocks) -> Blocks -> F Blocks
    forall a b. (a -> b) -> a -> b
    $ Attr -> Text -> Blocks
    B.codeBlockWith ("", [Text]
    classes, []) (Text -> Blocks) -> Text -> Blocks
    forall a b. (a -> b) -> a -> b
    $
               Text -> Text
    stripTrailingNewlines (Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $ [Text] -> Text
    T.concat [Text]
    contents

    lhsCodeBlock :: PandocMonad m => MarkdownParser m (F Blocks)
    lhsCodeBlock :: MarkdownParser m (F Blocks)
    lhsCodeBlock = do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_literate_haskell
      (Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> F Blocks) -> (Text -> Blocks) -> Text -> F Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Attr -> Text -> Blocks
    B.codeBlockWith ("",["haskell","literate"],[]) (Text -> F Blocks)
    -> ParsecT Text ParserState m Text -> MarkdownParser m (F Blocks)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
              (ParsecT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    lhsCodeBlockBird ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    lhsCodeBlockLaTeX))
        MarkdownParser m (F Blocks)
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> F Blocks) -> (Text -> Blocks) -> Text -> F Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Attr -> Text -> Blocks
    B.codeBlockWith ("",["haskell"],[]) (Text -> F Blocks)
    -> ParsecT Text ParserState m Text -> MarkdownParser m (F Blocks)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
              ParsecT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    lhsCodeBlockInverseBird)

    lhsCodeBlockLaTeX :: PandocMonad m => MarkdownParser m Text
    lhsCodeBlockLaTeX :: MarkdownParser m Text
    lhsCodeBlockLaTeX = MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
      [Char] -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "\\begin{code}"
      ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    manyTill ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
      Text
    contents <- ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char] -> MarkdownParser 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    anyChar (ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text ParserState m [Char]
     -> ParsecT Text ParserState m [Char])
    -> ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    forall a b. (a -> b) -> a -> b
    $ [Char] -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "\\end{code}")
      MarkdownParser m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      Text -> MarkdownParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> MarkdownParser m Text) -> Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    stripTrailingNewlines Text
    contents

    lhsCodeBlockBird :: PandocMonad m => MarkdownParser m Text
    lhsCodeBlockBird :: MarkdownParser m Text
    lhsCodeBlockBird = Char -> MarkdownParser m Text
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> MarkdownParser m Text
    lhsCodeBlockBirdWith '>'

    lhsCodeBlockInverseBird :: PandocMonad m => MarkdownParser m Text
    lhsCodeBlockInverseBird :: MarkdownParser m Text
    lhsCodeBlockInverseBird = Char -> MarkdownParser m Text
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> MarkdownParser m Text
    lhsCodeBlockBirdWith '<'

    lhsCodeBlockBirdWith :: PandocMonad m => Char -> MarkdownParser m Text
    lhsCodeBlockBirdWith :: Char -> MarkdownParser m Text
    lhsCodeBlockBirdWith c :: Char
    c = MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
      SourcePos
    pos <- ParsecT Text ParserState m SourcePos
    forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
    getPosition
      Bool
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    when (SourcePos -> Int
    sourceColumn SourcePos
    pos Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    /= 1) (ParsecT Text ParserState m () -> ParsecT Text ParserState m ())
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ [Char] -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a. MonadFail m => [Char] -> m a
    Prelude.fail "Not in first column"
      [Text]
    lns <- MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (MarkdownParser m Text -> ParsecT Text ParserState m [Text])
    -> MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall a b. (a -> b) -> a -> b
    $ Char -> MarkdownParser m Text
    forall (m :: * -> *) st.
    PandocMonad m =>
    Char -> ParserT Text st m Text
    birdTrackLine Char
    c
      -- if (as is normal) there is always a space after >, drop it
      let lns' :: [Text]
    lns' = if (Text -> Bool) -> [Text] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all (\ln :: Text
    ln -> Text -> Bool
    T.null Text
    ln Bool -> Bool -> Bool
    || Int -> Text -> Text
    T.take 1 Text
    ln Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == " ") [Text]
    lns
                    then (Text -> Text) -> [Text] -> [Text]
    forall a b. (a -> b) -> [a] -> [b]
    map (Int -> Text -> Text
    T.drop 1) [Text]
    lns
                    else [Text]
    lns
      MarkdownParser m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      Text -> MarkdownParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> MarkdownParser m Text) -> Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ Text -> [Text] -> Text
    T.intercalate "\n" [Text]
    lns'

    birdTrackLine :: PandocMonad m => Char -> ParserT Text st m Text
    birdTrackLine :: Char -> ParserT Text st m Text
    birdTrackLine c :: Char
    c = ParserT Text st m Text -> ParserT Text st m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParserT Text st m Text -> ParserT Text st m Text)
    -> ParserT Text st m Text -> ParserT Text st m Text
    forall a b. (a -> b) -> a -> b
    $ do
      Char -> ParsecT Text st m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c
      -- allow html tags on left margin:
      Bool -> ParsecT Text st m () -> ParsecT Text st m ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    when (Char
    c Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == '<') (ParsecT Text st m () -> ParsecT Text st m ())
    -> ParsecT Text st m () -> ParsecT Text st m ()
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text st m Char -> ParsecT Text st 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 m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    letter
      ParserT Text st m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine

    --
    -- block quotes
    --

    emailBlockQuoteStart :: PandocMonad m => MarkdownParser m Char
    emailBlockQuoteStart :: MarkdownParser m Char
    emailBlockQuoteStart = MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Char -> MarkdownParser m Char)
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Int
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
    skipNonindentSpaces MarkdownParser m Int
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Char -> MarkdownParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '>' MarkdownParser m Char
    -> ParsecT Text ParserState m () -> MarkdownParser m Char
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* MarkdownParser m Char -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional (Char -> MarkdownParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ' ')

    emailBlockQuote :: PandocMonad m => MarkdownParser m [Text]
    emailBlockQuote :: MarkdownParser m [Text]
    emailBlockQuote = MarkdownParser m [Text] -> MarkdownParser m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m [Text] -> MarkdownParser m [Text])
    -> MarkdownParser m [Text] -> MarkdownParser m [Text]
    forall a b. (a -> b) -> a -> b
    $ do
      MarkdownParser m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    emailBlockQuoteStart
      let emailLine :: ParserT Text ParserState m Text
    emailLine = MarkdownParser m Char -> ParserT Text ParserState m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    manyChar (MarkdownParser m Char -> ParserT Text ParserState m Text)
    -> MarkdownParser m Char -> ParserT Text ParserState m Text
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Char
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Char
    nonEndline MarkdownParser m Char
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try
                                  (MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    endline MarkdownParser m (F Inlines)
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Char -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy MarkdownParser m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    emailBlockQuoteStart ParsecT Text ParserState m ()
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                                   Char -> MarkdownParser m Char
    forall (m :: * -> *) a. Monad m => a -> m a
    return '\n')
      let emailSep :: MarkdownParser m Char
    emailSep = MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline MarkdownParser m Char
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    emailBlockQuoteStart)
      Text
    first <- ParserT Text ParserState m Text
    emailLine
      [Text]
    rest <- ParserT Text ParserState m Text -> MarkdownParser m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParserT Text ParserState m Text -> MarkdownParser m [Text])
    -> ParserT Text ParserState m Text -> MarkdownParser m [Text]
    forall a b. (a -> b) -> a -> b
    $ ParserT Text ParserState m Text -> ParserT Text ParserState m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParserT Text ParserState m Text
     -> ParserT Text ParserState m Text)
    -> ParserT Text ParserState m Text
    -> ParserT Text ParserState m Text
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Char
    emailSep MarkdownParser m Char
    -> ParserT Text ParserState m Text
    -> ParserT Text ParserState m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParserT Text ParserState m Text
    emailLine
      let raw :: [Text]
    raw = Text
    firstText -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    :[Text]
    rest
      MarkdownParser m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline MarkdownParser m Char
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u.
    (Stream s m t, Show t) =>
    ParsecT s u m ()
    eof ParsecT Text ParserState m ()
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Char -> MarkdownParser m Char
    forall (m :: * -> *) a. Monad m => a -> m a
    return '\n')
      ParserT Text ParserState m Text -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParserT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      [Text] -> MarkdownParser m [Text]
    forall (m :: * -> *) a. Monad m => a -> m a
    return [Text]
    raw

    blockQuote :: PandocMonad m => MarkdownParser m (F Blocks)
    blockQuote :: MarkdownParser m (F Blocks)
    blockQuote = do
      [Text]
    raw <- MarkdownParser m [Text]
    forall (m :: * -> *). PandocMonad m => MarkdownParser m [Text]
    emailBlockQuote
      -- parse the extracted block, which may contain various block elements:
      F Blocks
    contents <- MarkdownParser m (F Blocks) -> Text -> MarkdownParser m (F Blocks)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    parseBlocks (Text -> MarkdownParser m (F Blocks))
    -> Text -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Text -> [Text] -> Text
    T.intercalate "\n" [Text]
    raw Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> "\n\n"
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Blocks -> Blocks
    B.blockQuote (Blocks -> Blocks) -> F Blocks -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Blocks
    contents

    --
    -- list blocks
    --

    bulletListStart :: PandocMonad m => MarkdownParser m ()
    bulletListStart :: MarkdownParser m ()
    bulletListStart = MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m () -> MarkdownParser m ())
    -> MarkdownParser m () -> MarkdownParser m ()
    forall a b. (a -> b) -> a -> b
    $ do
      ParsecT Text ParserState m Char -> MarkdownParser m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline -- if preceded by a Plain block in a list context
      MarkdownParser m Int
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
    skipNonindentSpaces
      MarkdownParser m () -> MarkdownParser m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' (() () -> ParsecT Text ParserState m (F Blocks) -> MarkdownParser m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text ParserState m (F Blocks)
    forall (m :: * -> *) st.
    PandocMonad m =>
    ParserT Text st m (F Blocks)
    hrule)     -- because hrules start out just like lists
      (Char -> Bool) -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy Char -> Bool
    isBulletListMarker
      Int -> MarkdownParser m ()
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m ()
    gobbleSpaces 1 MarkdownParser m () -> MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> () () -> ParsecT Text ParserState m Char -> MarkdownParser m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
      MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Int -> MarkdownParser m Int
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m Int
    gobbleAtMostSpaces 3 MarkdownParser m Int -> MarkdownParser m () -> MarkdownParser m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char -> MarkdownParser 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar) MarkdownParser m () -> MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> () -> MarkdownParser m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    orderedListStart :: PandocMonad m
                     => Maybe (ListNumberStyle, ListNumberDelim)
                     -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    orderedListStart :: Maybe (ListNumberStyle, ListNumberDelim)
    -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    orderedListStart mbstydelim :: Maybe (ListNumberStyle, ListNumberDelim)
    mbstydelim = MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
     -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim))
    -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    forall a b. (a -> b) -> a -> b
    $ do
      ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline -- if preceded by a Plain block in a list context
      MarkdownParser m Int
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
    skipNonindentSpaces
      ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char -> ParsecT Text ParserState m ())
    -> ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ [Char] -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "p." ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    digit  -- page number
      (do Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_fancy_lists
          Int
    start <- ParsecT Text ParserState m Char -> ParserT Text ParserState m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    digit ParserT Text ParserState m Text
    -> (Text -> MarkdownParser m Int) -> MarkdownParser m Int
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Text -> MarkdownParser m Int
    forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
    safeRead
          Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '.'
          Int -> ParsecT Text ParserState m ()
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m ()
    gobbleSpaces 1 ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> () ()
    -> ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
          ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional (ParsecT Text ParserState m () -> ParsecT Text ParserState m ())
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Int -> MarkdownParser m Int
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m Int
    gobbleAtMostSpaces 3 MarkdownParser m Int
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar)
          (Int, ListNumberStyle, ListNumberDelim)
    -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Int
    start, ListNumberStyle
    DefaultStyle, ListNumberDelim
    DefaultDelim))
       MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
       (do (num :: Int
    num, style :: ListNumberStyle
    style, delim :: ListNumberDelim
    delim) <- MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    -> ((ListNumberStyle, ListNumberDelim)
        -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim))
    -> Maybe (ListNumberStyle, ListNumberDelim)
    -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe
              MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    forall s (m :: * -> *).
    Stream s m Char =>
    ParserT s ParserState m (Int, ListNumberStyle, ListNumberDelim)
    anyOrderedListMarker
              (\(sty :: ListNumberStyle
    sty,delim :: ListNumberDelim
    delim) -> (\start :: Int
    start -> (Int
    start,ListNumberStyle
    sty,ListNumberDelim
    delim)) (Int -> (Int, ListNumberStyle, ListNumberDelim))
    -> MarkdownParser m Int
    -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                   ListNumberStyle -> ListNumberDelim -> MarkdownParser m Int
    forall s (m :: * -> *).
    Stream s m Char =>
    ListNumberStyle -> ListNumberDelim -> ParserT s ParserState m Int
    orderedListMarker ListNumberStyle
    sty ListNumberDelim
    delim)
              Maybe (ListNumberStyle, ListNumberDelim)
    mbstydelim
           Int -> ParsecT Text ParserState m ()
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m ()
    gobbleSpaces 1 ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> () ()
    -> ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
           -- if it could be an abbreviated first name,
           -- insist on more than one space
           Bool
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    when (ListNumberDelim
    delim ListNumberDelim -> ListNumberDelim -> Bool
    forall a. Eq a => a -> a -> Bool
    == ListNumberDelim
    Period Bool -> Bool -> Bool
    && (ListNumberStyle
    style ListNumberStyle -> ListNumberStyle -> Bool
    forall a. Eq a => a -> a -> Bool
    == ListNumberStyle
    UpperAlpha Bool -> Bool -> Bool
    ||
                (ListNumberStyle
    style ListNumberStyle -> ListNumberStyle -> Bool
    forall a. Eq a => a -> a -> Bool
    == ListNumberStyle
    UpperRoman Bool -> Bool -> Bool
    &&
                 Int
    num Int -> [Int] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [1, 5, 10, 50, 100, 500, 1000]))) (ParsecT Text ParserState m () -> ParsecT Text ParserState m ())
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $
                  () ()
    -> ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar)
           ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional (ParsecT Text ParserState m () -> ParsecT Text ParserState m ())
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Int -> MarkdownParser m Int
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m Int
    gobbleAtMostSpaces 3 MarkdownParser m Int
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar)
           (Int, ListNumberStyle, ListNumberDelim)
    -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Int
    num, ListNumberStyle
    style, ListNumberDelim
    delim))

    listStart :: PandocMonad m => MarkdownParser m ()
    listStart :: MarkdownParser m ()
    listStart = MarkdownParser m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    bulletListStart MarkdownParser m () -> MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m (Int, ListNumberStyle, ListNumberDelim)
    -> MarkdownParser m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    Control.Monad.void (Maybe (ListNumberStyle, ListNumberDelim)
    -> ParsecT
         Text ParserState m (Int, ListNumberStyle, ListNumberDelim)
    forall (m :: * -> *).
    PandocMonad m =>
    Maybe (ListNumberStyle, ListNumberDelim)
    -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    orderedListStart Maybe (ListNumberStyle, ListNumberDelim)
    forall a. Maybe a
    Nothing)

    listLine :: PandocMonad m => Int -> MarkdownParser m Text
    listLine :: Int -> MarkdownParser m Text
    listLine continuationIndent :: Int
    continuationIndent = MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
      ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' (do Int -> ParserT Text ParserState m ()
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m ()
    gobbleSpaces Int
    continuationIndent
                         ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
                         ParserT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    listStart)
      ParserT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    notFollowedByHtmlCloser
      ParserT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    notFollowedByDivCloser
      ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional (() ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Int -> ParserT Text ParserState m ()
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m ()
    gobbleSpaces Int
    continuationIndent)
      MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    listLineCommon

    listLineCommon :: PandocMonad m => MarkdownParser m Text
    listLineCommon :: MarkdownParser m Text
    listLineCommon = [Text] -> Text
    T.concat ([Text] -> Text)
    -> ParsecT Text ParserState m [Text] -> MarkdownParser m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m Text
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Text]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    manyTill
                  (  ParsecT Text ParserState m Char -> MarkdownParser m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char ((Char -> Bool) -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy ((Char -> Bool) -> ParsecT Text ParserState m Char)
    -> (Char -> Bool) -> ParsecT Text ParserState m Char
    forall a b. (a -> b) -> a -> b
    $ \c :: Char
    c -> Char
    c Char -> [Char] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `notElem` ['\n', '<', '`'])
                 MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ((F Inlines, Text) -> Text)
    -> ParsecT Text ParserState m (F Inlines, Text)
    -> MarkdownParser m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (F Inlines, Text) -> Text
    forall a b. (a, b) -> b
    snd (ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines, Text)
    forall (m :: * -> *) st a.
    Monad m =>
    ParsecT Text st m a -> ParsecT Text st m (a, Text)
    withRaw ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    code)
                 MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ((Tag Text, Text) -> Text)
    -> ParsecT Text ParserState m (Tag Text, Text)
    -> MarkdownParser m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (Tag Text, Text) -> Text
    forall a b. (a, b) -> b
    snd ((Tag Text -> Bool) -> ParsecT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag Tag Text -> Bool
    forall a. Tag a -> Bool
    isCommentTag)
                 MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Int -> ParsecT Text ParserState m Char -> MarkdownParser m Text
    forall s (m :: * -> *) st.
    (Stream s m Char, Monad m) =>
    Int -> ParsecT s st m Char -> ParsecT s st m Text
    countChar 1 ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    anyChar
                  ) ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline

    -- parse raw text for one list item, excluding start marker and continuations
    rawListItem :: PandocMonad m
                => Bool -- four space rule
                -> MarkdownParser m a
                -> MarkdownParser m (Text, Int)
    rawListItem :: Bool -> MarkdownParser m a -> MarkdownParser m (Text, Int)
    rawListItem fourSpaceRule :: Bool
    fourSpaceRule start :: MarkdownParser m a
    start = MarkdownParser m (Text, Int) -> MarkdownParser m (Text, Int)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (Text, Int) -> MarkdownParser m (Text, Int))
    -> MarkdownParser m (Text, Int) -> MarkdownParser m (Text, Int)
    forall a b. (a -> b) -> a -> b
    $ do
      SourcePos
    pos1 <- ParsecT Text ParserState m SourcePos
    forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
    getPosition
      MarkdownParser m a
    start
      SourcePos
    pos2 <- ParsecT Text ParserState m SourcePos
    forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
    getPosition
      let continuationIndent :: Int
    continuationIndent = if Bool
    fourSpaceRule
                                  then 4
                                  else SourcePos -> Int
    sourceColumn SourcePos
    pos2 Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - SourcePos -> Int
    sourceColumn SourcePos
    pos1
      Text
    first <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    listLineCommon
      [Text]
    rest <- MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (do ParsecT Text ParserState m () -> ParsecT Text ParserState 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 ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    listStart
                       ParsecT Text ParserState m () -> ParsecT Text ParserState 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 ParserState m (F Blocks)
    -> ParsecT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text ParserState m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    codeBlockFenced)
                       ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
                       Int -> MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m Text
    listLine Int
    continuationIndent)
      Text
    blanks <- ParsecT Text ParserState m Char -> MarkdownParser m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    manyChar ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
      let result :: Text
    result = [Text] -> Text
    T.unlines (Text
    firstText -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    :[Text]
    rest) Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    blanks
      (Text, Int) -> MarkdownParser m (Text, Int)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text
    result, Int
    continuationIndent)

    -- continuation of a list item - indented and separated by blankline
    -- or (in compact lists) endline.
    -- note: nested lists are parsed as continuations
    listContinuation :: PandocMonad m => Int -> MarkdownParser m Text
    listContinuation :: Int -> MarkdownParser m Text
    listContinuation continuationIndent :: Int
    continuationIndent = MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    x <- MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
             ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
             ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    notFollowedByHtmlCloser
             ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    notFollowedByDivCloser
             Int -> ParsecT Text ParserState m ()
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m ()
    gobbleSpaces Int
    continuationIndent
             MarkdownParser m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLineNewline
      [Text]
    xs <- MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (MarkdownParser m Text -> ParsecT Text ParserState m [Text])
    -> MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
             ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
             ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    notFollowedByHtmlCloser
             ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    notFollowedByDivCloser
             Int -> ParsecT Text ParserState m ()
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m ()
    gobbleSpaces Int
    continuationIndent ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    listStart
             MarkdownParser m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLineNewline
      Text
    blanks <- ParsecT Text ParserState m Char -> MarkdownParser m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    manyChar ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
      Text -> MarkdownParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> MarkdownParser m Text) -> Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ [Text] -> Text
    T.concat (Text
    xText -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    :[Text]
    xs) Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    blanks

    -- Variant of blanklines that doesn't require blank lines
    -- before a fence or eof.
    blanklines' :: PandocMonad m => MarkdownParser m Text
    blanklines' :: MarkdownParser m Text
    blanklines' = MarkdownParser m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try MarkdownParser m Text
    checkDivCloser
      where checkDivCloser :: MarkdownParser m Text
    checkDivCloser = do
              Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_fenced_divs
              Int
    divLevel <- ParserState -> Int
    stateFencedDivLevel (ParserState -> Int)
    -> ParsecT Text ParserState m ParserState
    -> ParsecT Text ParserState m Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
              Bool -> ParserT Text ParserState m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Int
    divLevel Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    >= 1)
              ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead ParserT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    divFenceEnd
              Text -> MarkdownParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return ""

    notFollowedByDivCloser :: PandocMonad m => MarkdownParser m ()
    notFollowedByDivCloser :: MarkdownParser m ()
    notFollowedByDivCloser =
      Extension -> MarkdownParser m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_fenced_divs MarkdownParser m () -> MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
      do Int
    divLevel <- ParserState -> Int
    stateFencedDivLevel (ParserState -> Int)
    -> ParsecT Text ParserState m ParserState
    -> ParsecT Text ParserState m Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
         Bool -> MarkdownParser m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Int
    divLevel Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < 1) MarkdownParser m () -> MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m () -> MarkdownParser m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy MarkdownParser m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    divFenceEnd

    notFollowedByHtmlCloser :: PandocMonad m => MarkdownParser m ()
    notFollowedByHtmlCloser :: MarkdownParser m ()
    notFollowedByHtmlCloser = do
      Maybe Text
    inHtmlBlock <- ParserState -> Maybe Text
    stateInHtmlBlock (ParserState -> Maybe Text)
    -> ParsecT Text ParserState m ParserState
    -> ParsecT Text ParserState m (Maybe Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      case Maybe Text
    inHtmlBlock of
            Just t :: Text
    t  -> ParserT Text ParserState m (Tag Text, Text) -> MarkdownParser 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 ParserState m (Tag Text, Text)
     -> MarkdownParser m ())
    -> ParserT Text ParserState m (Tag Text, Text)
    -> MarkdownParser m ()
    forall a b. (a -> b) -> a -> b
    $ (Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag (Tag Text -> Tag Text -> Bool
    forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
    ~== Text -> Tag Text
    forall str. str -> Tag str
    TagClose Text
    t)
            Nothing -> () -> MarkdownParser m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    listItem :: PandocMonad m
             => Bool -- four-space rule
             -> MarkdownParser m a
             -> MarkdownParser m (F Blocks)
    listItem :: Bool -> MarkdownParser m a -> MarkdownParser m (F Blocks)
    listItem fourSpaceRule :: Bool
    fourSpaceRule start :: MarkdownParser m a
    start = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      -- parsing with ListItemState forces markers at beginning of lines to
      -- count as list item markers, even if not separated by blank space.
      -- see definition of "endline"
      ParserState
    state <- ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      let oldContext :: ParserContext
    oldContext = ParserState -> ParserContext
    stateParserContext ParserState
    state
      ParserState -> ParsecT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => u -> ParsecT s u m ()
    setState (ParserState -> ParsecT Text ParserState m ())
    -> ParserState -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ ParserState
    state {stateParserContext :: ParserContext
    stateParserContext = ParserContext
    ListItemState}
      (first :: Text
    first, continuationIndent :: Int
    continuationIndent) <- Bool -> MarkdownParser m a -> MarkdownParser m (Text, Int)
    forall (m :: * -> *) a.
    PandocMonad m =>
    Bool -> MarkdownParser m a -> MarkdownParser m (Text, Int)
    rawListItem Bool
    fourSpaceRule MarkdownParser m a
    start
      [Text]
    continuations <- ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (Int -> ParsecT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m Text
    listContinuation Int
    continuationIndent)
      -- parse the extracted block, which may contain various block elements:
      let raw :: Text
    raw = [Text] -> Text
    T.concat (Text
    firstText -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    :[Text]
    continuations)
      F Blocks
    contents <- MarkdownParser m (F Blocks) -> Text -> MarkdownParser m (F Blocks)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    parseBlocks Text
    raw
      (ParserState -> ParserState) -> ParsecT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState (\st :: ParserState
    st -> ParserState
    st {stateParserContext :: ParserContext
    stateParserContext = ParserContext
    oldContext})
      Extensions
    exts <- (ReaderOptions -> Extensions)
    -> ParserT Text ParserState 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
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ [Block] -> Blocks
    forall a. [a] -> Many a
    B.fromList ([Block] -> Blocks) -> (Blocks -> [Block]) -> Blocks -> Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Extensions -> [Block] -> [Block]
    taskListItemFromAscii Extensions
    exts ([Block] -> [Block]) -> (Blocks -> [Block]) -> Blocks -> [Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Blocks -> [Block]
    forall a. Many a -> [a]
    B.toList (Blocks -> Blocks) -> F Blocks -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Blocks
    contents

    orderedList :: PandocMonad m => MarkdownParser m (F Blocks)
    orderedList :: MarkdownParser m (F Blocks)
    orderedList = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      (start :: Int
    start, style :: ListNumberStyle
    style, delim :: ListNumberDelim
    delim) <- ParsecT Text ParserState m (Int, ListNumberStyle, ListNumberDelim)
    -> ParsecT
         Text ParserState m (Int, ListNumberStyle, ListNumberDelim)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead (Maybe (ListNumberStyle, ListNumberDelim)
    -> ParsecT
         Text ParserState m (Int, ListNumberStyle, ListNumberDelim)
    forall (m :: * -> *).
    PandocMonad m =>
    Maybe (ListNumberStyle, ListNumberDelim)
    -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    orderedListStart Maybe (ListNumberStyle, ListNumberDelim)
    forall a. Maybe a
    Nothing)
      Bool
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    unless (ListNumberStyle
    style ListNumberStyle -> [ListNumberStyle] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [ListNumberStyle
    DefaultStyle, ListNumberStyle
    Decimal, ListNumberStyle
    Example] Bool -> Bool -> Bool
    &&
              ListNumberDelim
    delim ListNumberDelim -> [ListNumberDelim] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [ListNumberDelim
    DefaultDelim, ListNumberDelim
    Period]) (ParsecT Text ParserState m () -> ParsecT Text ParserState m ())
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $
        Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_fancy_lists
      Bool
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    when (ListNumberStyle
    style ListNumberStyle -> ListNumberStyle -> Bool
    forall a. Eq a => a -> a -> Bool
    == ListNumberStyle
    Example) (ParsecT Text ParserState m () -> ParsecT Text ParserState m ())
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_example_lists
      Bool
    fourSpaceRule <- (Bool
    True Bool
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m Bool
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_four_space_rule)
                   ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Bool -> ParsecT Text ParserState m Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return (ListNumberStyle
    style ListNumberStyle -> ListNumberStyle -> Bool
    forall a. Eq a => a -> a -> Bool
    == ListNumberStyle
    Example)
      Future ParserState [Blocks]
    items <- ([F Blocks] -> Future ParserState [Blocks])
    -> ParsecT Text ParserState m [F Blocks]
    -> ParsecT Text ParserState m (Future ParserState [Blocks])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [F Blocks] -> Future ParserState [Blocks]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence (ParsecT Text ParserState m [F Blocks]
     -> ParsecT Text ParserState m (Future ParserState [Blocks]))
    -> ParsecT Text ParserState m [F Blocks]
    -> ParsecT Text ParserState m (Future ParserState [Blocks])
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m (F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (MarkdownParser m (F Blocks)
     -> ParsecT Text ParserState m [F Blocks])
    -> MarkdownParser m (F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    forall a b. (a -> b) -> a -> b
    $ Bool
    -> ParsecT
         Text ParserState m (Int, ListNumberStyle, ListNumberDelim)
    -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a.
    PandocMonad m =>
    Bool -> MarkdownParser m a -> MarkdownParser m (F Blocks)
    listItem Bool
    fourSpaceRule
                     (Maybe (ListNumberStyle, ListNumberDelim)
    -> ParsecT
         Text ParserState m (Int, ListNumberStyle, ListNumberDelim)
    forall (m :: * -> *).
    PandocMonad m =>
    Maybe (ListNumberStyle, ListNumberDelim)
    -> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
    orderedListStart ((ListNumberStyle, ListNumberDelim)
    -> Maybe (ListNumberStyle, ListNumberDelim)
    forall a. a -> Maybe a
    Just (ListNumberStyle
    style, ListNumberDelim
    delim)))
      Int
    start' <- if ListNumberStyle
    style ListNumberStyle -> ListNumberStyle -> Bool
    forall a. Eq a => a -> a -> Bool
    == ListNumberStyle
    Example
                   then Int -> ParsecT Text ParserState m Int
    forall (m :: * -> *) a. Monad m => a -> m a
    return Int
    start
                   else (Int
    start Int
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m Int
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_startnum) ParsecT Text ParserState m Int
    -> ParsecT Text ParserState m Int -> ParsecT Text ParserState m Int
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Int -> ParsecT Text ParserState m Int
    forall (m :: * -> *) a. Monad m => a -> m a
    return 1
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ (Int, ListNumberStyle, ListNumberDelim) -> [Blocks] -> Blocks
    B.orderedListWith (Int
    start', ListNumberStyle
    style, ListNumberDelim
    delim) ([Blocks] -> Blocks) -> Future ParserState [Blocks] -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ([Blocks] -> [Blocks])
    -> Future ParserState [Blocks] -> Future ParserState [Blocks]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Blocks] -> [Blocks]
    compactify Future ParserState [Blocks]
    items

    bulletList :: PandocMonad m => MarkdownParser m (F Blocks)
    bulletList :: MarkdownParser m (F Blocks)
    bulletList = do
      Bool
    fourSpaceRule <- (Bool
    True Bool
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m Bool
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_four_space_rule)
                   ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Bool -> ParsecT Text ParserState m Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    False
      Future ParserState [Blocks]
    items <- ([F Blocks] -> Future ParserState [Blocks])
    -> ParsecT Text ParserState m [F Blocks]
    -> ParsecT Text ParserState m (Future ParserState [Blocks])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [F Blocks] -> Future ParserState [Blocks]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence (ParsecT Text ParserState m [F Blocks]
     -> ParsecT Text ParserState m (Future ParserState [Blocks]))
    -> ParsecT Text ParserState m [F Blocks]
    -> ParsecT Text ParserState m (Future ParserState [Blocks])
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m (F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (MarkdownParser m (F Blocks)
     -> ParsecT Text ParserState m [F Blocks])
    -> MarkdownParser m (F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    forall a b. (a -> b) -> a -> b
    $ Bool
    -> ParsecT Text ParserState m () -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a.
    PandocMonad m =>
    Bool -> MarkdownParser m a -> MarkdownParser m (F Blocks)
    listItem Bool
    fourSpaceRule ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    bulletListStart
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ [Blocks] -> Blocks
    B.bulletList ([Blocks] -> Blocks) -> Future ParserState [Blocks] -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ([Blocks] -> [Blocks])
    -> Future ParserState [Blocks] -> Future ParserState [Blocks]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Blocks] -> [Blocks]
    compactify Future ParserState [Blocks]
    items

    -- definition lists

    defListMarker :: PandocMonad m => MarkdownParser m ()
    defListMarker :: MarkdownParser m ()
    defListMarker = do
      Text
    sps <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    nonindentSpaces
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':' ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '~'
      Int
    tabStop <- (ReaderOptions -> Int) -> ParserT Text ParserState m Int
    forall st s (m :: * -> *) t b.
    (HasReaderOptions st, Stream s m t) =>
    (ReaderOptions -> b) -> ParserT s st m b
    getOption ReaderOptions -> Int
    readerTabStop
      let remaining :: Int
    remaining = Int
    tabStop Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - (Text -> Int
    T.length Text
    sps Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + 1)
      if Int
    remaining Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > 0
         then ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Int
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState 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
    remaining (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ' ')) ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState 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 ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "\t" ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
         else ParsecT Text ParserState m [Char]
    forall (m :: * -> *) a. MonadPlus m => m a
    mzero
      () -> MarkdownParser m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    definitionListItem :: PandocMonad m => Bool -> MarkdownParser m (F (Inlines, [Blocks]))
    definitionListItem :: Bool -> MarkdownParser m (F (Inlines, [Blocks]))
    definitionListItem compact :: Bool
    compact = MarkdownParser m (F (Inlines, [Blocks]))
    -> MarkdownParser m (F (Inlines, [Blocks]))
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F (Inlines, [Blocks]))
     -> MarkdownParser m (F (Inlines, [Blocks])))
    -> MarkdownParser m (F (Inlines, [Blocks]))
    -> MarkdownParser m (F (Inlines, [Blocks]))
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    rawLine' <- ParserT Text ParserState m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine
      [Text]
    raw <- ParserT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (ParserT Text ParserState m Text
     -> ParsecT Text ParserState m [Text])
    -> ParserT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall a b. (a -> b) -> a -> b
    $ Bool -> ParserT Text ParserState m Text
    forall (m :: * -> *).
    PandocMonad m =>
    Bool -> MarkdownParser m Text
    defRawBlock Bool
    compact
      F Inlines
    term <- ParserT Text ParserState m (F Inlines)
    -> Text -> ParserT Text ParserState m (F Inlines)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' (F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> F Inlines)
    -> ParserT Text ParserState m (F Inlines)
    -> ParserT Text ParserState m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParserT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlines) Text
    rawLine'
      [F Blocks]
    contents <- (Text -> ParsecT Text ParserState m (F Blocks))
    -> [Text] -> ParsecT Text ParserState m [F Blocks]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM (ParsecT Text ParserState m (F Blocks)
    -> Text -> ParsecT Text ParserState m (F Blocks)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' ParsecT Text ParserState m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    parseBlocks (Text -> ParsecT Text ParserState m (F Blocks))
    -> (Text -> Text) -> Text -> ParsecT Text ParserState m (F Blocks)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> "\n")) [Text]
    raw
      ParserT Text ParserState m Text -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParserT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      F (Inlines, [Blocks]) -> MarkdownParser m (F (Inlines, [Blocks]))
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F (Inlines, [Blocks]) -> MarkdownParser m (F (Inlines, [Blocks])))
    -> F (Inlines, [Blocks])
    -> MarkdownParser m (F (Inlines, [Blocks]))
    forall a b. (a -> b) -> a -> b
    $ (Inlines -> [Blocks] -> (Inlines, [Blocks]))
    -> F Inlines
    -> Future ParserState [Blocks]
    -> F (Inlines, [Blocks])
    forall (m :: * -> *) a1 a2 r.
    Monad m =>
    (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
    liftM2 (,) F Inlines
    term ([F Blocks] -> Future ParserState [Blocks]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence [F Blocks]
    contents)

    defRawBlock :: PandocMonad m => Bool -> MarkdownParser m Text
    defRawBlock :: Bool -> MarkdownParser m Text
    defRawBlock compact :: Bool
    compact = MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
      Bool
    hasBlank <- Bool
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState 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 ParserState m Bool
     -> ParsecT Text ParserState m Bool)
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    forall a b. (a -> b) -> a -> b
    $ ParserT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline ParserT Text ParserState m Char
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Bool -> ParsecT Text ParserState m Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    True
      MarkdownParser m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    defListMarker
      Text
    firstline <- MarkdownParser m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLineNewline
      let dline :: MarkdownParser m Text
    dline = MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try
                   ( do ParserT Text ParserState m Char -> MarkdownParser m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy ParserT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
                        MarkdownParser m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    notFollowedByHtmlCloser
                        MarkdownParser m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    notFollowedByDivCloser
                        if Bool
    compact -- laziness not compatible with compact
                           then () () -> MarkdownParser m Text -> MarkdownParser m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    indentSpaces
                           else (() () -> MarkdownParser m Text -> MarkdownParser m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    indentSpaces)
                                 MarkdownParser m () -> MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m () -> MarkdownParser m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy MarkdownParser m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    defListMarker
                        MarkdownParser m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine )
      [Text]
    rawlines <- MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many MarkdownParser m Text
    dline
      Text
    cont <- ([Text] -> Text)
    -> ParsecT Text ParserState m [Text] -> MarkdownParser m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Text] -> Text
    T.concat (ParsecT Text ParserState m [Text] -> MarkdownParser m Text)
    -> ParsecT Text ParserState m [Text] -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (MarkdownParser m Text -> ParsecT Text ParserState m [Text])
    -> MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
                Text
    trailing <- Text -> MarkdownParser m Text -> MarkdownParser m Text
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option "" MarkdownParser m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
                Text
    ln <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    indentSpaces MarkdownParser m Text -> MarkdownParser m () -> MarkdownParser m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParserT Text ParserState m Char -> MarkdownParser m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy ParserT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline MarkdownParser m ()
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine
                [Text]
    lns <- MarkdownParser m Text -> ParsecT Text ParserState m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many MarkdownParser m Text
    dline
                Text -> MarkdownParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> MarkdownParser m Text) -> Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ Text
    trailing Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> [Text] -> Text
    T.unlines (Text
    lnText -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    :[Text]
    lns)
      Text -> MarkdownParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> MarkdownParser m Text) -> Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    trimr (Text
    firstline Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> [Text] -> Text
    T.unlines [Text]
    rawlines Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    cont) Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>
                if Bool
    hasBlank Bool -> Bool -> Bool
    || Bool -> Bool
    not (Text -> Bool
    T.null Text
    cont) then "\n\n" else ""

    definitionList :: PandocMonad m => MarkdownParser m (F Blocks)
    definitionList :: MarkdownParser m (F Blocks)
    definitionList = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead (ParserT Text ParserState m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine ParserT Text ParserState m Text
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                 ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional (ParserT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline ParserT Text ParserState m Char
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy (MarkdownParser m (F Blocks) -> ParsecT Text ParserState m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    Control.Monad.void MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    table)) ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                 -- don't capture table caption as def list!
                 ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    defListMarker)
      MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    compactDefinitionList MarkdownParser m (F Blocks)
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    normalDefinitionList

    compactDefinitionList :: PandocMonad m => MarkdownParser m (F Blocks)
    compactDefinitionList :: MarkdownParser m (F Blocks)
    compactDefinitionList = do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_compact_definition_lists
      Future ParserState [(Inlines, [Blocks])]
    items <- ([F (Inlines, [Blocks])]
     -> Future ParserState [(Inlines, [Blocks])])
    -> ParsecT Text ParserState m [F (Inlines, [Blocks])]
    -> ParsecT
         Text ParserState m (Future ParserState [(Inlines, [Blocks])])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [F (Inlines, [Blocks])] -> Future ParserState [(Inlines, [Blocks])]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence (ParsecT Text ParserState m [F (Inlines, [Blocks])]
     -> ParsecT
          Text ParserState m (Future ParserState [(Inlines, [Blocks])]))
    -> ParsecT Text ParserState m [F (Inlines, [Blocks])]
    -> ParsecT
         Text ParserState m (Future ParserState [(Inlines, [Blocks])])
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m (F (Inlines, [Blocks]))
    -> ParsecT Text ParserState m [F (Inlines, [Blocks])]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (ParsecT Text ParserState m (F (Inlines, [Blocks]))
     -> ParsecT Text ParserState m [F (Inlines, [Blocks])])
    -> ParsecT Text ParserState m (F (Inlines, [Blocks]))
    -> ParsecT Text ParserState m [F (Inlines, [Blocks])]
    forall a b. (a -> b) -> a -> b
    $ Bool -> ParsecT Text ParserState m (F (Inlines, [Blocks]))
    forall (m :: * -> *).
    PandocMonad m =>
    Bool -> MarkdownParser m (F (Inlines, [Blocks]))
    definitionListItem Bool
    True
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ [(Inlines, [Blocks])] -> Blocks
    B.definitionList ([(Inlines, [Blocks])] -> Blocks)
    -> Future ParserState [(Inlines, [Blocks])] -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ([(Inlines, [Blocks])] -> [(Inlines, [Blocks])])
    -> Future ParserState [(Inlines, [Blocks])]
    -> Future ParserState [(Inlines, [Blocks])]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
    compactifyDL Future ParserState [(Inlines, [Blocks])]
    items

    normalDefinitionList :: PandocMonad m => MarkdownParser m (F Blocks)
    normalDefinitionList :: MarkdownParser m (F Blocks)
    normalDefinitionList = do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_definition_lists
      Future ParserState [(Inlines, [Blocks])]
    items <- ([F (Inlines, [Blocks])]
     -> Future ParserState [(Inlines, [Blocks])])
    -> ParsecT Text ParserState m [F (Inlines, [Blocks])]
    -> ParsecT
         Text ParserState m (Future ParserState [(Inlines, [Blocks])])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [F (Inlines, [Blocks])] -> Future ParserState [(Inlines, [Blocks])]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence (ParsecT Text ParserState m [F (Inlines, [Blocks])]
     -> ParsecT
          Text ParserState m (Future ParserState [(Inlines, [Blocks])]))
    -> ParsecT Text ParserState m [F (Inlines, [Blocks])]
    -> ParsecT
         Text ParserState m (Future ParserState [(Inlines, [Blocks])])
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m (F (Inlines, [Blocks]))
    -> ParsecT Text ParserState m [F (Inlines, [Blocks])]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (ParsecT Text ParserState m (F (Inlines, [Blocks]))
     -> ParsecT Text ParserState m [F (Inlines, [Blocks])])
    -> ParsecT Text ParserState m (F (Inlines, [Blocks]))
    -> ParsecT Text ParserState m [F (Inlines, [Blocks])]
    forall a b. (a -> b) -> a -> b
    $ Bool -> ParsecT Text ParserState m (F (Inlines, [Blocks]))
    forall (m :: * -> *).
    PandocMonad m =>
    Bool -> MarkdownParser m (F (Inlines, [Blocks]))
    definitionListItem Bool
    False
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ [(Inlines, [Blocks])] -> Blocks
    B.definitionList ([(Inlines, [Blocks])] -> Blocks)
    -> Future ParserState [(Inlines, [Blocks])] -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Future ParserState [(Inlines, [Blocks])]
    items

    --
    -- paragraph block
    --

    para :: PandocMonad m => MarkdownParser m (F Blocks)
    para :: MarkdownParser m (F Blocks)
    para = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      Extensions
    exts <- (ReaderOptions -> Extensions)
    -> ParserT Text ParserState 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
      let implicitFigures :: m Inlines -> m Inlines
    implicitFigures x :: m Inlines
    x
           | Extension -> Extensions -> Bool
    extensionEnabled Extension
    Ext_implicit_figures Extensions
    exts = do
             Inlines
    x' <- m Inlines
    x
             case Inlines -> [Inline]
    forall a. Many a -> [a]
    B.toList Inlines
    x' of
                   [Image attr :: Attr
    attr alt :: [Inline]
    alt (src :: Text
    src,tit :: Text
    tit)]
                     | Bool -> Bool
    not ([Inline] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [Inline]
    alt) ->
                        -- the fig: at beginning of title indicates a figure
                        Inlines -> m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> m Inlines) -> Inlines -> m Inlines
    forall a b. (a -> b) -> a -> b
    $ Inline -> Inlines
    forall a. a -> Many a
    B.singleton
                               (Inline -> Inlines) -> Inline -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Attr -> [Inline] -> (Text, Text) -> Inline
    Image Attr
    attr [Inline]
    alt (Text
    src, "fig:" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    tit)
                   _ -> Inlines -> m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    x'
           | Bool
    otherwise = m Inlines
    x
      F Inlines
    result <- F Inlines -> F Inlines
    forall (m :: * -> *). Monad m => m Inlines -> m Inlines
    implicitFigures (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)
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlines1
      F Blocks
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option (Inlines -> Blocks
    B.plain (Inlines -> Blocks) -> F Inlines -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    result)
        (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
                ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
                (ParserT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines ParserT Text ParserState m Text
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
    forall a. Monoid a => a
    mempty)
                  ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_blank_before_blockquote ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> () () -> MarkdownParser m (F Blocks) -> ParsecT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    blockQuote)
                  ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_backtick_code_blocks ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> () () -> MarkdownParser m (F Blocks) -> ParsecT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    codeBlockFenced)
                  ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_blank_before_header ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> () () -> MarkdownParser m (F Blocks) -> ParsecT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    header)
                  ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_lists_without_preceding_blankline ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                           -- Avoid creating a paragraph in a nested list.
                           ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    inList ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                           () ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    listStart)
                  ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> do Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_native_divs
                         Maybe Text
    inHtmlBlock <- ParserState -> Maybe Text
    stateInHtmlBlock (ParserState -> Maybe Text)
    -> ParsecT Text ParserState m ParserState
    -> ParsecT Text ParserState m (Maybe Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
                         case Maybe Text
    inHtmlBlock of
                              Just "div" -> () ()
    -> ParsecT Text ParserState m (Tag Text, Text)
    -> ParsecT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$
                                           ParsecT Text ParserState m (Tag Text, Text)
    -> ParsecT Text ParserState m (Tag Text, Text)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead ((Tag Text -> Bool) -> ParsecT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag (Tag Text -> Tag Text -> Bool
    forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
    ~== Text -> Tag Text
    forall str. str -> Tag str
    TagClose ("div" :: Text)))
                              _          -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a. MonadPlus m => m a
    mzero
                  ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> do Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_fenced_divs
                         Int
    divLevel <- ParserState -> Int
    stateFencedDivLevel (ParserState -> Int)
    -> ParsecT Text ParserState m ParserState
    -> ParsecT Text ParserState m Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
                         if Int
    divLevel Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > 0
                            then ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    divFenceEnd
                            else ParsecT Text ParserState m ()
    forall (m :: * -> *) a. MonadPlus m => m a
    mzero
                F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Inlines -> Blocks
    B.para (Inlines -> Blocks) -> F Inlines -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    result

    plain :: PandocMonad m => MarkdownParser m (F Blocks)
    plain :: MarkdownParser m (F Blocks)
    plain = (Inlines -> Blocks) -> F Inlines -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Inlines -> Blocks
    B.plain (F Inlines -> F Blocks)
    -> (F Inlines -> F Inlines) -> F Inlines -> F 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 Blocks)
    -> ParsecT Text ParserState m (F Inlines)
    -> MarkdownParser m (F Blocks)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlines1

    --
    -- raw html
    --

    htmlElement :: PandocMonad m => MarkdownParser m Text
    htmlElement :: MarkdownParser m Text
    htmlElement = MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    rawVerbatimBlock
              MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    strictHtmlBlock
              MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ((Tag Text, Text) -> Text)
    -> ParsecT Text ParserState m (Tag Text, Text)
    -> MarkdownParser m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (Tag Text, Text) -> Text
    forall a b. (a, b) -> b
    snd ((Tag Text -> Bool) -> ParsecT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag Tag Text -> Bool
    forall a. NamedTag (Tag a) => Tag a -> Bool
    isBlockTag)

    htmlBlock :: PandocMonad m => MarkdownParser m (F Blocks)
    htmlBlock :: MarkdownParser m (F Blocks)
    htmlBlock = do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_raw_html
      MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (do
          (TagOpen _ attrs :: [(Text, Text)]
    attrs) <- ParsecT Text ParserState m (Tag Text)
    -> ParsecT Text ParserState m (Tag Text)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead (ParsecT Text ParserState m (Tag Text)
     -> ParsecT Text ParserState m (Tag Text))
    -> ParsecT Text ParserState m (Tag Text)
    -> ParsecT Text ParserState m (Tag Text)
    forall a b. (a -> b) -> a -> b
    $ (Tag Text, Text) -> Tag Text
    forall a b. (a, b) -> a
    fst ((Tag Text, Text) -> Tag Text)
    -> ParsecT Text ParserState m (Tag Text, Text)
    -> ParsecT Text ParserState m (Tag Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Tag Text -> Bool) -> ParsecT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag Tag Text -> Bool
    forall a. NamedTag (Tag a) => Tag a -> Bool
    isBlockTag
          (Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> F Blocks) -> (Text -> Blocks) -> Text -> F Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text -> Blocks
    B.rawBlock "html") (Text -> F Blocks)
    -> ParsecT Text ParserState m Text -> MarkdownParser m (F Blocks)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    rawVerbatimBlock
            MarkdownParser m (F Blocks)
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (do Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_markdown_attribute
                    Bool
    oldMarkdownAttribute <- ParserState -> Bool
    stateMarkdownAttribute (ParserState -> Bool)
    -> ParsecT Text ParserState m ParserState
    -> ParsecT Text ParserState m Bool
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
                    Bool
    markdownAttribute <-
                       case Text -> [(Text, Text)] -> Maybe Text
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup "markdown" [(Text, Text)]
    attrs of
                            Just "0" -> Bool
    False Bool
    -> ParserT Text ParserState m () -> ParsecT Text ParserState m Bool
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState (\st :: ParserState
    st -> ParserState
    st{
                                           stateMarkdownAttribute :: Bool
    stateMarkdownAttribute = Bool
    False })
                            Just _   -> Bool
    True Bool
    -> ParserT Text ParserState m () -> ParsecT Text ParserState m Bool
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState (\st :: ParserState
    st -> ParserState
    st{
                                           stateMarkdownAttribute :: Bool
    stateMarkdownAttribute = Bool
    True })
                            Nothing  -> Bool -> ParsecT Text ParserState m Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    oldMarkdownAttribute
                    F Blocks
    res <- if Bool
    markdownAttribute
                              then MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    rawHtmlBlocks
                              else MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    htmlBlock'
                    (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParserT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateMarkdownAttribute :: Bool
    stateMarkdownAttribute =
                                             Bool
    oldMarkdownAttribute }
                    F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Blocks
    res)
            MarkdownParser m (F Blocks)
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_markdown_in_html_blocks ParserT Text ParserState m ()
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    rawHtmlBlocks))
        MarkdownParser m (F Blocks)
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    htmlBlock'

    htmlBlock' :: PandocMonad m => MarkdownParser m (F Blocks)
    htmlBlock' :: MarkdownParser m (F Blocks)
    htmlBlock' = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
        Text
    first <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    htmlElement
        ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
        MarkdownParser m Text -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional MarkdownParser m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
        F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ if Text -> Bool
    T.null Text
    first
                    then F Blocks
    forall a. Monoid a => a
    mempty
                    else Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> F Blocks) -> Blocks -> F Blocks
    forall a b. (a -> b) -> a -> b
    $ Text -> Text -> Blocks
    B.rawBlock "html" Text
    first

    strictHtmlBlock :: PandocMonad m => MarkdownParser m Text
    strictHtmlBlock :: MarkdownParser m Text
    strictHtmlBlock = (Tag Text -> Bool) -> MarkdownParser m Text
    forall (m :: * -> *) st.
    Monad m =>
    (Tag Text -> Bool) -> ParserT Text st m Text
    htmlInBalanced (Bool -> Bool
    not (Bool -> Bool) -> (Tag Text -> Bool) -> Tag Text -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Tag Text -> Bool
    forall a. NamedTag (Tag a) => Tag a -> Bool
    isInlineTag)

    rawVerbatimBlock :: PandocMonad m => MarkdownParser m Text
    rawVerbatimBlock :: MarkdownParser m Text
    rawVerbatimBlock = (Tag Text -> Bool) -> MarkdownParser m Text
    forall (m :: * -> *) st.
    Monad m =>
    (Tag Text -> Bool) -> ParserT Text st m Text
    htmlInBalanced Tag Text -> Bool
    forall a. (Eq a, IsString a) => Tag a -> Bool
    isVerbTag
      where isVerbTag :: Tag a -> Bool
    isVerbTag (TagOpen "pre" _)      = Bool
    True
            isVerbTag (TagOpen "style" _)    = Bool
    True
            isVerbTag (TagOpen "script" _)   = Bool
    True
            isVerbTag (TagOpen "textarea" _) = Bool
    True
            isVerbTag _                      = Bool
    False

    rawTeXBlock :: PandocMonad m => MarkdownParser m (F Blocks)
    rawTeXBlock :: MarkdownParser m (F Blocks)
    rawTeXBlock = do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_raw_tex
      Blocks
    result <- (Text -> Text -> Blocks
    B.rawBlock "tex" (Text -> Blocks) -> ([Text] -> Text) -> [Text] -> Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text
    trim (Text -> Text) -> ([Text] -> Text) -> [Text] -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Text] -> Text
    T.concat ([Text] -> Blocks)
    -> ParsecT Text ParserState m [Text]
    -> ParsecT Text ParserState m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                    ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    (<>) (Text -> Text -> Text)
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m (Text -> Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Text
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Text
    rawConTeXtEnvironment ParsecT Text ParserState m (Text -> Text)
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Text ParserState m Text
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Text
    spnl'))
              ParsecT Text ParserState m Blocks
    -> ParsecT Text ParserState m Blocks
    -> ParsecT Text ParserState m Blocks
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Text -> Text -> Blocks
    B.rawBlock "tex" (Text -> Blocks) -> ([Text] -> Text) -> [Text] -> Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text
    trim (Text -> Text) -> ([Text] -> Text) -> [Text] -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Text] -> Text
    T.concat ([Text] -> Blocks)
    -> ParsecT Text ParserState m [Text]
    -> ParsecT Text ParserState m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                    ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    (<>) (Text -> Text -> Text)
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m (Text -> Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Text
    forall (m :: * -> *) s.
    (PandocMonad m, HasMacros s, HasReaderOptions s) =>
    ParserT Text s m Text
    rawLaTeXBlock ParsecT Text ParserState m (Text -> Text)
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Text ParserState m Text
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Text
    spnl'))
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ case Blocks -> [Block]
    forall a. Many a -> [a]
    B.toList Blocks
    result of
                    [RawBlock _ cs :: Text
    cs]
                      | (Char -> Bool) -> Text -> Bool
    T.all (Char -> [Char] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [' ','\t','\n']) Text
    cs -> Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    forall a. Monoid a => a
    mempty
                    -- don't create a raw block for suppressed macro defs
                    _ -> Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    result

    rawHtmlBlocks :: PandocMonad m => MarkdownParser m (F Blocks)
    rawHtmlBlocks :: MarkdownParser m (F Blocks)
    rawHtmlBlocks = do
      (TagOpen tagtype :: Text
    tagtype _, raw :: Text
    raw) <- (Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag Tag Text -> Bool
    forall a. NamedTag (Tag a) => Tag a -> Bool
    isBlockTag
      -- we don't want '<td>    text' to be a code block:
      ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
      Int
    indentlevel <- (ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Int -> ParsecT Text ParserState m Int
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> [Char] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length ([Char] -> Int)
    -> ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ' ')) ParsecT Text ParserState m Int
    -> ParsecT Text ParserState m Int -> ParsecT Text ParserState m Int
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Int -> ParsecT Text ParserState m Int
    forall (m :: * -> *) a. Monad m => a -> m a
    return 0
      -- try to find closing tag
      -- we set stateInHtmlBlock so that closing tags that can be either block or
      -- inline will not be parsed as inline tags
      Maybe Text
    oldInHtmlBlock <- ParserState -> Maybe Text
    stateInHtmlBlock (ParserState -> Maybe Text)
    -> ParsecT Text ParserState m ParserState
    -> ParsecT Text ParserState m (Maybe Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      (ParserState -> ParserState) -> ParsecT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParsecT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateInHtmlBlock :: Maybe Text
    stateInHtmlBlock = Text -> Maybe Text
    forall a. a -> Maybe a
    Just Text
    tagtype }
      let closer :: ParserT Text ParserState m (Tag Text, Text)
    closer = (Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag (Tag Text -> Tag Text -> Bool
    forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
    ~== Text -> Tag Text
    forall str. str -> Tag str
    TagClose Text
    tagtype)
      let block' :: MarkdownParser m (F Blocks)
    block' = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
                     Int -> ParsecT Text ParserState m Int
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m Int
    gobbleAtMostSpaces Int
    indentlevel
                     ParserT Text ParserState m (Tag Text, Text)
    -> ParsecT Text ParserState 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 ParserState m (Tag Text, Text)
    closer
                     MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    block
      F Blocks
    contents <- [F Blocks] -> F Blocks
    forall a. Monoid a => [a] -> a
    mconcat ([F Blocks] -> F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    -> MarkdownParser m (F Blocks)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many MarkdownParser m (F Blocks)
    block'
      F Blocks
    result <-
        MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try
        (do Int -> ParsecT Text ParserState m Int
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    Int -> ParserT Text st m Int
    gobbleAtMostSpaces Int
    indentlevel
            (_, rawcloser :: Text
    rawcloser) <- ParserT Text ParserState m (Tag Text, Text)
    closer
            F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Text -> Blocks
    B.rawBlock "html" (Text -> Blocks) -> Text -> Blocks
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    stripMarkdownAttribute Text
    raw) F Blocks -> F Blocks -> F Blocks
    forall a. Semigroup a => a -> a -> a
    <>
                    F Blocks
    contents F Blocks -> F Blocks -> F Blocks
    forall a. Semigroup a => a -> a -> a
    <>
                    Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Text -> Blocks
    B.rawBlock "html" Text
    rawcloser)))
          MarkdownParser m (F Blocks)
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Text -> Blocks
    B.rawBlock "html" Text
    raw) F Blocks -> F Blocks -> F Blocks
    forall a. Semigroup a => a -> a -> a
    <> F Blocks
    contents)
      (ParserState -> ParserState) -> ParsecT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParsecT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateInHtmlBlock :: Maybe Text
    stateInHtmlBlock = Maybe Text
    oldInHtmlBlock }
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Blocks
    result

    -- remove markdown="1" attribute
    stripMarkdownAttribute :: Text -> Text
    stripMarkdownAttribute :: Text -> Text
    stripMarkdownAttribute s :: Text
    s = [Tag Text] -> Text
    renderTags' ([Tag Text] -> Text) -> [Tag Text] -> Text
    forall a b. (a -> b) -> a -> b
    $ (Tag Text -> Tag Text) -> [Tag Text] -> [Tag Text]
    forall a b. (a -> b) -> [a] -> [b]
    map Tag Text -> Tag Text
    forall a. (Eq a, IsString a) => Tag a -> Tag a
    filterAttrib ([Tag Text] -> [Tag Text]) -> [Tag Text] -> [Tag Text]
    forall a b. (a -> b) -> a -> b
    $ Text -> [Tag Text]
    forall str. StringLike str => str -> [Tag str]
    parseTags Text
    s
      where filterAttrib :: Tag a -> Tag a
    filterAttrib (TagOpen t :: a
    t as :: [Attribute a]
    as) = a -> [Attribute a] -> Tag a
    forall str. str -> [Attribute str] -> Tag str
    TagOpen a
    t
                                            [(a
    k,a
    v) | (k :: a
    k,v :: a
    v) <- [Attribute a]
    as, a
    k a -> a -> Bool
    forall a. Eq a => a -> a -> Bool
    /= "markdown"]
            filterAttrib              x :: Tag a
    x = Tag a
    x

    --
    -- line block
    --

    lineBlock :: PandocMonad m => MarkdownParser m (F Blocks)
    lineBlock :: MarkdownParser m (F Blocks)
    lineBlock = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_line_blocks
      [F Inlines]
    lines' <- ParserT Text ParserState m [Text]
    forall (m :: * -> *) st. Monad m => ParserT Text st m [Text]
    lineBlockLines ParserT Text ParserState m [Text]
    -> ([Text] -> ParsecT Text ParserState m [F Inlines])
    -> ParsecT Text ParserState m [F Inlines]
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>=
                (Text -> ParsecT Text ParserState m (F Inlines))
    -> [Text] -> ParsecT Text ParserState m [F Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM (ParsecT Text ParserState m (F Inlines)
    -> Text -> ParsecT Text ParserState m (F Inlines)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' (F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlines))
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ [Inlines] -> Blocks
    B.lineBlock ([Inlines] -> Blocks) -> F [Inlines] -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> [F Inlines] -> F [Inlines]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence [F Inlines]
    lines'

    --
    -- Tables
    --

    -- Parse a dashed line with optional trailing spaces; return its length
    -- and the length including trailing space.
    dashedLine :: PandocMonad m
               => Char
               -> ParserT Text st m (Int, Int)
    dashedLine :: Char -> ParserT Text st m (Int, Int)
    dashedLine ch :: Char
    ch = do
      [Char]
    dashes <- ParsecT Text st m Char -> ParsecT Text st m [Char]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (Char -> ParsecT Text st m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    ch)
      [Char]
    sp     <- ParsecT Text st m Char -> ParsecT Text st m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many ParsecT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
      let lengthDashes :: Int
    lengthDashes = [Char] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [Char]
    dashes
          lengthSp :: Int
    lengthSp     = [Char] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [Char]
    sp
      (Int, Int) -> ParserT Text st m (Int, Int)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Int
    lengthDashes, Int
    lengthDashes Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    lengthSp)

    -- Parse a table header with dashed lines of '-' preceded by
    -- one (or zero) line of text.
    simpleTableHeader :: PandocMonad m
                      => Bool  -- ^ Headerless table
                      -> MarkdownParser m (F [Blocks], [Alignment], [Int])
    simpleTableHeader :: Bool
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    simpleTableHeader headless :: Bool
    headless = MarkdownParser m (Future ParserState [Blocks], [Alignment], [Int])
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (Future ParserState [Blocks], [Alignment], [Int])
     -> MarkdownParser
          m (Future ParserState [Blocks], [Alignment], [Int]))
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    forall a b. (a -> b) -> a -> b
    $ do
      Text
    rawContent  <- if Bool
    headless
                        then Text -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return ""
                        else ParsecT Text ParserState m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine
      Text
    initSp      <- ParsecT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    nonindentSpaces
      [(Int, Int)]
    dashes      <- ParsecT Text ParserState m (Int, Int)
    -> ParsecT Text ParserState m [(Int, Int)]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (Char -> ParsecT Text ParserState m (Int, Int)
    forall (m :: * -> *) st.
    PandocMonad m =>
    Char -> ParserT Text st m (Int, Int)
    dashedLine '-')
      ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
      let (lengths :: [Int]
    lengths, lines' :: [Int]
    lines') = [(Int, Int)] -> ([Int], [Int])
    forall a b. [(a, b)] -> ([a], [b])
    unzip [(Int, Int)]
    dashes
      let indices :: [Int]
    indices  = (Int -> Int -> Int) -> Int -> [Int] -> [Int]
    forall b a. (b -> a -> b) -> b -> [a] -> [b]
    scanl Int -> Int -> Int
    forall a. Num a => a -> a -> a
    (+) (Text -> Int
    T.length Text
    initSp) [Int]
    lines'
      -- If no header, calculate alignment on basis of first row of text
      [Text]
    rawHeads <- (Text -> [Text])
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ([Text] -> [Text]
    forall a. [a] -> [a]
    tail ([Text] -> [Text]) -> (Text -> [Text]) -> Text -> [Text]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Int] -> Text -> [Text]
    splitTextByIndices ([Int] -> [Int]
    forall a. [a] -> [a]
    init [Int]
    indices)) (ParsecT Text ParserState m Text
     -> ParsecT Text ParserState m [Text])
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall a b. (a -> b) -> a -> b
    $
                  if Bool
    headless
                     then ParsecT Text ParserState m Text -> ParsecT Text ParserState m Text
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead ParsecT Text ParserState m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine
                     else Text -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return Text
    rawContent
      let aligns :: [Alignment]
    aligns   = ([Text] -> Int -> Alignment) -> [[Text]] -> [Int] -> [Alignment]
    forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
    zipWith [Text] -> Int -> Alignment
    alignType ((Text -> [Text]) -> [Text] -> [[Text]]
    forall a b. (a -> b) -> [a] -> [b]
    map (Text -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    : []) [Text]
    rawHeads) [Int]
    lengths
      let rawHeads' :: [Text]
    rawHeads' = if Bool
    headless
                         then Int -> Text -> [Text]
    forall a. Int -> a -> [a]
    replicate ([(Int, Int)] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [(Int, Int)]
    dashes) ""
                         else [Text]
    rawHeads
      Future ParserState [Blocks]
    heads <- ([F Blocks] -> Future ParserState [Blocks])
    -> ParsecT Text ParserState m [F Blocks]
    -> ParsecT Text ParserState m (Future ParserState [Blocks])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [F Blocks] -> Future ParserState [Blocks]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence
               (ParsecT Text ParserState m [F Blocks]
     -> ParsecT Text ParserState m (Future ParserState [Blocks]))
    -> ParsecT Text ParserState m [F Blocks]
    -> ParsecT Text ParserState m (Future ParserState [Blocks])
    forall a b. (a -> b) -> a -> b
    $
                (Text -> ParsecT Text ParserState m (F Blocks))
    -> [Text] -> ParsecT Text ParserState m [F Blocks]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM (ParsecT Text ParserState m (F Blocks)
    -> Text -> ParsecT Text ParserState m (F Blocks)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' ([F Blocks] -> F Blocks
    forall a. Monoid a => [a] -> a
    mconcat ([F Blocks] -> F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    -> ParsecT Text ParserState m (F Blocks)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many ParsecT Text ParserState m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    plain)(Text -> ParsecT Text ParserState m (F Blocks))
    -> (Text -> Text) -> Text -> ParsecT Text ParserState m (F Blocks)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    .Text -> Text
    trim) [Text]
    rawHeads'
      (Future ParserState [Blocks], [Alignment], [Int])
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Future ParserState [Blocks]
    heads, [Alignment]
    aligns, [Int]
    indices)

    -- Returns an alignment type for a table, based on a list of strings
    -- (the rows of the column header) and a number (the length of the
    -- dashed line under the rows.
    alignType :: [Text]
              -> Int
              -> Alignment
    alignType :: [Text] -> Int -> Alignment
    alignType [] _ = Alignment
    AlignDefault
    alignType strLst :: [Text]
    strLst len :: Int
    len =
      let nonempties :: [Text]
    nonempties = (Text -> Bool) -> [Text] -> [Text]
    forall a. (a -> Bool) -> [a] -> [a]
    filter (Bool -> Bool
    not (Bool -> Bool) -> (Text -> Bool) -> Text -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Bool
    T.null) ([Text] -> [Text]) -> [Text] -> [Text]
    forall a b. (a -> b) -> a -> b
    $ (Text -> Text) -> [Text] -> [Text]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> Text
    trimr [Text]
    strLst
          (leftSpace :: Bool
    leftSpace, rightSpace :: Bool
    rightSpace) =
               case (Text -> Int) -> [Text] -> [Text]
    forall b a. Ord b => (a -> b) -> [a] -> [a]
    sortOn Text -> Int
    T.length [Text]
    nonempties of
                     (x :: Text
    x:_) -> (Text -> Char
    T.head Text
    x Char -> [Char] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [' ', '\t'], Text -> Int
    T.length Text
    x Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < Int
    len)
                     []    -> (Bool
    False, Bool
    False)
      in  case (Bool
    leftSpace, Bool
    rightSpace) of
            (True,  False) -> Alignment
    AlignRight
            (False, True)  -> Alignment
    AlignLeft
            (True,  True)  -> Alignment
    AlignCenter
            (False, False) -> Alignment
    AlignDefault

    -- Parse a table footer - dashed lines followed by blank line.
    tableFooter :: PandocMonad m => MarkdownParser m Text
    tableFooter :: MarkdownParser m Text
    tableFooter = MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Text -> MarkdownParser m Text)
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Int
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
    skipNonindentSpaces MarkdownParser m Int
    -> ParsecT Text ParserState m [(Int, Int)]
    -> ParsecT Text ParserState m [(Int, Int)]
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m (Int, Int)
    -> ParsecT Text ParserState m [(Int, Int)]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (Char -> ParsecT Text ParserState m (Int, Int)
    forall (m :: * -> *) st.
    PandocMonad m =>
    Char -> ParserT Text st m (Int, Int)
    dashedLine '-') ParsecT Text ParserState m [(Int, Int)]
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    blanklines'

    -- Parse a table separator - dashed line.
    tableSep :: PandocMonad m => MarkdownParser m Char
    tableSep :: MarkdownParser m Char
    tableSep = MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Char -> MarkdownParser m Char)
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Int
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
    skipNonindentSpaces MarkdownParser m Int
    -> ParsecT Text ParserState m [(Int, Int)]
    -> ParsecT Text ParserState m [(Int, Int)]
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m (Int, Int)
    -> ParsecT Text ParserState m [(Int, Int)]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (Char -> ParsecT Text ParserState m (Int, Int)
    forall (m :: * -> *) st.
    PandocMonad m =>
    Char -> ParserT Text st m (Int, Int)
    dashedLine '-') ParsecT Text ParserState m [(Int, Int)]
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Char -> MarkdownParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '\n'

    -- Parse a raw line and split it into chunks by indices.
    rawTableLine :: PandocMonad m
                 => [Int]
                 -> MarkdownParser m [Text]
    rawTableLine :: [Int] -> MarkdownParser m [Text]
    rawTableLine indices :: [Int]
    indices = do
      ParserT Text ParserState m Text -> ParserT Text ParserState 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 ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    blanklines' ParserT Text ParserState m Text
    -> ParserT Text ParserState m Text
    -> ParserT Text ParserState m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParserT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    tableFooter)
      Text
    line <- (Char -> Bool) -> ParserT Text ParserState m Text
    forall (m :: * -> *) st.
    Monad m =>
    (Char -> Bool) -> ParserT Text st m Text
    take1WhileP (Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    /='\n') ParserT Text ParserState m Text
    -> ParsecT Text ParserState m Char
    -> ParserT Text ParserState m Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
      [Text] -> MarkdownParser m [Text]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Text] -> MarkdownParser m [Text])
    -> [Text] -> MarkdownParser m [Text]
    forall a b. (a -> b) -> a -> b
    $ (Text -> Text) -> [Text] -> [Text]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> Text
    trim ([Text] -> [Text]) -> [Text] -> [Text]
    forall a b. (a -> b) -> a -> b
    $ [Text] -> [Text]
    forall a. [a] -> [a]
    tail ([Text] -> [Text]) -> [Text] -> [Text]
    forall a b. (a -> b) -> a -> b
    $
               [Int] -> Text -> [Text]
    splitTextByIndices ([Int] -> [Int]
    forall a. [a] -> [a]
    init [Int]
    indices) Text
    line

    -- Parse a table line and return a list of lists of blocks (columns).
    tableLine :: PandocMonad m
              => [Int]
              -> MarkdownParser m (F [Blocks])
    tableLine :: [Int] -> MarkdownParser m (Future ParserState [Blocks])
    tableLine indices :: [Int]
    indices = [Int] -> MarkdownParser m [Text]
    forall (m :: * -> *).
    PandocMonad m =>
    [Int] -> MarkdownParser m [Text]
    rawTableLine [Int]
    indices MarkdownParser m [Text]
    -> ([Text] -> MarkdownParser m (Future ParserState [Blocks]))
    -> MarkdownParser m (Future ParserState [Blocks])
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>=
      ([F Blocks] -> Future ParserState [Blocks])
    -> ParsecT Text ParserState m [F Blocks]
    -> MarkdownParser m (Future ParserState [Blocks])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [F Blocks] -> Future ParserState [Blocks]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence (ParsecT Text ParserState m [F Blocks]
     -> MarkdownParser m (Future ParserState [Blocks]))
    -> ([Text] -> ParsecT Text ParserState m [F Blocks])
    -> [Text]
    -> MarkdownParser m (Future ParserState [Blocks])
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Text -> ParsecT Text ParserState m (F Blocks))
    -> [Text] -> ParsecT Text ParserState m [F Blocks]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM (ParsecT Text ParserState m (F Blocks)
    -> Text -> ParsecT Text ParserState m (F Blocks)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' ([F Blocks] -> F Blocks
    forall a. Monoid a => [a] -> a
    mconcat ([F Blocks] -> F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    -> ParsecT Text ParserState m (F Blocks)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many ParsecT Text ParserState m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    plain))

    -- Parse a multiline table row and return a list of blocks (columns).
    multilineRow :: PandocMonad m
                 => [Int]
                 -> MarkdownParser m (F [Blocks])
    multilineRow :: [Int] -> MarkdownParser m (Future ParserState [Blocks])
    multilineRow indices :: [Int]
    indices = do
      [[Text]]
    colLines <- ParsecT Text ParserState m [Text]
    -> ParsecT Text ParserState m [[Text]]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 ([Int] -> ParsecT Text ParserState m [Text]
    forall (m :: * -> *).
    PandocMonad m =>
    [Int] -> MarkdownParser m [Text]
    rawTableLine [Int]
    indices)
      let cols :: [Text]
    cols = ([Text] -> Text) -> [[Text]] -> [Text]
    forall a b. (a -> b) -> [a] -> [b]
    map [Text] -> Text
    T.unlines ([[Text]] -> [Text]) -> [[Text]] -> [Text]
    forall a b. (a -> b) -> a -> b
    $ [[Text]] -> [[Text]]
    forall a. [[a]] -> [[a]]
    transpose [[Text]]
    colLines
      ([F Blocks] -> Future ParserState [Blocks])
    -> ParsecT Text ParserState m [F Blocks]
    -> MarkdownParser m (Future ParserState [Blocks])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [F Blocks] -> Future ParserState [Blocks]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence (ParsecT Text ParserState m [F Blocks]
     -> MarkdownParser m (Future ParserState [Blocks]))
    -> ParsecT Text ParserState m [F Blocks]
    -> MarkdownParser m (Future ParserState [Blocks])
    forall a b. (a -> b) -> a -> b
    $ (Text -> ParsecT Text ParserState m (F Blocks))
    -> [Text] -> ParsecT Text ParserState m [F Blocks]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM (ParsecT Text ParserState m (F Blocks)
    -> Text -> ParsecT Text ParserState m (F Blocks)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' ([F Blocks] -> F Blocks
    forall a. Monoid a => [a] -> a
    mconcat ([F Blocks] -> F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    -> ParsecT Text ParserState m (F Blocks)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many ParsecT Text ParserState m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    plain)) [Text]
    cols

    -- Parses a table caption:  inlines beginning with 'Table:'
    -- and followed by blank lines.
    tableCaption :: PandocMonad m => MarkdownParser m (F Inlines)
    tableCaption :: MarkdownParser m (F Inlines)
    tableCaption = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_table_captions
      MarkdownParser m Int
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
    skipNonindentSpaces
      ([Char] -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string ":" ParsecT Text ParserState m [Char]
    -> ParserT Text ParserState m ()
    -> ParsecT Text ParserState m [Char]
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy ((Char -> Bool) -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy Char -> Bool
    isPunctuation)) ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState 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 ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "Table:"
      F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlines1 MarkdownParser m (F Inlines)
    -> ParsecT Text ParserState m Text -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines

    -- Parse a simple table with '---' header and one line per row.
    simpleTable :: PandocMonad m
                => Bool  -- ^ Headerless table
                -> MarkdownParser m ([Alignment], [Double], F [Blocks], F [[Blocks]])
    simpleTable :: Bool
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    simpleTable headless :: Bool
    headless = do
      (aligns :: [Alignment]
    aligns, _widths :: [Double]
    _widths, heads' :: Future ParserState [Blocks]
    heads', lines' :: F [[Blocks]]
    lines') <-
           MarkdownParser m (Future ParserState [Blocks], [Alignment], [Int])
    -> ([Int] -> MarkdownParser m (Future ParserState [Blocks]))
    -> MarkdownParser m ()
    -> MarkdownParser m Text
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *) sep end.
    PandocMonad m =>
    MarkdownParser m (Future ParserState [Blocks], [Alignment], [Int])
    -> ([Int] -> MarkdownParser m (Future ParserState [Blocks]))
    -> MarkdownParser m sep
    -> MarkdownParser m end
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    tableWith (Bool
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    forall (m :: * -> *).
    PandocMonad m =>
    Bool
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    simpleTableHeader Bool
    headless) [Int] -> MarkdownParser m (Future ParserState [Blocks])
    forall (m :: * -> *).
    PandocMonad m =>
    [Int] -> MarkdownParser m (Future ParserState [Blocks])
    tableLine
                  (() -> MarkdownParser m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ())
                  (if Bool
    headless then MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    tableFooter else MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    tableFooter MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    blanklines')
      -- Simple tables get 0s for relative column widths (i.e., use default)
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Alignment]
    aligns, Int -> Double -> [Double]
    forall a. Int -> a -> [a]
    replicate ([Alignment] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [Alignment]
    aligns) 0, Future ParserState [Blocks]
    heads', F [[Blocks]]
    lines')

    -- Parse a multiline table:  starts with row of '-' on top, then header
    -- (which may be multiline), then the rows,
    -- which may be multiline, separated by blank lines, and
    -- ending with a footer (dashed line followed by blank line).
    multilineTable :: PandocMonad m
                   => Bool -- ^ Headerless table
                   -> MarkdownParser m ([Alignment], [Double], F [Blocks], F [[Blocks]])
    multilineTable :: Bool
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    multilineTable headless :: Bool
    headless =
      MarkdownParser m (Future ParserState [Blocks], [Alignment], [Int])
    -> ([Int] -> MarkdownParser m (Future ParserState [Blocks]))
    -> MarkdownParser m Text
    -> MarkdownParser m Text
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *) sep end.
    PandocMonad m =>
    MarkdownParser m (Future ParserState [Blocks], [Alignment], [Int])
    -> ([Int] -> MarkdownParser m (Future ParserState [Blocks]))
    -> MarkdownParser m sep
    -> MarkdownParser m end
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    tableWith (Bool
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    forall (m :: * -> *).
    PandocMonad m =>
    Bool
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    multilineTableHeader Bool
    headless) [Int] -> MarkdownParser m (Future ParserState [Blocks])
    forall (m :: * -> *).
    PandocMonad m =>
    [Int] -> MarkdownParser m (Future ParserState [Blocks])
    multilineRow MarkdownParser m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    tableFooter

    multilineTableHeader :: PandocMonad m
                         => Bool -- ^ Headerless table
                         -> MarkdownParser m (F [Blocks], [Alignment], [Int])
    multilineTableHeader :: Bool
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    multilineTableHeader headless :: Bool
    headless = MarkdownParser m (Future ParserState [Blocks], [Alignment], [Int])
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (Future ParserState [Blocks], [Alignment], [Int])
     -> MarkdownParser
          m (Future ParserState [Blocks], [Alignment], [Int]))
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    forall a b. (a -> b) -> a -> b
    $ do
      Bool
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    unless Bool
    headless (ParsecT Text ParserState m () -> ParsecT Text ParserState m ())
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $
         MarkdownParser m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    tableSep MarkdownParser m Char
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m Char -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy MarkdownParser m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
      [Text]
    rawContent  <- if Bool
    headless
                        then [Text] -> ParsecT Text ParserState m [Text]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Text] -> ParsecT Text ParserState m [Text])
    -> [Text] -> ParsecT Text ParserState m [Text]
    forall a b. (a -> b) -> a -> b
    $ Text -> [Text]
    forall a. a -> [a]
    repeat ""
                        else ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (ParsecT Text ParserState m Text
     -> ParsecT Text ParserState m [Text])
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m Char -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy MarkdownParser m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    tableSep ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine
      Text
    initSp      <- ParsecT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    nonindentSpaces
      [(Int, Int)]
    dashes      <- ParsecT Text ParserState m (Int, Int)
    -> ParsecT Text ParserState m [(Int, Int)]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (Char -> ParsecT Text ParserState m (Int, Int)
    forall (m :: * -> *) st.
    PandocMonad m =>
    Char -> ParserT Text st m (Int, Int)
    dashedLine '-')
      MarkdownParser m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
      let (lengths :: [Int]
    lengths, lines' :: [Int]
    lines') = [(Int, Int)] -> ([Int], [Int])
    forall a b. [(a, b)] -> ([a], [b])
    unzip [(Int, Int)]
    dashes
      let indices :: [Int]
    indices  = (Int -> Int -> Int) -> Int -> [Int] -> [Int]
    forall b a. (b -> a -> b) -> b -> [a] -> [b]
    scanl Int -> Int -> Int
    forall a. Num a => a -> a -> a
    (+) (Text -> Int
    T.length Text
    initSp) [Int]
    lines'
      -- compensate for the fact that intercolumn spaces are
      -- not included in the last index:
      let indices' :: [Int]
    indices' = case [Int] -> [Int]
    forall a. [a] -> [a]
    reverse [Int]
    indices of
                          []     -> []
                          (x :: Int
    x:xs :: [Int]
    xs) -> [Int] -> [Int]
    forall a. [a] -> [a]
    reverse (Int
    xInt -> Int -> Int
    forall a. Num a => a -> a -> a
    +1Int -> [Int] -> [Int]
    forall a. a -> [a] -> [a]
    :[Int]
    xs)
      [[Text]]
    rawHeadsList <- if Bool
    headless
                         then (Text -> [[Text]])
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [[Text]]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((Text -> [Text]) -> [Text] -> [[Text]]
    forall a b. (a -> b) -> [a] -> [b]
    map (Text -> [Text] -> [Text]
    forall a. a -> [a] -> [a]
    :[]) ([Text] -> [[Text]]) -> (Text -> [Text]) -> Text -> [[Text]]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Text] -> [Text]
    forall a. [a] -> [a]
    tail ([Text] -> [Text]) -> (Text -> [Text]) -> Text -> [Text]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    .
                                  [Int] -> Text -> [Text]
    splitTextByIndices ([Int] -> [Int]
    forall a. [a] -> [a]
    init [Int]
    indices')) (ParsecT Text ParserState m Text
     -> ParsecT Text ParserState m [[Text]])
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [[Text]]
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m Text -> ParsecT Text ParserState m Text
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead ParsecT Text ParserState m Text
    forall (m :: * -> *) st. Monad m => ParserT Text st m Text
    anyLine
                         else [[Text]] -> ParsecT Text ParserState m [[Text]]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([[Text]] -> ParsecT Text ParserState m [[Text]])
    -> [[Text]] -> ParsecT Text ParserState m [[Text]]
    forall a b. (a -> b) -> a -> b
    $ [[Text]] -> [[Text]]
    forall a. [[a]] -> [[a]]
    transpose ([[Text]] -> [[Text]]) -> [[Text]] -> [[Text]]
    forall a b. (a -> b) -> a -> b
    $ (Text -> [Text]) -> [Text] -> [[Text]]
    forall a b. (a -> b) -> [a] -> [b]
    map
                               ([Text] -> [Text]
    forall a. [a] -> [a]
    tail ([Text] -> [Text]) -> (Text -> [Text]) -> Text -> [Text]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Int] -> Text -> [Text]
    splitTextByIndices ([Int] -> [Int]
    forall a. [a] -> [a]
    init [Int]
    indices'))
                               [Text]
    rawContent
      let aligns :: [Alignment]
    aligns   = ([Text] -> Int -> Alignment) -> [[Text]] -> [Int] -> [Alignment]
    forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
    zipWith [Text] -> Int -> Alignment
    alignType [[Text]]
    rawHeadsList [Int]
    lengths
      let rawHeads :: [Text]
    rawHeads = if Bool
    headless
                        then Int -> Text -> [Text]
    forall a. Int -> a -> [a]
    replicate ([(Int, Int)] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [(Int, Int)]
    dashes) ""
                        else ([Text] -> Text) -> [[Text]] -> [Text]
    forall a b. (a -> b) -> [a] -> [b]
    map ([Text] -> Text
    T.unlines ([Text] -> Text) -> ([Text] -> [Text]) -> [Text] -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Text -> Text) -> [Text] -> [Text]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> Text
    trim) [[Text]]
    rawHeadsList
      Future ParserState [Blocks]
    heads <- ([F Blocks] -> Future ParserState [Blocks])
    -> ParsecT Text ParserState m [F Blocks]
    -> ParsecT Text ParserState m (Future ParserState [Blocks])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [F Blocks] -> Future ParserState [Blocks]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence (ParsecT Text ParserState m [F Blocks]
     -> ParsecT Text ParserState m (Future ParserState [Blocks]))
    -> ParsecT Text ParserState m [F Blocks]
    -> ParsecT Text ParserState m (Future ParserState [Blocks])
    forall a b. (a -> b) -> a -> b
    $
                (Text -> ParsecT Text ParserState m (F Blocks))
    -> [Text] -> ParsecT Text ParserState m [F Blocks]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM (ParsecT Text ParserState m (F Blocks)
    -> Text -> ParsecT Text ParserState m (F Blocks)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' ([F Blocks] -> F Blocks
    forall a. Monoid a => [a] -> a
    mconcat ([F Blocks] -> F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    -> ParsecT Text ParserState m (F Blocks)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many ParsecT Text ParserState m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    plain)(Text -> ParsecT Text ParserState m (F Blocks))
    -> (Text -> Text) -> Text -> ParsecT Text ParserState m (F Blocks)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    .Text -> Text
    trim) [Text]
    rawHeads
      (Future ParserState [Blocks], [Alignment], [Int])
    -> MarkdownParser
         m (Future ParserState [Blocks], [Alignment], [Int])
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Future ParserState [Blocks]
    heads, [Alignment]
    aligns, [Int]
    indices')

    -- Parse a grid table:  starts with row of '-' on top, then header
    -- (which may be grid), then the rows,
    -- which may be grid, separated by blank lines, and
    -- ending with a footer (dashed line followed by blank line).
    gridTable :: PandocMonad m => Bool -- ^ Headerless table
              -> MarkdownParser m ([Alignment], [Double], F [Blocks], F [[Blocks]])
    gridTable :: Bool
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    gridTable headless :: Bool
    headless = ParserT Text ParserState m (F Blocks)
    -> Bool
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s (m :: * -> *) st (mf :: * -> *).
    (Stream s m Char, HasReaderOptions st, HasLastStrPosition st,
     Monad mf, IsString s) =>
    ParserT s st m (mf Blocks)
    -> Bool -> ParserT s st m (TableComponents mf)
    gridTableWith' ParserT Text ParserState m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    parseBlocks Bool
    headless

    pipeBreak :: PandocMonad m => MarkdownParser m ([Alignment], [Int])
    pipeBreak :: MarkdownParser m ([Alignment], [Int])
    pipeBreak = MarkdownParser m ([Alignment], [Int])
    -> MarkdownParser m ([Alignment], [Int])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m ([Alignment], [Int])
     -> MarkdownParser m ([Alignment], [Int]))
    -> MarkdownParser m ([Alignment], [Int])
    -> MarkdownParser m ([Alignment], [Int])
    forall a b. (a -> b) -> a -> b
    $ do
      MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    nonindentSpaces
      Bool
    openPipe <- (Bool
    True Bool
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Bool
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '|') ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Bool -> ParsecT Text ParserState m Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    False
      (Alignment, Int)
    first <- ParserT Text ParserState m (Alignment, Int)
    forall (m :: * -> *) st.
    PandocMonad m =>
    ParserT Text st m (Alignment, Int)
    pipeTableHeaderPart
      [(Alignment, Int)]
    rest <- ParserT Text ParserState m (Alignment, Int)
    -> ParsecT Text ParserState m [(Alignment, Int)]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParserT Text ParserState m (Alignment, Int)
     -> ParsecT Text ParserState m [(Alignment, Int)])
    -> ParserT Text ParserState m (Alignment, Int)
    -> ParsecT Text ParserState m [(Alignment, Int)]
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    sepPipe MarkdownParser m ()
    -> ParserT Text ParserState m (Alignment, Int)
    -> ParserT Text ParserState m (Alignment, Int)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParserT Text ParserState m (Alignment, Int)
    forall (m :: * -> *) st.
    PandocMonad m =>
    ParserT Text st m (Alignment, Int)
    pipeTableHeaderPart
      -- surrounding pipes needed for a one-column table:
      Bool -> MarkdownParser m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> MarkdownParser m ()) -> Bool -> MarkdownParser m ()
    forall a b. (a -> b) -> a -> b
    $ Bool -> Bool
    not ([(Alignment, Int)] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [(Alignment, Int)]
    rest Bool -> Bool -> Bool
    && Bool -> Bool
    not Bool
    openPipe)
      ParsecT Text ParserState m Char -> MarkdownParser m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '|')
      ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
      ([Alignment], [Int]) -> MarkdownParser m ([Alignment], [Int])
    forall (m :: * -> *) a. Monad m => a -> m a
    return (([Alignment], [Int]) -> MarkdownParser m ([Alignment], [Int]))
    -> ([Alignment], [Int]) -> MarkdownParser m ([Alignment], [Int])
    forall a b. (a -> b) -> a -> b
    $ [(Alignment, Int)] -> ([Alignment], [Int])
    forall a b. [(a, b)] -> ([a], [b])
    unzip ((Alignment, Int)
    first(Alignment, Int) -> [(Alignment, Int)] -> [(Alignment, Int)]
    forall a. a -> [a] -> [a]
    :[(Alignment, Int)]
    rest)

    pipeTable :: PandocMonad m => MarkdownParser m ([Alignment], [Double], F [Blocks], F [[Blocks]])
    pipeTable :: MarkdownParser
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    pipeTable = MarkdownParser
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser
       m
       ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
     -> MarkdownParser
          m
          ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]]))
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall a b. (a -> b) -> a -> b
    $ do
      MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    nonindentSpaces
      ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    nonspaceChar
      (heads :: Future ParserState [Blocks]
    heads,(aligns :: [Alignment]
    aligns, seplengths :: [Int]
    seplengths)) <- (,) (Future ParserState [Blocks]
     -> ([Alignment], [Int])
     -> (Future ParserState [Blocks], ([Alignment], [Int])))
    -> ParsecT Text ParserState m (Future ParserState [Blocks])
    -> ParsecT
         Text
         ParserState
         m
         (([Alignment], [Int])
          -> (Future ParserState [Blocks], ([Alignment], [Int])))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (Future ParserState [Blocks])
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (Future ParserState [Blocks])
    pipeTableRow ParsecT
      Text
      ParserState
      m
      (([Alignment], [Int])
       -> (Future ParserState [Blocks], ([Alignment], [Int])))
    -> ParsecT Text ParserState m ([Alignment], [Int])
    -> ParsecT
         Text
         ParserState
         m
         (Future ParserState [Blocks], ([Alignment], [Int]))
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Text ParserState m ([Alignment], [Int])
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m ([Alignment], [Int])
    pipeBreak
      let heads' :: Future ParserState [Blocks]
    heads' = Int -> [Blocks] -> [Blocks]
    forall a. Int -> [a] -> [a]
    take ([Alignment] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [Alignment]
    aligns) ([Blocks] -> [Blocks])
    -> Future ParserState [Blocks] -> Future ParserState [Blocks]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Future ParserState [Blocks]
    heads
      [Future ParserState [Blocks]]
    lines' <- ParsecT Text ParserState m (Future ParserState [Blocks])
    -> ParsecT Text ParserState m [Future ParserState [Blocks]]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many ParsecT Text ParserState m (Future ParserState [Blocks])
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (Future ParserState [Blocks])
    pipeTableRow
      let lines'' :: [Future ParserState [Blocks]]
    lines'' = (Future ParserState [Blocks] -> Future ParserState [Blocks])
    -> [Future ParserState [Blocks]] -> [Future ParserState [Blocks]]
    forall a b. (a -> b) -> [a] -> [b]
    map (Int -> [Blocks] -> [Blocks]
    forall a. Int -> [a] -> [a]
    take ([Alignment] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [Alignment]
    aligns) ([Blocks] -> [Blocks])
    -> Future ParserState [Blocks] -> Future ParserState [Blocks]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>) [Future ParserState [Blocks]]
    lines'
      let maxlength :: Int
    maxlength = [Int] -> Int
    forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
    maximum ([Int] -> Int) -> [Int] -> Int
    forall a b. (a -> b) -> a -> b
    $
           (Future ParserState [Blocks] -> Int)
    -> [Future ParserState [Blocks]] -> [Int]
    forall a b. (a -> b) -> [a] -> [b]
    map (\x :: Future ParserState [Blocks]
    x -> Text -> Int
    T.length (Text -> Int) -> ([Blocks] -> Text) -> [Blocks] -> Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Blocks] -> Text
    forall a. Walkable Inline a => a -> Text
    stringify ([Blocks] -> Int) -> [Blocks] -> Int
    forall a b. (a -> b) -> a -> b
    $ Future ParserState [Blocks] -> ParserState -> [Blocks]
    forall s a. Future s a -> s -> a
    runF Future ParserState [Blocks]
    x ParserState
    forall a. Default a => a
    def) (Future ParserState [Blocks]
    heads' Future ParserState [Blocks]
    -> [Future ParserState [Blocks]] -> [Future ParserState [Blocks]]
    forall a. a -> [a] -> [a]
    : [Future ParserState [Blocks]]
    lines'')
      Int
    numColumns <- (ReaderOptions -> Int) -> ParserT Text ParserState m Int
    forall st s (m :: * -> *) t b.
    (HasReaderOptions st, Stream s m t) =>
    (ReaderOptions -> b) -> ParserT s st m b
    getOption ReaderOptions -> Int
    readerColumns
      let widths :: [Double]
    widths = if Int
    maxlength Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    > Int
    numColumns
                      then (Int -> Double) -> [Int] -> [Double]
    forall a b. (a -> b) -> [a] -> [b]
    map (\len :: Int
    len ->
                             Int -> Double
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Int
    len Double -> Double -> Double
    forall a. Fractional a => a -> a -> a
    / Int -> Double
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral ([Int] -> Int
    forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
    sum [Int]
    seplengths))
                             [Int]
    seplengths
                      else Int -> Double -> [Double]
    forall a. Int -> a -> [a]
    replicate ([Alignment] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [Alignment]
    aligns) 0.0
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Alignment]
    aligns, [Double]
    widths, Future ParserState [Blocks]
    heads', [Future ParserState [Blocks]] -> F [[Blocks]]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence [Future ParserState [Blocks]]
    lines'')

    sepPipe :: PandocMonad m => MarkdownParser m ()
    sepPipe :: MarkdownParser m ()
    sepPipe = MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m () -> MarkdownParser m ())
    -> MarkdownParser m () -> MarkdownParser m ()
    forall a b. (a -> b) -> a -> b
    $ do
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '|' ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '+'
      ParsecT Text ParserState m Char -> MarkdownParser 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline

    -- parse a row, also returning probable alignments for org-table cells
    pipeTableRow :: PandocMonad m => MarkdownParser m (F [Blocks])
    pipeTableRow :: MarkdownParser m (Future ParserState [Blocks])
    pipeTableRow = MarkdownParser m (Future ParserState [Blocks])
    -> MarkdownParser m (Future ParserState [Blocks])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (Future ParserState [Blocks])
     -> MarkdownParser m (Future ParserState [Blocks]))
    -> MarkdownParser m (Future ParserState [Blocks])
    -> MarkdownParser m (Future ParserState [Blocks])
    forall a b. (a -> b) -> a -> b
    $ do
      ParserT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    scanForPipe
      ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
      Bool
    openPipe <- (Bool
    True Bool
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Bool
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '|') ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Bool -> ParsecT Text ParserState m Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    False
      -- split into cells
      let chunk :: ParserT Text ParserState m ()
    chunk = ParsecT Text ParserState m (F Inlines)
    -> ParserT Text ParserState m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    code ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState 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 ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    math ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState 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 ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    rawHtmlInline ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState 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 ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    escapedChar ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState 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 ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    rawLaTeXInline')
           ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void ([Char] -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf "|\n\r")
      let cellContents :: ParsecT Text ParserState m (F Blocks)
    cellContents = ((Text -> Text
    trim (Text -> Text) -> (([()], Text) -> Text) -> ([()], Text) -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ([()], Text) -> Text
    forall a b. (a, b) -> b
    snd) (([()], Text) -> Text)
    -> ParsecT Text ParserState m ([()], Text)
    -> ParsecT Text ParserState m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m [()]
    -> ParsecT Text ParserState m ([()], Text)
    forall (m :: * -> *) st a.
    Monad m =>
    ParsecT Text st m a -> ParsecT Text st m (a, Text)
    withRaw (ParserT Text ParserState m () -> ParsecT Text ParserState m [()]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many ParserT Text ParserState m ()
    chunk)) ParsecT Text ParserState m Text
    -> (Text -> ParsecT Text ParserState m (F Blocks))
    -> ParsecT Text ParserState m (F Blocks)
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>=
            ParsecT Text ParserState m (F Blocks)
    -> Text -> ParsecT Text ParserState m (F Blocks)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' ParsecT Text ParserState m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    pipeTableCell
      [F Blocks]
    cells <- ParsecT Text ParserState m (F Blocks)
    cellContents ParsecT Text ParserState m (F Blocks)
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [F Blocks]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    `sepEndBy1` Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '|'
      -- surrounding pipes needed for a one-column table:
      Bool -> ParserT Text ParserState m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParserT Text ParserState m ())
    -> Bool -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ Bool -> Bool
    not ([F Blocks] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [F Blocks]
    cells Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == 1 Bool -> Bool -> Bool
    && Bool -> Bool
    not Bool
    openPipe)
      ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
      Future ParserState [Blocks]
    -> MarkdownParser m (Future ParserState [Blocks])
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Future ParserState [Blocks]
     -> MarkdownParser m (Future ParserState [Blocks]))
    -> Future ParserState [Blocks]
    -> MarkdownParser m (Future ParserState [Blocks])
    forall a b. (a -> b) -> a -> b
    $ [F Blocks] -> Future ParserState [Blocks]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence [F Blocks]
    cells

    pipeTableCell :: PandocMonad m => MarkdownParser m (F Blocks)
    pipeTableCell :: MarkdownParser m (F Blocks)
    pipeTableCell =
      (do F Inlines
    result <- MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlines1
          F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Inlines -> Blocks
    B.plain (Inlines -> Blocks) -> F Inlines -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    result)
        MarkdownParser m (F Blocks)
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Blocks
    forall a. Monoid a => a
    mempty

    pipeTableHeaderPart :: PandocMonad m => ParserT Text st m (Alignment, Int)
    pipeTableHeaderPart :: ParserT Text st m (Alignment, Int)
    pipeTableHeaderPart = ParserT Text st m (Alignment, Int)
    -> ParserT Text st m (Alignment, Int)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParserT Text st m (Alignment, Int)
     -> ParserT Text st m (Alignment, Int))
    -> ParserT Text st m (Alignment, Int)
    -> ParserT Text st m (Alignment, Int)
    forall a b. (a -> b) -> a -> b
    $ do
      ParsecT Text st m Char -> ParsecT Text st m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
      Maybe Char
    left <- ParsecT Text st m Char -> ParsecT Text st m (Maybe Char)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m (Maybe a)
    optionMaybe (Char -> ParsecT Text st m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':')
      [Char]
    pipe <- ParsecT Text st m Char -> ParsecT Text st m [Char]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (Char -> ParsecT Text st m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '-')
      Maybe Char
    right <- ParsecT Text st m Char -> ParsecT Text st m (Maybe Char)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m (Maybe a)
    optionMaybe (Char -> ParsecT Text st m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':')
      ParsecT Text st m Char -> ParsecT Text st m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
      let len :: Int
    len = [Char] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [Char]
    pipe Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int -> (Char -> Int) -> Maybe Char -> Int
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe 0 (Int -> Char -> Int
    forall a b. a -> b -> a
    const 1) Maybe Char
    left Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int -> (Char -> Int) -> Maybe Char -> Int
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe 0 (Int -> Char -> Int
    forall a b. a -> b -> a
    const 1) Maybe Char
    right
      (Alignment, Int) -> ParserT Text st m (Alignment, Int)
    forall (m :: * -> *) a. Monad m => a -> m a
    return
        (case (Maybe Char
    left,Maybe Char
    right) of
          (Nothing,Nothing) -> Alignment
    AlignDefault
          (Just _,Nothing)  -> Alignment
    AlignLeft
          (Nothing,Just _)  -> Alignment
    AlignRight
          (Just _,Just _)   -> Alignment
    AlignCenter, Int
    len)

    -- Succeed only if current line contains a pipe.
    scanForPipe :: PandocMonad m => ParserT Text st m ()
    scanForPipe :: ParserT Text st m ()
    scanForPipe = do
      Text
    inp <- ParsecT Text st m Text
    forall (m :: * -> *) s u. Monad m => ParsecT s u m s
    getInput
      case (Char -> Bool) -> Text -> (Text, Text)
    T.break (\c :: Char
    c -> Char
    c Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == '\n' Bool -> Bool -> Bool
    || Char
    c Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == '|') Text
    inp of
           (_, Text -> Maybe (Char, Text)
    T.uncons -> Just ('|', _)) -> () -> ParserT Text st m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
           _                              -> ParserT Text st m ()
    forall (m :: * -> *) a. MonadPlus m => m a
    mzero

    -- | Parse a table using 'headerParser', 'rowParser',
    -- 'lineParser', and 'footerParser'.  Variant of the version in
    -- Text.Pandoc.Parsing.
    tableWith :: PandocMonad m
              => MarkdownParser m (F [Blocks], [Alignment], [Int])
              -> ([Int] -> MarkdownParser m (F [Blocks]))
              -> MarkdownParser m sep
              -> MarkdownParser m end
              -> MarkdownParser m ([Alignment], [Double], F [Blocks], F [[Blocks]])
    tableWith :: MarkdownParser m (Future ParserState [Blocks], [Alignment], [Int])
    -> ([Int] -> MarkdownParser m (Future ParserState [Blocks]))
    -> MarkdownParser m sep
    -> MarkdownParser m end
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    tableWith headerParser :: MarkdownParser m (Future ParserState [Blocks], [Alignment], [Int])
    headerParser rowParser :: [Int] -> MarkdownParser m (Future ParserState [Blocks])
    rowParser lineParser :: MarkdownParser m sep
    lineParser footerParser :: MarkdownParser m end
    footerParser = MarkdownParser
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser
       m
       ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
     -> MarkdownParser
          m
          ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]]))
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall a b. (a -> b) -> a -> b
    $ do
        (heads :: Future ParserState [Blocks]
    heads, aligns :: [Alignment]
    aligns, indices :: [Int]
    indices) <- MarkdownParser m (Future ParserState [Blocks], [Alignment], [Int])
    headerParser
        F [[Blocks]]
    lines' <- ([Future ParserState [Blocks]] -> F [[Blocks]])
    -> ParsecT Text ParserState m [Future ParserState [Blocks]]
    -> ParsecT Text ParserState m (F [[Blocks]])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Future ParserState [Blocks]] -> F [[Blocks]]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence (ParsecT Text ParserState m [Future ParserState [Blocks]]
     -> ParsecT Text ParserState m (F [[Blocks]]))
    -> ParsecT Text ParserState m [Future ParserState [Blocks]]
    -> ParsecT Text ParserState m (F [[Blocks]])
    forall a b. (a -> b) -> a -> b
    $ [Int] -> MarkdownParser m (Future ParserState [Blocks])
    rowParser [Int]
    indices MarkdownParser m (Future ParserState [Blocks])
    -> MarkdownParser m sep
    -> ParsecT Text ParserState m [Future ParserState [Blocks]]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    `sepEndBy1` MarkdownParser m sep
    lineParser
        MarkdownParser m end
    footerParser
        Int
    numColumns <- (ReaderOptions -> Int) -> ParserT Text ParserState m Int
    forall st s (m :: * -> *) t b.
    (HasReaderOptions st, Stream s m t) =>
    (ReaderOptions -> b) -> ParserT s st m b
    getOption ReaderOptions -> Int
    readerColumns
        let widths :: [Double]
    widths = if [Int] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [Int]
    indices
                        then Int -> Double -> [Double]
    forall a. Int -> a -> [a]
    replicate ([Alignment] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [Alignment]
    aligns) 0.0
                        else Int -> [Int] -> [Double]
    widthsFromIndices Int
    numColumns [Int]
    indices
        ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Alignment]
    aligns, [Double]
    widths, Future ParserState [Blocks]
    heads, F [[Blocks]]
    lines')

    table :: PandocMonad m => MarkdownParser m (F Blocks)
    table :: MarkdownParser m (F Blocks)
    table = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      Maybe (F Inlines)
    frontCaption <- Maybe (F Inlines)
    -> ParsecT Text ParserState m (Maybe (F Inlines))
    -> ParsecT Text ParserState m (Maybe (F Inlines))
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option Maybe (F Inlines)
    forall a. Maybe a
    Nothing (F Inlines -> Maybe (F Inlines)
    forall a. a -> Maybe a
    Just (F Inlines -> Maybe (F Inlines))
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (Maybe (F Inlines))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    tableCaption)
      (aligns :: [Alignment]
    aligns, widths :: [Double]
    widths, heads :: Future ParserState [Blocks]
    heads, lns :: F [[Blocks]]
    lns) <-
             ParsecT
      Text
      ParserState
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_pipe_tables ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParserT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    scanForPipe ParserT Text ParserState m ()
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT
      Text
      ParserState
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    pipeTable) ParsecT
      Text
      ParserState
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
             ParsecT
      Text
      ParserState
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_multiline_tables ParserT Text ParserState m ()
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                    Bool
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *).
    PandocMonad m =>
    Bool
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    multilineTable Bool
    False) ParsecT
      Text
      ParserState
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
             ParsecT
      Text
      ParserState
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_simple_tables ParserT Text ParserState m ()
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                    (Bool
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *).
    PandocMonad m =>
    Bool
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    simpleTable Bool
    True ParsecT
      Text
      ParserState
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Bool
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *).
    PandocMonad m =>
    Bool
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    simpleTable Bool
    False)) ParsecT
      Text
      ParserState
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
             ParsecT
      Text
      ParserState
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_multiline_tables ParserT Text ParserState m ()
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                    Bool
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *).
    PandocMonad m =>
    Bool
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    multilineTable Bool
    True) ParsecT
      Text
      ParserState
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
             ParsecT
      Text
      ParserState
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_grid_tables ParserT Text ParserState m ()
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                    (Bool
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *).
    PandocMonad m =>
    Bool
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    gridTable Bool
    False ParsecT
      Text
      ParserState
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Bool
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall (m :: * -> *).
    PandocMonad m =>
    Bool
    -> MarkdownParser
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    gridTable Bool
    True)) ParsecT
      Text
      ParserState
      m
      ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    -> [Char]
    -> ParsecT
         Text
         ParserState
         m
         ([Alignment], [Double], Future ParserState [Blocks], F [[Blocks]])
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> "table"
      ParsecT Text ParserState m Text -> ParserT Text ParserState m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m ()
    optional ParsecT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      F Inlines
    caption <- case Maybe (F Inlines)
    frontCaption of
                      Nothing -> F Inlines
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option (Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    forall a. Monoid a => a
    mempty) ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    tableCaption
                      Just c :: F Inlines
    c  -> F Inlines -> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Inlines
    c
      -- renormalize widths if greater than 100%:
      let totalWidth :: Double
    totalWidth = [Double] -> Double
    forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
    sum [Double]
    widths
      let widths' :: [Double]
    widths' = if Double
    totalWidth Double -> Double -> Bool
    forall a. Ord a => a -> a -> Bool
    < 1
                       then [Double]
    widths
                       else (Double -> Double) -> [Double] -> [Double]
    forall a b. (a -> b) -> [a] -> [b]
    map (Double -> Double -> Double
    forall a. Fractional a => a -> a -> a
    / Double
    totalWidth) [Double]
    widths
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
        Inlines
    caption' <- F Inlines
    caption
        [Blocks]
    heads' <- Future ParserState [Blocks]
    heads
        [[Blocks]]
    lns' <- F [[Blocks]]
    lns
        Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> F Blocks) -> Blocks -> F Blocks
    forall a b. (a -> b) -> a -> b
    $ Inlines
    -> [(Alignment, Double)] -> [Blocks] -> [[Blocks]] -> Blocks
    B.table Inlines
    caption' ([Alignment] -> [Double] -> [(Alignment, Double)]
    forall a b. [a] -> [b] -> [(a, b)]
    zip [Alignment]
    aligns [Double]
    widths') [Blocks]
    heads' [[Blocks]]
    lns'

    --
    -- inline
    --

    inlines :: PandocMonad m => MarkdownParser m (F Inlines)
    inlines :: MarkdownParser m (F Inlines)
    inlines = [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline

    inlines1 :: PandocMonad m => MarkdownParser m (F Inlines)
    inlines1 :: MarkdownParser m (F Inlines)
    inlines1 = [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline

    inline :: PandocMonad m => MarkdownParser m (F Inlines)
    inline :: MarkdownParser m (F Inlines)
    inline = [MarkdownParser m (F Inlines)] -> MarkdownParser m (F Inlines)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice [ MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    whitespace
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    bareURL
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    str
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    endline
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    code
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    strongOrEmph
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    note
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    cite
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    bracketedSpan
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    link
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    image
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    math
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    strikeout
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    subscript
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    superscript
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlineNote  -- after superscript because of ^[link](/foo)^
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    autoLink
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    spanHtml
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    rawHtmlInline
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    escapedNewline
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    escapedChar
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    rawLaTeXInline'
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    exampleRef
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    smart
                    , Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines)
    -> (Inline -> Inlines) -> Inline -> F Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inline -> Inlines
    forall a. a -> Many a
    B.singleton (Inline -> F Inlines)
    -> ParsecT Text ParserState m Inline
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Inline
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Inline
    charRef
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    emoji
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    symbol
                    , MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    ltSign
                    ] MarkdownParser m (F Inlines)
    -> [Char] -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> "inline"

    escapedChar' :: PandocMonad m => MarkdownParser m Char
    escapedChar' :: MarkdownParser m Char
    escapedChar' = MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m Char -> MarkdownParser m Char)
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall a b. (a -> b) -> a -> b
    $ do
      Char -> MarkdownParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '\\'
      (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_all_symbols_escapable ParserT Text ParserState m ()
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> (Char -> Bool) -> MarkdownParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy (Bool -> Bool
    not (Bool -> Bool) -> (Char -> Bool) -> Char -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Char -> Bool
    isAlphaNum))
         MarkdownParser m Char
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_angle_brackets_escapable ParserT Text ParserState m ()
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                [Char] -> MarkdownParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf "\\`*_{}[]()>#+-.!~\"<>")
         MarkdownParser m Char
    -> MarkdownParser m Char -> MarkdownParser m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> [Char] -> MarkdownParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf "\\`*_{}[]()>#+-.!~\""

    escapedNewline :: PandocMonad m => MarkdownParser m (F Inlines)
    escapedNewline :: MarkdownParser m (F Inlines)
    escapedNewline = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_escaped_line_breaks
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '\\'
      ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '\n') -- don't consume the newline (see #3730)
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    B.linebreak

    escapedChar :: PandocMonad m => MarkdownParser m (F Inlines)
    escapedChar :: MarkdownParser m (F Inlines)
    escapedChar = do
      Char
    result <- MarkdownParser m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    escapedChar'
      case Char
    result of
           ' ' -> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ 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 -> Inlines
    B.str "\160" -- "\ " is a nonbreaking space
           _   -> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ 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 -> Inlines
    B.str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Char -> Text
    T.singleton Char
    result

    ltSign :: PandocMonad m => MarkdownParser m (F Inlines)
    ltSign :: MarkdownParser m (F Inlines)
    ltSign = do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_raw_html
        ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (ParserT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    notFollowedByHtmlCloser ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParserT Text ParserState m (Tag Text, Text)
    -> ParserT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' ((Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag Tag Text -> Bool
    forall a. NamedTag (Tag a) => Tag a -> Bool
    isBlockTag))
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '<'
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ 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 -> Inlines
    B.str "<"

    exampleRef :: PandocMonad m => MarkdownParser m (F Inlines)
    exampleRef :: MarkdownParser m (F Inlines)
    exampleRef = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_example_lists
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '@'
      Text
    lab <- ParsecT Text ParserState m Char -> ParserT Text ParserState m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char (ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    alphaNum ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf "-_")
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
        ParserState
    st <- Future ParserState ParserState
    forall s. Future s s
    askF
        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
    $ case Text -> Map Text Int -> Maybe Int
    forall k a. Ord k => k -> Map k a -> Maybe a
    M.lookup Text
    lab (ParserState -> Map Text Int
    stateExamples ParserState
    st) of
                      Just n :: Int
    n  -> Text -> Inlines
    B.str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Int -> Text
    forall a. Show a => a -> Text
    tshow Int
    n
                      Nothing -> Text -> Inlines
    B.str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ "@" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    lab

    symbol :: PandocMonad m => MarkdownParser m (F Inlines)
    symbol :: MarkdownParser m (F Inlines)
    symbol = do
      Char
    result <- [Char] -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf "<\\\n\t "
             ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m Char -> ParsecT Text ParserState m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (do ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
     -> ParsecT Text ParserState m Char)
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall a b. (a -> b) -> a -> b
    $ Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '\\'
                         ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' (() ()
    -> ParsecT Text ParserState m (F Blocks)
    -> ParserT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text ParserState m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    rawTeXBlock)
                         Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '\\')
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ 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 -> Inlines
    B.str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Char -> Text
    T.singleton Char
    result

    -- parses inline code, between n `s and n `s
    code :: PandocMonad m => MarkdownParser m (F Inlines)
    code :: MarkdownParser m (F Inlines)
    code = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      [Char]
    starts <- ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '`')
      ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      Text
    result <- (Text -> Text
    trim (Text -> Text) -> ([Text] -> Text) -> [Text] -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Text] -> Text
    T.concat) ([Text] -> Text)
    -> ParsecT Text ParserState m [Text]
    -> ParsecT Text ParserState m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                ParsecT Text ParserState m Text
    -> ParserT Text ParserState m ()
    -> ParsecT Text ParserState m [Text]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    manyTill (ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy (ParserT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    inList ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParserT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    listStart) ParserT Text ParserState m ()
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                          (ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    noneOf "`\n") ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '`') ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
                           (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '\n' ParsecT Text ParserState m Char
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline ParserT Text ParserState m ()
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Text -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return " ")))
                          (ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces ParserT Text ParserState m ()
    -> ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m [Char]
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Int
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    Int -> ParsecT s u m a -> ParsecT s u m [a]
    count ([Char] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [Char]
    starts) (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '`') ParsecT Text ParserState m [Char]
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                          ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '`')))
      Either Text Attr
    rawattr <-
         (Text -> Either Text Attr
    forall a b. a -> Either a b
    Left (Text -> Either Text Attr)
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m (Either Text Attr)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Text -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_raw_attribute ParserT Text ParserState m ()
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    rawAttribute))
        ParsecT Text ParserState m (Either Text Attr)
    -> ParsecT Text ParserState m (Either Text Attr)
    -> ParsecT Text ParserState m (Either Text Attr)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
         (Attr -> Either Text Attr
    forall a b. b -> Either a b
    Right (Attr -> Either Text Attr)
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m (Either Text Attr)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Attr
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m Attr
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option ("",[],[])
             (ParsecT Text ParserState m Attr -> ParsecT Text ParserState m Attr
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_inline_code_attributes ParserT Text ParserState m ()
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m Attr
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    attributes)))
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ 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
    $
        case Either Text Attr
    rawattr of
             Left syn :: Text
    syn   -> Text -> Text -> Inlines
    B.rawInline Text
    syn Text
    result
             Right attr :: Attr
    attr -> Attr -> Text -> Inlines
    B.codeWith Attr
    attr Text
    result

    math :: PandocMonad m => MarkdownParser m (F Inlines)
    math :: MarkdownParser 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.displayMath (Text -> F Inlines)
    -> ParsecT Text ParserState m Text -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (ParsecT Text ParserState m Text
    forall st s (m :: * -> *).
    (HasReaderOptions st, Stream s m Char) =>
    ParserT s st m Text
    mathDisplay ParsecT Text ParserState m Text
    -> (Text -> ParsecT Text ParserState m Text)
    -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Text -> ParsecT Text ParserState m Text
    forall (m :: * -> *) s.
    (PandocMonad m, HasMacros s, HasReaderOptions s) =>
    Text -> ParserT Text s m Text
    applyMacros))
         MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (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 ParserState m Text -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (ParsecT Text ParserState m Text
    forall st s (m :: * -> *).
    (HasReaderOptions st, Stream s m Char) =>
    ParserT s st m Text
    mathInline ParsecT Text ParserState m Text
    -> (Text -> ParsecT Text ParserState m Text)
    -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Text -> ParsecT Text ParserState m Text
    forall (m :: * -> *) s.
    (PandocMonad m, HasMacros s, HasReaderOptions s) =>
    Text -> ParserT Text s m Text
    applyMacros)) MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a s st (m :: * -> *).
    Monoid a =>
    ParserT s st m a -> ParserT s st m a -> ParserT s st m a
    <+?>
                   (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_smart ParserT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> (Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines)
    -> ParsecT Text ParserState m Inlines
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Inlines
    forall s (m :: * -> *) st.
    Stream s m Char =>
    ParserT s st m Inlines
    apostrophe)
                    MarkdownParser m (F Inlines)
    -> ParserT Text ParserState m () -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    space ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Char -> Bool) -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy Char -> Bool
    isPunctuation))

    -- Parses material enclosed in *s, **s, _s, or __s.
    -- Designed to avoid backtracking.
    enclosure :: PandocMonad m
              => Char
              -> MarkdownParser m (F Inlines)
    enclosure :: Char -> MarkdownParser m (F Inlines)
    enclosure c :: Char
    c = do
      -- we can't start an enclosure with _ if after a string and
      -- the intraword_underscores extension is enabled:
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_intraword_underscores
        ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Bool -> ParserT Text ParserState m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Char
    c Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == '*')
        ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Bool -> ParserT Text ParserState m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParserT Text ParserState m ())
    -> ParsecT Text ParserState m Bool -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< ParsecT Text ParserState m Bool
    forall s (m :: * -> *) a st.
    (Stream s m a, HasLastStrPosition st) =>
    ParserT s st m Bool
    notAfterString)
      Text
    cs <- ParserT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c)
      (Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Inlines
    B.str Text
    cs) F Inlines -> F Inlines -> F Inlines
    forall a. Semigroup a => a -> a -> a
    <>) (F Inlines -> F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    whitespace
        MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
            case Text -> Int
    T.length Text
    cs of
                 3 -> Char -> MarkdownParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> MarkdownParser m (F Inlines)
    three Char
    c
                 2 -> Char -> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> F Inlines -> MarkdownParser m (F Inlines)
    two   Char
    c F Inlines
    forall a. Monoid a => a
    mempty
                 1 -> Char -> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> F Inlines -> MarkdownParser m (F Inlines)
    one   Char
    c F Inlines
    forall a. Monoid a => a
    mempty
                 _ -> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (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 -> Inlines
    B.str Text
    cs)

    ender :: PandocMonad m => Char -> Int -> MarkdownParser m ()
    ender :: Char -> Int -> MarkdownParser m ()
    ender c :: Char
    c n :: Int
    n = MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m () -> MarkdownParser m ())
    -> MarkdownParser m () -> MarkdownParser m ()
    forall a b. (a -> b) -> a -> b
    $ do
      Int
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState 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
    n (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char Char
    c)
      Bool -> MarkdownParser m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Char
    c Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == '*')
        MarkdownParser m () -> MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Extension -> MarkdownParser m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_intraword_underscores
        MarkdownParser m () -> MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m Char -> MarkdownParser 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    alphaNum

    -- Parse inlines til you hit one c or a sequence of two cs.
    -- If one c, emit emph and then parse two.
    -- If two cs, emit strong and then parse one.
    -- Otherwise, emit ccc then the results.
    three :: PandocMonad m => Char -> MarkdownParser m (F Inlines)
    three :: Char -> MarkdownParser m (F Inlines)
    three c :: Char
    c = do
      F Inlines
    contents <- [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy (Char -> Int -> ParsecT Text ParserState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> Int -> MarkdownParser m ()
    ender Char
    c 1) ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline)
      (Char -> Int -> ParsecT Text ParserState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> Int -> MarkdownParser m ()
    ender Char
    c 3 ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasLastStrPosition st) =>
    ParserT s st m ()
    updateLastStrPos ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return ((Inlines -> Inlines
    B.strong (Inlines -> Inlines) -> (Inlines -> Inlines) -> Inlines -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inlines -> Inlines
    B.emph) (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    contents))
        MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Char -> Int -> ParsecT Text ParserState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> Int -> MarkdownParser m ()
    ender Char
    c 2 ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasLastStrPosition st) =>
    ParserT s st m ()
    updateLastStrPos ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Char -> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> F Inlines -> MarkdownParser m (F Inlines)
    one Char
    c (Inlines -> Inlines
    B.strong (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    contents))
        MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Char -> Int -> ParsecT Text ParserState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> Int -> MarkdownParser m ()
    ender Char
    c 1 ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasLastStrPosition st) =>
    ParserT s st m ()
    updateLastStrPos ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Char -> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> F Inlines -> MarkdownParser m (F Inlines)
    two Char
    c (Inlines -> Inlines
    B.emph (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    contents))
        MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Inlines
    B.str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Text
    T.pack [Char
    c,Char
    c,Char
    c]) F Inlines -> F Inlines -> F Inlines
    forall a. Semigroup a => a -> a -> a
    <> F Inlines
    contents)

    -- Parse inlines til you hit two c's, and emit strong.
    -- If you never do hit two cs, emit ** plus inlines parsed.
    two :: PandocMonad m => Char -> F Inlines -> MarkdownParser m (F Inlines)
    two :: Char -> F Inlines -> MarkdownParser m (F Inlines)
    two c :: Char
    c prefix' :: F Inlines
    prefix' = do
      F Inlines
    contents <- [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy (Char -> Int -> ParsecT Text ParserState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> Int -> MarkdownParser m ()
    ender Char
    c 2) ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline)
      (Char -> Int -> ParsecT Text ParserState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> Int -> MarkdownParser m ()
    ender Char
    c 2 ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasLastStrPosition st) =>
    ParserT s st m ()
    updateLastStrPos ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                    F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> Inlines
    B.strong (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (F Inlines
    prefix' F Inlines -> F Inlines -> F Inlines
    forall a. Semigroup a => a -> a -> a
    <> F Inlines
    contents)))
        MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Inlines
    B.str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ [Char] -> Text
    T.pack [Char
    c,Char
    c]) F Inlines -> F Inlines -> F Inlines
    forall a. Semigroup a => a -> a -> a
    <> (F Inlines
    prefix' F Inlines -> F Inlines -> F Inlines
    forall a. Semigroup a => a -> a -> a
    <> F Inlines
    contents))

    -- Parse inlines til you hit a c, and emit emph.
    -- If you never hit a c, emit * plus inlines parsed.
    one :: PandocMonad m => Char -> F Inlines -> MarkdownParser m (F Inlines)
    one :: Char -> F Inlines -> MarkdownParser m (F Inlines)
    one c :: Char
    c prefix' :: F Inlines
    prefix' = do
      F Inlines
    contents <- [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (  (ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy (Char -> Int -> ParsecT Text ParserState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> Int -> MarkdownParser m ()
    ender Char
    c 1) ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline)
                               MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ([Char] -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string [Char
    c,Char
    c] ParsecT Text ParserState m [Char]
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                                        ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) t a u.
    (Stream s m t, Show a) =>
    ParsecT s u m a -> ParsecT s u m ()
    notFollowedBy (Char -> Int -> ParsecT Text ParserState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> Int -> MarkdownParser m ()
    ender Char
    c 1) ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                                        Char -> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> F Inlines -> MarkdownParser m (F Inlines)
    two Char
    c F Inlines
    forall a. Monoid a => a
    mempty) )
      (Char -> Int -> ParsecT Text ParserState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> Int -> MarkdownParser m ()
    ender Char
    c 1 ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasLastStrPosition st) =>
    ParserT s st m ()
    updateLastStrPos ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> Inlines
    B.emph (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (F Inlines
    prefix' F Inlines -> F Inlines -> F Inlines
    forall a. Semigroup a => a -> a -> a
    <> F Inlines
    contents)))
        MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Inlines
    B.str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Char -> Text
    T.singleton Char
    c) F Inlines -> F Inlines -> F Inlines
    forall a. Semigroup a => a -> a -> a
    <> (F Inlines
    prefix' F Inlines -> F Inlines -> F Inlines
    forall a. Semigroup a => a -> a -> a
    <> F Inlines
    contents))

    strongOrEmph :: PandocMonad m => MarkdownParser m (F Inlines)
    strongOrEmph :: MarkdownParser m (F Inlines)
    strongOrEmph =  Char -> MarkdownParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> MarkdownParser m (F Inlines)
    enclosure '*' MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Char -> MarkdownParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> MarkdownParser m (F Inlines)
    enclosure '_'

    -- | Parses a list of inlines between start and end delimiters.
    inlinesBetween :: PandocMonad m
                   => (Show b)
                   => MarkdownParser m a
                   -> MarkdownParser m b
                   -> MarkdownParser m (F Inlines)
    inlinesBetween :: MarkdownParser m a
    -> MarkdownParser m b -> MarkdownParser m (F Inlines)
    inlinesBetween start :: MarkdownParser m a
    start end :: MarkdownParser m b
    end =
      (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 ParserState m [F Inlines]
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m [F Inlines]
    -> ParsecT Text ParserState m [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m a
    start MarkdownParser m a
    -> ParsecT Text ParserState m [F Inlines]
    -> ParsecT Text ParserState m [F Inlines]
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m (F Inlines)
    -> MarkdownParser m b -> ParsecT Text ParserState 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 MarkdownParser m (F Inlines)
    inner MarkdownParser m b
    end)
        where inner :: MarkdownParser m (F Inlines)
    inner      = MarkdownParser m (F Inlines)
    innerSpace MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' (() () -> MarkdownParser m (F Inlines) -> ParserT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    whitespace) ParserT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline)
              innerSpace :: MarkdownParser m (F Inlines)
    innerSpace = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    whitespace MarkdownParser m (F Inlines)
    -> ParserT Text ParserState m () -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* MarkdownParser m b -> ParserT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' MarkdownParser m b
    end

    strikeout :: PandocMonad m => MarkdownParser m (F Inlines)
    strikeout :: MarkdownParser 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)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
     (Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_strikeout ParserT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParserT Text ParserState m ()
    -> MarkdownParser m [Char] -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) b a.
    (PandocMonad m, Show b) =>
    MarkdownParser m a
    -> MarkdownParser m b -> MarkdownParser m (F Inlines)
    inlinesBetween ParserT Text ParserState m ()
    forall u. ParsecT Text u m ()
    strikeStart MarkdownParser m [Char]
    forall u. ParsecT Text u m [Char]
    strikeEnd)
        where strikeStart :: ParsecT Text u m ()
    strikeStart = [Char] -> ParsecT Text u m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "~~" ParsecT Text u m [Char]
    -> ParsecT Text u m Char -> ParsecT Text u m Char
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text u m Char -> ParsecT Text u 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 u m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    nonspaceChar
                            ParsecT Text u m Char -> ParsecT Text u m () -> ParsecT Text u m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text u m Char -> ParsecT Text u 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 u m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '~')
              strikeEnd :: ParsecT Text u m [Char]
    strikeEnd   = ParsecT Text u m [Char] -> ParsecT Text u m [Char]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text u m [Char] -> ParsecT Text u m [Char])
    -> ParsecT Text u m [Char] -> ParsecT Text u m [Char]
    forall a b. (a -> b) -> a -> b
    $ [Char] -> ParsecT Text u m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "~~"

    superscript :: PandocMonad m => MarkdownParser m (F Inlines)
    superscript :: MarkdownParser 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)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_superscript
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '^'
      [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Inlines)
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState 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 (do ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
                                ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
                                MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline) (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '^'))

    subscript :: PandocMonad m => MarkdownParser m (F Inlines)
    subscript :: MarkdownParser 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)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_subscript
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '~'
      [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Inlines)
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState 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 (do ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
                                ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
                                MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline) (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '~'))

    whitespace :: PandocMonad m => MarkdownParser m (F Inlines)
    whitespace :: MarkdownParser m (F Inlines)
    whitespace = ParserT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar ParserT Text ParserState m Char
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines)
    -> ParsecT Text ParserState m Inlines
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (ParsecT Text ParserState m Inlines
    lb ParsecT Text ParserState m Inlines
    -> ParsecT Text ParserState m Inlines
    -> ParsecT Text ParserState m Inlines
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m Inlines
    forall u. ParsecT Text u m Inlines
    regsp) MarkdownParser m (F Inlines)
    -> [Char] -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> [Char] -> ParsecT s u m a
    <?> "whitespace"
      where lb :: ParsecT Text ParserState m Inlines
    lb = ParserT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar ParserT Text ParserState m Char
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParserT Text ParserState m Char -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParserT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m Inlines
    -> ParsecT Text ParserState m Inlines
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Inlines
    -> ParsecT Text ParserState m Inlines
    -> ParsecT Text ParserState m Inlines
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option Inlines
    B.space (MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    endline MarkdownParser m (F Inlines)
    -> ParsecT Text ParserState m Inlines
    -> ParsecT Text ParserState m Inlines
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Inlines -> ParsecT Text ParserState m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    B.linebreak)
            regsp :: ParsecT Text u m Inlines
    regsp = ParsecT Text u m Char -> ParsecT Text u m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text u m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar ParsecT Text u m ()
    -> ParsecT Text u m Inlines -> ParsecT Text u m Inlines
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Inlines -> ParsecT Text u m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    B.space

    nonEndline :: PandocMonad m => ParserT Text st m Char
    nonEndline :: ParserT Text st m Char
    nonEndline = (Char -> Bool) -> ParserT Text st m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    (Char -> Bool) -> ParsecT s u m Char
    satisfy (Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    /='\n')

    str :: PandocMonad m => MarkdownParser m (F Inlines)
    str :: MarkdownParser m (F Inlines)
    str = do
      Text
    result <- [Text] -> Text
    forall a. Monoid a => [a] -> a
    mconcat ([Text] -> Text)
    -> ParsecT Text ParserState m [Text]
    -> ParsecT Text ParserState m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1
                 ( (Char -> Bool) -> ParsecT Text ParserState m Text
    forall (m :: * -> *) st.
    Monad m =>
    (Char -> Bool) -> ParserT Text st m Text
    take1WhileP Char -> Bool
    isAlphaNum
                  ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState 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 ParserState m Char
    -> ParsecT Text ParserState m Text
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text ParserState m Char -> ParsecT Text ParserState m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '.' ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m Char
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '.')) )
      ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasLastStrPosition st) =>
    ParserT s st m ()
    updateLastStrPos
      (do Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_smart
          Set Text
    abbrevs <- (ReaderOptions -> Set Text)
    -> ParserT Text ParserState m (Set Text)
    forall st s (m :: * -> *) t b.
    (HasReaderOptions st, Stream s m t) =>
    (ReaderOptions -> b) -> ParserT s st m b
    getOption ReaderOptions -> Set Text
    readerAbbreviations
          if Bool -> Bool
    not (Text -> Bool
    T.null Text
    result) Bool -> Bool -> Bool
    && Text -> Char
    T.last Text
    result Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == '.' Bool -> Bool -> Bool
    && Text
    result Text -> Set Text -> Bool
    forall a. Ord a => a -> Set a -> Bool
    `Set.member` Set Text
    abbrevs
             then MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (do F Inlines
    ils <- MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    whitespace
                          -- ?? lookAhead alphaNum
                          -- replace space after with nonbreaking space
                          -- if softbreak, move before abbrev if possible (#4635)
                          F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
                            Inlines
    ils' <- F Inlines
    ils
                            case Inlines -> [Inline]
    forall a. Many a -> [a]
    B.toList Inlines
    ils' of
                                 [Space] ->
                                     Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Inlines
    B.str Text
    result Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Text -> Inlines
    B.str "\160")
                                 _ -> Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Inlines
    B.str Text
    result Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    ils'))
                    MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Inlines
    B.str Text
    result))
             else F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Inlines
    B.str Text
    result)))
         MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Inlines
    B.str Text
    result))

    -- an endline character that can be treated as a space, not a structural break
    endline :: PandocMonad m => MarkdownParser m (F Inlines)
    endline :: MarkdownParser m (F Inlines)
    endline = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    newline
      ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
      ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState ParsecT Text ParserState m ParserState
    -> (ParserState -> ParsecT Text ParserState m ())
    -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Bool -> ParsecT Text ParserState m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParsecT Text ParserState m ())
    -> (ParserState -> Bool)
    -> ParserState
    -> ParsecT Text ParserState m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ParserState -> Bool
    stateAllowLineBreaks
      -- parse potential list-starts differently if in a list:
      ParsecT Text ParserState m () -> ParsecT Text ParserState 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 ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    inList ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    listStart)
      Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_lists_without_preceding_blankline ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m () -> ParsecT Text ParserState 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 ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    listStart
      Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_blank_before_blockquote ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    emailBlockQuoteStart
      Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_blank_before_header ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char -> ParsecT Text ParserState m ())
    -> (Char -> ParsecT Text ParserState m Char)
    -> Char
    -> ParsecT Text ParserState m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char (Char -> ParsecT Text ParserState m ())
    -> ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
    =<< ParsecT Text ParserState m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    atxChar) -- atx header
      Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_backtick_code_blocks ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
         ParsecT Text ParserState m () -> ParsecT Text ParserState 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 ParserState m (F Blocks)
    -> ParsecT Text ParserState m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ (ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '`') ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m (F Blocks)
    -> ParsecT Text ParserState m (F Blocks)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    codeBlockFenced))
      ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    notFollowedByHtmlCloser
      ParsecT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    notFollowedByDivCloser
      (ParsecT Text ParserState m ()
    forall s (m :: * -> *) t u.
    (Stream s m t, Show t) =>
    ParsecT s u m ()
    eof ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Inlines
    forall a. Monoid a => a
    mempty)
        MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_hard_line_breaks ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    B.linebreak))
        MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_ignore_line_breaks ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return F Inlines
    forall a. Monoid a => a
    mempty)
        MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser 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 ParserState m Char -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    B.softbreak))

    --
    -- links
    --

    -- a reference label for a link
    reference :: PandocMonad m => MarkdownParser m (F Inlines, Text)
    reference :: MarkdownParser m (F Inlines, Text)
    reference = do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_footnotes ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParserT Text ParserState m [Char] -> ParserT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' ([Char] -> ParserT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "[^")
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_citations ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParserT Text ParserState m [Char] -> ParserT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' ([Char] -> ParserT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "[@")
      ParsecT Text ParserState m (F Inlines)
    -> MarkdownParser m (F Inlines, Text)
    forall (m :: * -> *) st a.
    Monad m =>
    ParsecT Text st m a -> ParsecT Text st m (a, Text)
    withRaw (ParsecT Text ParserState m (F Inlines)
     -> MarkdownParser m (F Inlines, Text))
    -> ParsecT Text ParserState m (F Inlines)
    -> MarkdownParser m (F Inlines, Text)
    forall a b. (a -> b) -> a -> b
    $ F Inlines -> F Inlines
    forall s. Future s Inlines -> Future s Inlines
    trimInlinesF (F Inlines -> F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    -> ParsecT Text ParserState m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlinesInBalancedBrackets

    parenthesizedChars :: PandocMonad m => MarkdownParser m Text
    parenthesizedChars :: MarkdownParser m Text
    parenthesizedChars = do
      Text
    result <- Char
    -> Char -> ParserT Text ParserState m Char -> MarkdownParser m Text
    forall s (m :: * -> *) st.
    Stream s m Char =>
    Char -> Char -> ParserT s st m Char -> ParserT s st m Text
    charsInBalanced '(' ')' ParserT Text ParserState m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    litChar
      Text -> MarkdownParser m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> MarkdownParser m Text) -> Text -> MarkdownParser m Text
    forall a b. (a -> b) -> a -> b
    $ "(" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    result Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> ")"

    -- source for a link, with optional title
    source :: PandocMonad m => MarkdownParser m (Text, Text)
    source :: MarkdownParser m (Text, Text)
    source = do
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '('
      ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      let urlChunk :: ParsecT Text ParserState m Text
    urlChunk =
                ParsecT Text ParserState m Text -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    parenthesizedChars
            ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf " )") ParserT Text ParserState m ()
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Int
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Text
    forall s (m :: * -> *) st.
    (Stream s m Char, Monad m) =>
    Int -> ParsecT s st m Char -> ParsecT s st m Text
    countChar 1 ParsecT Text ParserState m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    litChar)
            ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m Text -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text ParserState m Char -> ParsecT Text ParserState m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar ParsecT Text ParserState m Text
    -> ParserT Text ParserState m () -> ParsecT Text ParserState m Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf "\"')"))
      let sourceURL :: ParsecT Text ParserState m Text
    sourceURL = ([Text] -> Text
    T.unwords ([Text] -> Text) -> ([Text] -> [Text]) -> [Text] -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> [Text]
    T.words (Text -> [Text]) -> ([Text] -> Text) -> [Text] -> [Text]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Text] -> Text
    T.concat) ([Text] -> Text)
    -> ParsecT Text ParserState m [Text]
    -> ParsecT Text ParserState m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m [Text]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many ParsecT Text ParserState m Text
    urlChunk
      let betweenAngles :: ParsecT Text ParserState m Text
    betweenAngles = ParsecT Text ParserState m Text -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text ParserState m Text
     -> ParsecT Text ParserState m Text)
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall a b. (a -> b) -> a -> b
    $
             Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '<' ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Text
    forall s (m :: * -> *) t st a.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
    manyTillChar ParsecT Text ParserState m Char
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
    litChar (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '>')
      Text
    src <- ParsecT Text ParserState m Text -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ParsecT Text ParserState m Text
    betweenAngles ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text ParserState m Text
    sourceURL
      Text
    tit <- Text
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m 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 ParserState m Text
     -> ParsecT Text ParserState m Text)
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m Text -> ParsecT Text ParserState m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text ParserState m Text
     -> ParsecT Text ParserState m Text)
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall a b. (a -> b) -> a -> b
    $ ParserT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    spnl ParserT Text ParserState m ()
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    linkTitle
      ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ')'
      (Text, Text) -> MarkdownParser m (Text, Text)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Text
    escapeURI (Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    trimr Text
    src, Text
    tit)

    linkTitle :: PandocMonad m => MarkdownParser m Text
    linkTitle :: MarkdownParser m Text
    linkTitle = Char -> MarkdownParser m Text
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> MarkdownParser m Text
    quotedTitle '"' MarkdownParser m Text
    -> MarkdownParser m Text -> MarkdownParser m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Char -> MarkdownParser m Text
    forall (m :: * -> *).
    PandocMonad m =>
    Char -> MarkdownParser m Text
    quotedTitle '\''

    link :: PandocMonad m => MarkdownParser m (F Inlines)
    link :: MarkdownParser m (F Inlines)
    link = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      ParserState
    st <- ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      Bool -> ParsecT Text ParserState m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParsecT Text ParserState m ())
    -> Bool -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ ParserState -> Bool
    stateAllowLinks ParserState
    st
      ParserState -> ParsecT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => u -> ParsecT s u m ()
    setState (ParserState -> ParsecT Text ParserState m ())
    -> ParserState -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ ParserState
    st{ stateAllowLinks :: Bool
    stateAllowLinks = Bool
    False }
      (lab :: F Inlines
    lab,raw :: Text
    raw) <- MarkdownParser m (F Inlines, Text)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F Inlines, Text)
    reference
      ParserState -> ParsecT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => u -> ParsecT s u m ()
    setState (ParserState -> ParsecT Text ParserState m ())
    -> ParserState -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ ParserState
    st{ stateAllowLinks :: Bool
    stateAllowLinks = Bool
    True }
      (Attr -> Text -> Text -> Inlines -> Inlines)
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    (Attr -> Text -> Text -> Inlines -> Inlines)
    -> F Inlines -> MarkdownParser m (F Inlines)
    regLink Attr -> Text -> Text -> Inlines -> Inlines
    B.linkWith F Inlines
    lab MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Attr -> Text -> Text -> Inlines -> Inlines)
    -> (F Inlines, Text) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    (Attr -> Text -> Text -> Inlines -> Inlines)
    -> (F Inlines, Text) -> MarkdownParser m (F Inlines)
    referenceLink Attr -> Text -> Text -> Inlines -> Inlines
    B.linkWith (F Inlines
    lab,Text
    raw)

    bracketedSpan :: PandocMonad m => MarkdownParser m (F Inlines)
    bracketedSpan :: MarkdownParser m (F Inlines)
    bracketedSpan = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_bracketed_spans
      (lab :: F Inlines
    lab,_) <- MarkdownParser m (F Inlines, Text)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F Inlines, Text)
    reference
      Attr
    attr <- MarkdownParser m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    attributes
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ if Attr -> Bool
    isSmallCaps Attr
    attr
                  then Inlines -> Inlines
    B.smallcaps (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    lab
                  else Attr -> Inlines -> Inlines
    B.spanWith Attr
    attr (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    lab

    -- | We treat a span as SmallCaps if class is "smallcaps" (and
    -- no other attributes are set or if style is "font-variant:small-caps"
    -- (and no other attributes are set).
    isSmallCaps :: Attr -> Bool
    isSmallCaps :: Attr -> Bool
    isSmallCaps ("",["smallcaps"],[]) = Bool
    True
    isSmallCaps ("",[],kvs :: [(Text, Text)]
    kvs) =
      case Text -> [(Text, Text)] -> Maybe Text
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup "style" [(Text, Text)]
    kvs of
           Just s :: Text
    s -> Text -> Text
    T.toLower ((Char -> Bool) -> Text -> Text
    T.filter (Char -> [Char] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `notElem` [' ', '\t', ';']) Text
    s) Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    ==
                        "font-variant:small-caps"
           Nothing -> Bool
    False
    isSmallCaps _ = Bool
    False

    regLink :: PandocMonad m
            => (Attr -> Text -> Text -> Inlines -> Inlines)
            -> F Inlines
            -> MarkdownParser m (F Inlines)
    regLink :: (Attr -> Text -> Text -> Inlines -> Inlines)
    -> F Inlines -> MarkdownParser m (F Inlines)
    regLink constructor :: Attr -> Text -> Text -> Inlines -> Inlines
    constructor lab :: F Inlines
    lab = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      (src :: Text
    src, tit :: Text
    tit) <- MarkdownParser m (Text, Text)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (Text, Text)
    source
      Attr
    attr <- Attr
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m Attr
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option Attr
    nullAttr (ParsecT Text ParserState m Attr
     -> ParsecT Text ParserState m Attr)
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m Attr
    forall a b. (a -> b) -> a -> b
    $
              Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_link_attributes ParserT Text ParserState m ()
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m Attr
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    attributes
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Attr -> Text -> Text -> Inlines -> Inlines
    constructor Attr
    attr Text
    src Text
    tit (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    lab

    -- a link like [this][ref] or [this][] or [this]
    referenceLink :: PandocMonad m
                  => (Attr -> Text -> Text -> Inlines -> Inlines)
                  -> (F Inlines, Text)
                  -> MarkdownParser m (F Inlines)
    referenceLink :: (Attr -> Text -> Text -> Inlines -> Inlines)
    -> (F Inlines, Text) -> MarkdownParser m (F Inlines)
    referenceLink constructor :: Attr -> Text -> Text -> Inlines -> Inlines
    constructor (lab :: F Inlines
    lab, raw :: Text
    raw) = do
      Bool
    sp <- (Bool
    True Bool
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Bool
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ' ')) ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Bool -> ParsecT Text ParserState m Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    False
      (_,raw' :: Text
    raw') <- (F Inlines, Text)
    -> ParsecT Text ParserState m (F Inlines, Text)
    -> ParsecT Text ParserState m (F Inlines, Text)
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option (F Inlines
    forall a. Monoid a => a
    mempty, "") (ParsecT Text ParserState m (F Inlines, Text)
     -> ParsecT Text ParserState m (F Inlines, Text))
    -> ParsecT Text ParserState m (F Inlines, Text)
    -> ParsecT Text ParserState m (F Inlines, Text)
    forall a b. (a -> b) -> a -> b
    $
          ParsecT Text ParserState m (F Inlines, Text)
    -> ParsecT Text ParserState m (F Inlines, Text)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead (ParsecT Text ParserState m (F Inlines, Text)
    -> ParsecT Text ParserState m (F Inlines, Text)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (do Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_citations
                             Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_spaced_reference_links ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParserT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    spnl
                             MarkdownParser m (F [Citation])
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F [Citation])
    normalCite
                             (F Inlines, Text) -> ParsecT Text ParserState m (F Inlines, Text)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines
    forall a. Monoid a => a
    mempty, "")))
          ParsecT Text ParserState m (F Inlines, Text)
    -> ParsecT Text ParserState m (F Inlines, Text)
    -> ParsecT Text ParserState m (F Inlines, Text)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
          ParsecT Text ParserState m (F Inlines, Text)
    -> ParsecT Text ParserState m (F Inlines, Text)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try ((Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardDisabled Extension
    Ext_spaced_reference_links ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParserT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    spnl) ParserT Text ParserState m ()
    -> ParsecT Text ParserState m (F Inlines, Text)
    -> ParsecT Text ParserState m (F Inlines, Text)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m (F Inlines, Text)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F Inlines, Text)
    reference)
      Bool
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
    when (Text
    raw' Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == "") (ParserT Text ParserState m () -> ParserT Text ParserState m ())
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_shortcut_reference_links
      let labIsRef :: Bool
    labIsRef = Text
    raw' Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == "" Bool -> Bool -> Bool
    || Text
    raw' Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == "[]"
      let key :: Key
    key = Text -> Key
    toKey (Text -> Key) -> Text -> Key
    forall a b. (a -> b) -> a -> b
    $ if Bool
    labIsRef then Text
    raw else Text
    raw'
      F Inlines
    parsedRaw <- MarkdownParser m (F Inlines)
    -> Text -> MarkdownParser m (F Inlines)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlines Text
    raw'
      F Inlines
    fallback  <- MarkdownParser m (F Inlines)
    -> Text -> MarkdownParser m (F Inlines)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlines (Text -> MarkdownParser m (F Inlines))
    -> Text -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    dropBrackets Text
    raw
      Bool
    implicitHeaderRefs <- Bool
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState 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 ParserState m Bool
     -> ParsecT Text ParserState m Bool)
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    forall a b. (a -> b) -> a -> b
    $
                             Bool
    True Bool
    -> ParserT Text ParserState m () -> ParsecT Text ParserState m Bool
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_implicit_header_references
      let makeFallback :: F Inlines
    makeFallback = do
           Inlines
    parsedRaw' <- F Inlines
    parsedRaw
           Inlines
    fallback' <- F Inlines
    fallback
           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 -> Inlines
    B.str "[" Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    fallback' Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Text -> Inlines
    B.str "]" Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <>
                    (if Bool
    sp Bool -> Bool -> Bool
    && Bool -> Bool
    not (Text -> Bool
    T.null Text
    raw) then Inlines
    B.space else Inlines
    forall a. Monoid a => a
    mempty) Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <>
                    Inlines
    parsedRaw'
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
        KeyTable
    keys <- (ParserState -> KeyTable) -> Future ParserState KeyTable
    forall s a. (s -> a) -> Future s a
    asksF ParserState -> KeyTable
    stateKeys
        case Key -> KeyTable -> Maybe ((Text, Text), Attr)
    forall k a. Ord k => k -> Map k a -> Maybe a
    M.lookup Key
    key KeyTable
    keys of
           Nothing        ->
             if Bool
    implicitHeaderRefs
                then do
                  KeyTable
    headerKeys <- (ParserState -> KeyTable) -> Future ParserState KeyTable
    forall s a. (s -> a) -> Future s a
    asksF ParserState -> KeyTable
    stateHeaderKeys
                  case Key -> KeyTable -> Maybe ((Text, Text), Attr)
    forall k a. Ord k => k -> Map k a -> Maybe a
    M.lookup Key
    key KeyTable
    headerKeys of
                       Just ((src :: Text
    src, tit :: Text
    tit), _) -> Attr -> Text -> Text -> Inlines -> Inlines
    constructor Attr
    nullAttr Text
    src Text
    tit (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    lab
                       Nothing              -> F Inlines
    makeFallback
                else F Inlines
    makeFallback
           Just ((src :: Text
    src,tit :: Text
    tit), attr :: Attr
    attr) -> Attr -> Text -> Text -> Inlines -> Inlines
    constructor Attr
    attr Text
    src Text
    tit (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    lab

    dropBrackets :: Text -> Text
    dropBrackets :: Text -> Text
    dropBrackets = Text -> Text
    dropRB (Text -> Text) -> (Text -> Text) -> Text -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text
    dropLB
      where dropRB :: Text -> Text
    dropRB (Text -> Maybe (Text, Char)
    T.unsnoc -> Just (xs :: Text
    xs,']')) = Text
    xs
            dropRB xs :: Text
    xs                          = Text
    xs
            dropLB :: Text -> Text
    dropLB (Text -> Maybe (Char, Text)
    T.uncons -> Just ('[',xs :: Text
    xs)) = Text
    xs
            dropLB xs :: Text
    xs                          = Text
    xs

    bareURL :: PandocMonad m => MarkdownParser m (F Inlines)
    bareURL :: MarkdownParser m (F Inlines)
    bareURL = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_autolink_bare_uris
      ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState ParsecT Text ParserState m ParserState
    -> (ParserState -> ParserT Text ParserState m ())
    -> ParserT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Bool -> ParserT Text ParserState m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParserT Text ParserState m ())
    -> (ParserState -> Bool)
    -> ParserState
    -> ParserT Text ParserState m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ParserState -> Bool
    stateAllowLinks
      (cls :: Text
    cls, (orig :: Text
    orig, src :: Text
    src)) <- (("uri",) ((Text, Text) -> (Text, (Text, Text)))
    -> ParsecT Text ParserState m (Text, Text)
    -> ParsecT Text ParserState m (Text, (Text, Text))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (Text, Text)
    forall s (m :: * -> *) st.
    Stream s m Char =>
    ParserT s st m (Text, Text)
    uri) ParsecT Text ParserState m (Text, (Text, Text))
    -> ParsecT Text ParserState m (Text, (Text, Text))
    -> ParsecT Text ParserState m (Text, (Text, Text))
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (("email",) ((Text, Text) -> (Text, (Text, Text)))
    -> ParsecT Text ParserState m (Text, Text)
    -> ParsecT Text ParserState m (Text, (Text, Text))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (Text, Text)
    forall s (m :: * -> *) st.
    Stream s m Char =>
    ParserT s st m (Text, Text)
    emailAddress)
      ParsecT Text ParserState m (Tag Text, Text)
    -> ParserT Text ParserState 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 ParserState m (Tag Text, Text)
     -> ParserT Text ParserState m ())
    -> ParsecT Text ParserState m (Tag Text, Text)
    -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m (Tag Text, Text)
    -> ParsecT Text ParserState m (Tag Text, Text)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text ParserState m (Tag Text, Text)
     -> ParsecT Text ParserState m (Tag Text, Text))
    -> ParsecT Text ParserState m (Tag Text, Text)
    -> ParsecT Text ParserState m (Tag Text, Text)
    forall a b. (a -> b) -> a -> b
    $ ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    spaces ParserT Text ParserState m ()
    -> ParsecT Text ParserState m (Tag Text, Text)
    -> ParsecT Text ParserState m (Tag Text, Text)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> (Tag Text -> Bool) -> ParsecT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag (Tag Text -> Tag Text -> Bool
    forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
    ~== Text -> Tag Text
    forall str. str -> Tag str
    TagClose ("a" :: Text))
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ 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
    $ Attr -> Text -> Text -> Inlines -> Inlines
    B.linkWith ("",[Text
    cls],[]) Text
    src "" (Text -> Inlines
    B.str Text
    orig)

    autoLink :: PandocMonad m => MarkdownParser m (F Inlines)
    autoLink :: MarkdownParser m (F Inlines)
    autoLink = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState ParsecT Text ParserState m ParserState
    -> (ParserState -> ParsecT Text ParserState m ())
    -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Bool -> ParsecT Text ParserState m ()
    forall (f :: * -> *). Alternative f => Bool -> f ()
    guard (Bool -> ParsecT Text ParserState m ())
    -> (ParserState -> Bool)
    -> ParserState
    -> ParsecT Text ParserState m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ParserState -> Bool
    stateAllowLinks
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '<'
      (cls :: Text
    cls, (orig :: Text
    orig, src :: Text
    src)) <- (("uri",) ((Text, Text) -> (Text, (Text, Text)))
    -> ParsecT Text ParserState m (Text, Text)
    -> ParsecT Text ParserState m (Text, (Text, Text))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (Text, Text)
    forall s (m :: * -> *) st.
    Stream s m Char =>
    ParserT s st m (Text, Text)
    uri) ParsecT Text ParserState m (Text, (Text, Text))
    -> ParsecT Text ParserState m (Text, (Text, Text))
    -> ParsecT Text ParserState m (Text, (Text, Text))
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (("email",) ((Text, Text) -> (Text, (Text, Text)))
    -> ParsecT Text ParserState m (Text, Text)
    -> ParsecT Text ParserState m (Text, (Text, Text))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (Text, Text)
    forall s (m :: * -> *) st.
    Stream s m Char =>
    ParserT s st m (Text, Text)
    emailAddress)
      -- in rare cases, something may remain after the uri parser
      -- is finished, because the uri parser tries to avoid parsing
      -- final punctuation.  for example:  in `<http://hi---there>`,
      -- the URI parser will stop before the dashes.
      Text
    extra <- Text -> Text
    fromEntities (Text -> Text)
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Text
    forall s (m :: * -> *) t st a.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
    manyTillChar ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    nonspaceChar (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '>')
      Attr
    attr  <- Attr
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m Attr
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option ("", [Text
    cls], []) (ParsecT Text ParserState m Attr
     -> ParsecT Text ParserState m Attr)
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m Attr
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m Attr -> ParsecT Text ParserState m Attr
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text ParserState m Attr
     -> ParsecT Text ParserState m Attr)
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m Attr
    forall a b. (a -> b) -> a -> b
    $
                Extension -> ParsecT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_link_attributes ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m Attr
    -> ParsecT Text ParserState m Attr
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    attributes
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ 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
    $ Attr -> Text -> Text -> Inlines -> Inlines
    B.linkWith Attr
    attr (Text
    src Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text -> Text
    escapeURI Text
    extra) ""
                         (Text -> Inlines
    B.str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Text
    orig Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    extra)

    image :: PandocMonad m => MarkdownParser m (F Inlines)
    image :: MarkdownParser m (F Inlines)
    image = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '!'
      (lab :: F Inlines
    lab,raw :: Text
    raw) <- MarkdownParser m (F Inlines, Text)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F Inlines, Text)
    reference
      Text
    defaultExt <- (ReaderOptions -> Text) -> ParserT Text ParserState m Text
    forall st s (m :: * -> *) t b.
    (HasReaderOptions st, Stream s m t) =>
    (ReaderOptions -> b) -> ParserT s st m b
    getOption ReaderOptions -> Text
    readerDefaultImageExtension
      let constructor :: Attr -> Text -> Text -> Inlines -> Inlines
    constructor attr' :: Attr
    attr' src :: Text
    src = case [Char] -> [Char]
    takeExtension (Text -> [Char]
    T.unpack Text
    src) of
                              "" -> Attr -> Text -> Text -> Inlines -> Inlines
    B.imageWith Attr
    attr' ([Char] -> Text
    T.pack ([Char] -> Text) -> [Char] -> Text
    forall a b. (a -> b) -> a -> b
    $ [Char] -> [Char] -> [Char]
    addExtension (Text -> [Char]
    T.unpack Text
    src)
                                                              ([Char] -> [Char]) -> [Char] -> [Char]
    forall a b. (a -> b) -> a -> b
    $ Text -> [Char]
    T.unpack Text
    defaultExt)
                              _  -> Attr -> Text -> Text -> Inlines -> Inlines
    B.imageWith Attr
    attr' Text
    src
      (Attr -> Text -> Text -> Inlines -> Inlines)
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    (Attr -> Text -> Text -> Inlines -> Inlines)
    -> F Inlines -> MarkdownParser m (F Inlines)
    regLink Attr -> Text -> Text -> Inlines -> Inlines
    constructor F Inlines
    lab MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> (Attr -> Text -> Text -> Inlines -> Inlines)
    -> (F Inlines, Text) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    (Attr -> Text -> Text -> Inlines -> Inlines)
    -> (F Inlines, Text) -> MarkdownParser m (F Inlines)
    referenceLink Attr -> Text -> Text -> Inlines -> Inlines
    constructor (F Inlines
    lab,Text
    raw)

    note :: PandocMonad m => MarkdownParser m (F Inlines)
    note :: MarkdownParser m (F Inlines)
    note = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_footnotes
      Text
    ref <- MarkdownParser m Text
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
    noteMarker
      (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParserT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateNoteRefs :: Set Text
    stateNoteRefs = Text -> Set Text -> Set Text
    forall a. Ord a => a -> Set a -> Set a
    Set.insert Text
    ref (ParserState -> Set Text
    stateNoteRefs ParserState
    st) }
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
        Map Text (SourcePos, F Blocks)
    notes <- (ParserState -> Map Text (SourcePos, F Blocks))
    -> Future ParserState (Map Text (SourcePos, F Blocks))
    forall s a. (s -> a) -> Future s a
    asksF ParserState -> Map Text (SourcePos, F Blocks)
    stateNotes'
        case Text
    -> Map Text (SourcePos, F Blocks) -> Maybe (SourcePos, F Blocks)
    forall k a. Ord k => k -> Map k a -> Maybe a
    M.lookup Text
    ref Map Text (SourcePos, F Blocks)
    notes of
            Nothing       -> 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 -> Inlines
    B.str (Text -> Inlines) -> Text -> 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 (_pos :: SourcePos
    _pos, contents :: F Blocks
    contents) -> do
              ParserState
    st <- Future ParserState ParserState
    forall s. Future s s
    askF
              -- process the note in a context that doesn't resolve
              -- notes, to avoid infinite looping with notes inside
              -- notes:
              let contents' :: Blocks
    contents' = F Blocks -> ParserState -> Blocks
    forall s a. Future s a -> s -> a
    runF F Blocks
    contents ParserState
    st{ stateNotes' :: Map Text (SourcePos, F Blocks)
    stateNotes' = Map Text (SourcePos, F Blocks)
    forall k a. Map k a
    M.empty }
              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'

    inlineNote :: PandocMonad m => MarkdownParser m (F Inlines)
    inlineNote :: MarkdownParser m (F Inlines)
    inlineNote = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_inline_notes
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '^'
      F Inlines
    contents <- MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlinesInBalancedBrackets
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Blocks -> Inlines
    B.note (Blocks -> Inlines) -> (Inlines -> Blocks) -> Inlines -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inlines -> Blocks
    B.para (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    contents

    rawLaTeXInline' :: PandocMonad m => MarkdownParser m (F Inlines)
    rawLaTeXInline' :: MarkdownParser m (F Inlines)
    rawLaTeXInline' = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_raw_tex
      ParserT Text ParserState m Text -> ParserT Text ParserState 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 ParserState m Text
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Text
    rawConTeXtEnvironment
      Text
    s <- ParserT Text ParserState m Text
    forall (m :: * -> *) s.
    (PandocMonad m, HasMacros s, HasReaderOptions s) =>
    ParserT Text s m Text
    rawLaTeXInline
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ 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
    B.rawInline "tex" Text
    s -- "tex" because it might be context

    rawConTeXtEnvironment :: PandocMonad m => ParserT Text st m Text
    rawConTeXtEnvironment :: ParserT Text st m Text
    rawConTeXtEnvironment = ParserT Text st m Text -> ParserT Text st m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParserT Text st m Text -> ParserT Text st m Text)
    -> ParserT Text st m Text -> ParserT Text st m Text
    forall a b. (a -> b) -> a -> b
    $ do
      [Char] -> ParsecT Text st m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "\\start"
      Text
    completion <- ParserT Text st m Char -> ParserT Text st m Text
    forall (m :: * -> *) st.
    PandocMonad m =>
    ParserT Text st m Char -> ParserT Text st m Text
    inBrackets (ParserT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    letter ParserT Text st m Char
    -> ParserT Text st m Char -> ParserT Text st m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParserT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    digit ParserT Text st m Char
    -> ParserT Text st m Char -> ParserT Text st m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParserT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar)
                   ParserT Text st m Text
    -> ParserT Text st m Text -> ParserT Text st m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParserT Text st m Char -> ParserT Text st m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char ParserT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    letter
      [Text]
    contents <- ParserT Text st m Text
    -> ParserT Text st m Text -> ParsecT Text st m [Text]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    manyTill (ParserT Text st m Text
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Text
    rawConTeXtEnvironment ParserT Text st m Text
    -> ParserT Text st m Text -> ParserT Text st m Text
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Int -> ParserT Text st m Char -> ParserT Text st m Text
    forall s (m :: * -> *) st.
    (Stream s m Char, Monad m) =>
    Int -> ParsecT s st m Char -> ParsecT s st m Text
    countChar 1 ParserT Text st m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    anyChar)
                           (ParserT Text st m Text -> ParserT Text st m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParserT Text st m Text -> ParserT Text st m Text)
    -> ParserT Text st m Text -> ParserT Text st m Text
    forall a b. (a -> b) -> a -> b
    $ [Char] -> ParsecT Text st m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string "\\stop" ParsecT Text st m [Char]
    -> ParserT Text st m Text -> ParserT Text st m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Text -> ParserT Text st m Text
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Text -> ParsecT s u m Text
    textStr Text
    completion)
      Text -> ParserT Text st m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> ParserT Text st m Text) -> Text -> ParserT Text st m Text
    forall a b. (a -> b) -> a -> b
    $ "\\start" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    completion Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> [Text] -> Text
    T.concat [Text]
    contents Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> "\\stop" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    completion

    inBrackets :: PandocMonad m => ParserT Text st m Char -> ParserT Text st m Text
    inBrackets :: ParserT Text st m Char -> ParserT Text st m Text
    inBrackets parser :: ParserT Text st m Char
    parser = do
      Char -> ParserT Text st m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '['
      Text
    contents <- ParserT Text st m Char -> ParserT Text st 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 m Char
    parser
      Char -> ParserT Text st m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ']'
      Text -> ParserT Text st m Text
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> ParserT Text st m Text) -> Text -> ParserT Text st m Text
    forall a b. (a -> b) -> a -> b
    $ "[" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    contents Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> "]"

    spanHtml :: PandocMonad m => MarkdownParser m (F Inlines)
    spanHtml :: MarkdownParser m (F Inlines)
    spanHtml = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_native_spans
      (TagOpen _ attrs :: [(Text, Text)]
    attrs, _) <- (Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag (Tag Text -> Tag Text -> Bool
    forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
    ~== Text -> [(Text, Text)] -> Tag Text
    forall str. str -> [Attribute str] -> Tag str
    TagOpen ("span" :: Text) [])
      F Inlines
    contents <- [F Inlines] -> F Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([F Inlines] -> F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Inlines)
    -> ParserT Text ParserState m (Tag Text, Text)
    -> ParsecT Text ParserState m [F Inlines]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    manyTill MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline ((Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag (Tag Text -> Tag Text -> Bool
    forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
    ~== Text -> Tag Text
    forall str. str -> Tag str
    TagClose ("span" :: Text)))
      let ident :: Text
    ident = Text -> Maybe Text -> Text
    forall a. a -> Maybe a -> a
    fromMaybe "" (Maybe Text -> Text) -> Maybe Text -> Text
    forall a b. (a -> b) -> a -> b
    $ Text -> [(Text, Text)] -> Maybe Text
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup "id" [(Text, Text)]
    attrs
      let classes :: [Text]
    classes = [Text] -> (Text -> [Text]) -> Maybe Text -> [Text]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe [] Text -> [Text]
    T.words (Maybe Text -> [Text]) -> Maybe Text -> [Text]
    forall a b. (a -> b) -> a -> b
    $ Text -> [(Text, Text)] -> Maybe Text
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup "class" [(Text, Text)]
    attrs
      let keyvals :: [(Text, Text)]
    keyvals = [(Text
    k,Text
    v) | (k :: Text
    k,v :: Text
    v) <- [(Text, Text)]
    attrs, Text
    k Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    /= "id" Bool -> Bool -> Bool
    && Text
    k Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    /= "class"]
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ if Attr -> Bool
    isSmallCaps (Text
    ident, [Text]
    classes, [(Text, Text)]
    keyvals)
                  then Inlines -> Inlines
    B.smallcaps (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    contents
                  else Attr -> Inlines -> Inlines
    B.spanWith (Text
    ident, [Text]
    classes, [(Text, Text)]
    keyvals) (Inlines -> Inlines) -> F Inlines -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Inlines
    contents

    divHtml :: PandocMonad m => MarkdownParser m (F Blocks)
    divHtml :: MarkdownParser m (F Blocks)
    divHtml = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_native_divs
      (TagOpen _ attrs :: [(Text, Text)]
    attrs, rawtag :: Text
    rawtag) <- (Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag (Tag Text -> Tag Text -> Bool
    forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
    ~== Text -> [(Text, Text)] -> Tag Text
    forall str. str -> [Attribute str] -> Tag str
    TagOpen ("div" :: Text) [])
      -- we set stateInHtmlBlock so that closing tags that can be either block or
      -- inline will not be parsed as inline tags
      Maybe Text
    oldInHtmlBlock <- ParserState -> Maybe Text
    stateInHtmlBlock (ParserState -> Maybe Text)
    -> ParsecT Text ParserState m ParserState
    -> ParsecT Text ParserState m (Maybe Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParserT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateInHtmlBlock :: Maybe Text
    stateInHtmlBlock = Text -> Maybe Text
    forall a. a -> Maybe a
    Just "div" }
      Text
    bls <- Text
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option "" (ParserT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline ParserT Text ParserState m Char
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m Text
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Text
    -> ParsecT Text ParserState m Text
    -> ParsecT Text ParserState m 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 ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines)
      F Blocks
    contents <- [F Blocks] -> F Blocks
    forall a. Monoid a => [a] -> a
    mconcat ([F Blocks] -> F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    -> MarkdownParser m (F Blocks)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                  MarkdownParser m (F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParserT Text ParserState m (Tag Text, Text)
    -> ParserT Text ParserState m ()
    forall b s (m :: * -> *) a st.
    (Show b, Stream s m a) =>
    ParserT s st m b -> ParserT s st m ()
    notFollowedBy' ((Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag (Tag Text -> Tag Text -> Bool
    forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
    ~== Text -> Tag Text
    forall str. str -> Tag str
    TagClose ("div" :: Text))) ParserT Text ParserState m ()
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    block)
      Bool
    closed <- Bool
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState 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
    -> ParserT Text ParserState m (Tag Text, Text)
    -> ParsecT Text ParserState m Bool
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ (Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag (Tag Text -> Tag Text -> Bool
    forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
    ~== Text -> Tag Text
    forall str. str -> Tag str
    TagClose ("div" :: Text)))
      if Bool
    closed
         then do
           (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParserT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateInHtmlBlock :: Maybe Text
    stateInHtmlBlock = Maybe Text
    oldInHtmlBlock }
           let ident :: Text
    ident = Text -> Maybe Text -> Text
    forall a. a -> Maybe a -> a
    fromMaybe "" (Maybe Text -> Text) -> Maybe Text -> Text
    forall a b. (a -> b) -> a -> b
    $ Text -> [(Text, Text)] -> Maybe Text
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup "id" [(Text, Text)]
    attrs
           let classes :: [Text]
    classes = [Text] -> (Text -> [Text]) -> Maybe Text -> [Text]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe [] Text -> [Text]
    T.words (Maybe Text -> [Text]) -> Maybe Text -> [Text]
    forall a b. (a -> b) -> a -> b
    $ Text -> [(Text, Text)] -> Maybe Text
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup "class" [(Text, Text)]
    attrs
           let keyvals :: [(Text, Text)]
    keyvals = [(Text
    k,Text
    v) | (k :: Text
    k,v :: Text
    v) <- [(Text, Text)]
    attrs, Text
    k Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    /= "id" Bool -> Bool -> Bool
    && Text
    k Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    /= "class"]
           F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Attr -> Blocks -> Blocks
    B.divWith (Text
    ident, [Text]
    classes, [(Text, Text)]
    keyvals) (Blocks -> Blocks) -> F Blocks -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Blocks
    contents
         else -- avoid backtracing
           F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Blocks -> F Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Text -> Blocks
    B.rawBlock "html" (Text
    rawtag Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    bls)) F Blocks -> F Blocks -> F Blocks
    forall a. Semigroup a => a -> a -> a
    <> F Blocks
    contents

    divFenced :: PandocMonad m => MarkdownParser m (F Blocks)
    divFenced :: MarkdownParser m (F Blocks)
    divFenced = MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks))
    -> MarkdownParser m (F Blocks) -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_fenced_divs
      [Char] -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string ":::"
      ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':')
      ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
      Attr
    attribs <- MarkdownParser m Attr
    forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
    attributes MarkdownParser m Attr
    -> MarkdownParser m Attr -> MarkdownParser m Attr
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ((\x :: Text
    x -> ("",[Text
    x],[])) (Text -> Attr)
    -> ParsecT Text ParserState m Text -> MarkdownParser m Attr
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m Char -> ParsecT Text ParserState m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    nonspaceChar)
      ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    spaceChar
      ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':')
      ParsecT Text ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    blankline
      (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParserT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateFencedDivLevel :: Int
    stateFencedDivLevel = ParserState -> Int
    stateFencedDivLevel ParserState
    st Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + 1 }
      F Blocks
    bs <- [F Blocks] -> F Blocks
    forall a. Monoid a => [a] -> a
    mconcat ([F Blocks] -> F Blocks)
    -> ParsecT Text ParserState m [F Blocks]
    -> MarkdownParser m (F Blocks)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Blocks)
    -> ParserT Text ParserState m ()
    -> ParsecT Text ParserState m [F Blocks]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    manyTill MarkdownParser m (F Blocks)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
    block ParserT Text ParserState m ()
    forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
    divFenceEnd
      (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
    updateState ((ParserState -> ParserState) -> ParserT Text ParserState m ())
    -> (ParserState -> ParserState) -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: ParserState
    st -> ParserState
    st{ stateFencedDivLevel :: Int
    stateFencedDivLevel = ParserState -> Int
    stateFencedDivLevel ParserState
    st Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - 1 }
      F Blocks -> MarkdownParser m (F Blocks)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Blocks -> MarkdownParser m (F Blocks))
    -> F Blocks -> MarkdownParser m (F Blocks)
    forall a b. (a -> b) -> a -> b
    $ Attr -> Blocks -> Blocks
    B.divWith Attr
    attribs (Blocks -> Blocks) -> F Blocks -> F Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F Blocks
    bs

    divFenceEnd :: PandocMonad m => MarkdownParser m ()
    divFenceEnd :: MarkdownParser m ()
    divFenceEnd = MarkdownParser m () -> MarkdownParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m () -> MarkdownParser m ())
    -> MarkdownParser m () -> MarkdownParser m ()
    forall a b. (a -> b) -> a -> b
    $ do
      [Char] -> ParsecT Text ParserState m [Char]
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m [Char]
    string ":::"
      ParsecT Text ParserState m Char -> MarkdownParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
    skipMany (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':')
      ParserT Text ParserState m Text
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
    blanklines
      () -> MarkdownParser m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    rawHtmlInline :: PandocMonad m => MarkdownParser m (F Inlines)
    rawHtmlInline :: MarkdownParser m (F Inlines)
    rawHtmlInline = do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_raw_html
      Maybe Text
    inHtmlBlock <- ParserState -> Maybe Text
    stateInHtmlBlock (ParserState -> Maybe Text)
    -> ParsecT Text ParserState m ParserState
    -> ParsecT Text ParserState m (Maybe Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m ParserState
    forall (m :: * -> *) s u. Monad m => ParsecT s u m u
    getState
      let isCloseBlockTag :: Tag str -> Bool
    isCloseBlockTag t :: Tag str
    t = case Maybe Text
    inHtmlBlock of
                                   Just t' :: Text
    t' -> Tag str
    t Tag str -> Tag Text -> Bool
    forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
    ~== Text -> Tag Text
    forall str. str -> Tag str
    TagClose Text
    t'
                                   Nothing -> Bool
    False
      Bool
    mdInHtml <- Bool
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState 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 ParserState m Bool
     -> ParsecT Text ParserState m Bool)
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    forall a b. (a -> b) -> a -> b
    $
                    (    Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_markdown_in_html_blocks
                     ParserT Text ParserState m ()
    -> ParserT Text ParserState m () -> ParserT Text ParserState m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_markdown_attribute
                    ) ParserT Text ParserState m ()
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Bool -> ParsecT Text ParserState m Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    True
      (_,result :: Text
    result) <- (Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
    forall st (m :: * -> *).
    (HasReaderOptions st, Monad m) =>
    (Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
    htmlTag ((Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text))
    -> (Tag Text -> Bool)
    -> ParserT Text ParserState m (Tag Text, Text)
    forall a b. (a -> b) -> a -> b
    $ if Bool
    mdInHtml
                                 then (\x :: Tag Text
    x -> Tag Text -> Bool
    forall a. NamedTag (Tag a) => Tag a -> Bool
    isInlineTag Tag Text
    x Bool -> Bool -> Bool
    &&
                                             Bool -> Bool
    not (Tag Text -> Bool
    forall str. StringLike str => Tag str -> Bool
    isCloseBlockTag Tag Text
    x))
                                 else Bool -> Bool
    not (Bool -> Bool) -> (Tag Text -> Bool) -> Tag Text -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Tag Text -> Bool
    forall a. Tag a -> Bool
    isTextTag
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ 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
    B.rawInline "html" Text
    result

    -- Emoji

    emojiChars :: [Char]
    emojiChars :: [Char]
    emojiChars = ['a'..'z'] [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ ['0'..'9'] [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ ['_','+','-']

    emoji :: PandocMonad m => MarkdownParser m (F Inlines)
    emoji :: MarkdownParser m (F Inlines)
    emoji = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_emoji
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':'
      Text
    emojikey <- ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf [Char]
    emojiChars)
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':'
      case Text -> Maybe Inline
    emojiToInline Text
    emojikey of
        Just i :: Inline
    i -> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (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
    $ Inline -> Inlines
    forall a. a -> Many a
    B.singleton Inline
    i)
        Nothing -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. MonadPlus m => m a
    mzero

    -- Citations

    cite :: PandocMonad m => MarkdownParser m (F Inlines)
    cite :: MarkdownParser m (F Inlines)
    cite = do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_citations
      MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    textualCite
                MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> do (cs :: F [Citation]
    cs, raw :: Text
    raw) <- ParsecT Text ParserState m (F [Citation])
    -> ParsecT Text ParserState m (F [Citation], Text)
    forall (m :: * -> *) st a.
    Monad m =>
    ParsecT Text st m a -> ParsecT Text st m (a, Text)
    withRaw ParsecT Text ParserState m (F [Citation])
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F [Citation])
    normalCite
                       F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser 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

    textualCite :: PandocMonad m => MarkdownParser m (F Inlines)
    textualCite :: MarkdownParser m (F Inlines)
    textualCite = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      (suppressAuthor :: Bool
    suppressAuthor, key :: Text
    key) <- ParserT Text ParserState m (Bool, Text)
    forall s (m :: * -> *) st.
    (Stream s m Char, HasLastStrPosition st) =>
    ParserT s st m (Bool, Text)
    citeKey
      let first :: Citation
    first = Citation :: Text
    -> [Inline] -> [Inline] -> CitationMode -> Int -> Int -> Citation
    Citation{ citationId :: Text
    citationId      = Text
    key
                          , citationPrefix :: [Inline]
    citationPrefix  = []
                          , citationSuffix :: [Inline]
    citationSuffix  = []
                          , citationMode :: CitationMode
    citationMode    = if Bool
    suppressAuthor
                                                 then CitationMode
    SuppressAuthor
                                                 else CitationMode
    AuthorInText
                          , citationNoteNum :: Int
    citationNoteNum = 0
                          , citationHash :: Int
    citationHash    = 0
                          }
      Maybe (F [Citation], Text)
    mbrest <- Maybe (F [Citation], Text)
    -> ParsecT Text ParserState m (Maybe (F [Citation], Text))
    -> ParsecT Text ParserState m (Maybe (F [Citation], Text))
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option Maybe (F [Citation], Text)
    forall a. Maybe a
    Nothing (ParsecT Text ParserState m (Maybe (F [Citation], Text))
     -> ParsecT Text ParserState m (Maybe (F [Citation], Text)))
    -> ParsecT Text ParserState m (Maybe (F [Citation], Text))
    -> ParsecT Text ParserState m (Maybe (F [Citation], Text))
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m (Maybe (F [Citation], Text))
    -> ParsecT Text ParserState m (Maybe (F [Citation], Text))
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text ParserState m (Maybe (F [Citation], Text))
     -> ParsecT Text ParserState m (Maybe (F [Citation], Text)))
    -> ParsecT Text ParserState m (Maybe (F [Citation], Text))
    -> ParsecT Text ParserState m (Maybe (F [Citation], Text))
    forall a b. (a -> b) -> a -> b
    $ ParserT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    spnl ParserT Text ParserState m ()
    -> ParsecT Text ParserState m (Maybe (F [Citation], Text))
    -> ParsecT Text ParserState m (Maybe (F [Citation], Text))
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> (F [Citation], Text) -> Maybe (F [Citation], Text)
    forall a. a -> Maybe a
    Just ((F [Citation], Text) -> Maybe (F [Citation], Text))
    -> ParsecT Text ParserState m (F [Citation], Text)
    -> ParsecT Text ParserState m (Maybe (F [Citation], Text))
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text ParserState m (F [Citation])
    -> ParsecT Text ParserState m (F [Citation], Text)
    forall (m :: * -> *) st a.
    Monad m =>
    ParsecT Text st m a -> ParsecT Text st m (a, Text)
    withRaw ParsecT Text ParserState m (F [Citation])
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F [Citation])
    normalCite
      case Maybe (F [Citation], Text)
    mbrest of
           Just (rest :: F [Citation]
    rest, raw :: Text
    raw) ->
             F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser 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 -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ "@" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    key Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> " " Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    raw) ([Citation] -> Inlines)
    -> ([Citation] -> [Citation]) -> [Citation] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Citation
    firstCitation -> [Citation] -> [Citation]
    forall a. a -> [a] -> [a]
    :))
                   ([Citation] -> Inlines) -> F [Citation] -> F Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> F [Citation]
    rest
           Nothing   ->
             (do
              (cs :: F [Citation]
    cs, raw :: Text
    raw) <- ParsecT Text ParserState m (F [Citation])
    -> ParsecT Text ParserState m (F [Citation], Text)
    forall (m :: * -> *) st a.
    Monad m =>
    ParsecT Text st m a -> ParsecT Text st m (a, Text)
    withRaw (ParsecT Text ParserState m (F [Citation])
     -> ParsecT Text ParserState m (F [Citation], Text))
    -> ParsecT Text ParserState m (F [Citation])
    -> ParsecT Text ParserState m (F [Citation], Text)
    forall a b. (a -> b) -> a -> b
    $ Citation -> ParsecT Text ParserState m (F [Citation])
    forall (m :: * -> *).
    PandocMonad m =>
    Citation -> MarkdownParser m (F [Citation])
    bareloc Citation
    first
              let (spaces' :: Text
    spaces',raw' :: Text
    raw') = (Char -> Bool) -> Text -> (Text, Text)
    T.span Char -> Bool
    isSpace Text
    raw
                  spc :: Inlines
    spc | Text -> Bool
    T.null Text
    spaces' = Inlines
    forall a. Monoid a => a
    mempty
                      | Bool
    otherwise      = Inlines
    B.space
              F Inlines
    lab <- MarkdownParser m (F Inlines)
    -> Text -> MarkdownParser m (F Inlines)
    forall s (m :: * -> *) u a.
    (Stream s m Char, IsString s, HasLastStrPosition u) =>
    ParserT s u m a -> Text -> ParserT s u m a
    parseFromString' MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inlines (Text -> MarkdownParser m (F Inlines))
    -> Text -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    dropBrackets Text
    raw'
              F Inlines
    fallback <- (Attr -> Text -> Text -> Inlines -> Inlines)
    -> (F Inlines, Text) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *).
    PandocMonad m =>
    (Attr -> Text -> Text -> Inlines -> Inlines)
    -> (F Inlines, Text) -> MarkdownParser m (F Inlines)
    referenceLink Attr -> Text -> Text -> Inlines -> Inlines
    B.linkWith (F Inlines
    lab,Text
    raw')
              F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
                Inlines
    fallback' <- F Inlines
    fallback
                [Citation]
    cs' <- F [Citation]
    cs
                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
    $
                  case Inlines -> [Inline]
    forall a. Many a -> [a]
    B.toList Inlines
    fallback' of
                    Link{}:_ -> [Citation] -> Inlines -> Inlines
    B.cite [Citation
    first] (Text -> Inlines
    B.str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ "@" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    key) Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    spc Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    fallback'
                    _        -> [Citation] -> Inlines -> Inlines
    B.cite [Citation]
    cs' (Text -> Inlines
    B.text (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ "@" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    key Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> " " Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    raw))
             MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (do ParserState
    st <- Future ParserState ParserState
    forall s. Future s s
    askF
                            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
    $ case Text -> Map Text Int -> Maybe Int
    forall k a. Ord k => k -> Map k a -> Maybe a
    M.lookup Text
    key (ParserState -> Map Text Int
    stateExamples ParserState
    st) of
                                     Just n :: Int
    n -> Text -> Inlines
    B.str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Int -> Text
    forall a. Show a => a -> Text
    tshow Int
    n
                                     _      -> [Citation] -> Inlines -> Inlines
    B.cite [Citation
    first] (Inlines -> Inlines) -> Inlines -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Inlines
    B.str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ "@" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    key)

    bareloc :: PandocMonad m => Citation -> MarkdownParser m (F [Citation])
    bareloc :: Citation -> MarkdownParser m (F [Citation])
    bareloc c :: Citation
    c = MarkdownParser m (F [Citation]) -> MarkdownParser m (F [Citation])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F [Citation])
     -> MarkdownParser m (F [Citation]))
    -> MarkdownParser m (F [Citation])
    -> MarkdownParser m (F [Citation])
    forall a b. (a -> b) -> a -> b
    $ do
      ParserT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    spnl
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '['
      ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char -> ParserT Text ParserState m ())
    -> ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '^'
      F Inlines
    suff <- MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    suffix
      F [Citation]
    rest <- F [Citation]
    -> MarkdownParser m (F [Citation])
    -> MarkdownParser m (F [Citation])
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option ([Citation] -> F [Citation]
    forall (m :: * -> *) a. Monad m => a -> m a
    return []) (MarkdownParser m (F [Citation])
     -> MarkdownParser m (F [Citation]))
    -> MarkdownParser m (F [Citation])
    -> MarkdownParser m (F [Citation])
    forall a b. (a -> b) -> a -> b
    $ MarkdownParser m (F [Citation]) -> MarkdownParser m (F [Citation])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F [Citation])
     -> MarkdownParser m (F [Citation]))
    -> MarkdownParser m (F [Citation])
    -> MarkdownParser m (F [Citation])
    forall a b. (a -> b) -> a -> b
    $ Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ';' ParsecT Text ParserState m Char
    -> MarkdownParser m (F [Citation])
    -> MarkdownParser m (F [Citation])
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m (F [Citation])
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F [Citation])
    citeList
      ParserT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    spnl
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ']'
      ParsecT Text ParserState m Char -> ParserT Text ParserState 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 ParserState m Char -> ParserT Text ParserState m ())
    -> ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ [Char] -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf "[("
      F [Citation] -> MarkdownParser m (F [Citation])
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F [Citation] -> MarkdownParser m (F [Citation]))
    -> F [Citation] -> MarkdownParser m (F [Citation])
    forall a b. (a -> b) -> a -> b
    $ do
        Inlines
    suff' <- F Inlines
    suff
        [Citation]
    rest' <- F [Citation]
    rest
        [Citation] -> F [Citation]
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Citation] -> F [Citation]) -> [Citation] -> F [Citation]
    forall a b. (a -> b) -> a -> b
    $ Citation
    c{ citationSuffix :: [Inline]
    citationSuffix = Inlines -> [Inline]
    forall a. Many a -> [a]
    B.toList Inlines
    suff' } Citation -> [Citation] -> [Citation]
    forall a. a -> [a] -> [a]
    : [Citation]
    rest'

    normalCite :: PandocMonad m => MarkdownParser m (F [Citation])
    normalCite :: MarkdownParser m (F [Citation])
    normalCite = MarkdownParser m (F [Citation]) -> MarkdownParser m (F [Citation])
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F [Citation])
     -> MarkdownParser m (F [Citation]))
    -> MarkdownParser m (F [Citation])
    -> MarkdownParser m (F [Citation])
    forall a b. (a -> b) -> a -> b
    $ do
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '['
      ParserT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    spnl
      F [Citation]
    citations <- MarkdownParser m (F [Citation])
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (F [Citation])
    citeList
      ParserT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    spnl
      Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ']'
      F [Citation] -> MarkdownParser m (F [Citation])
    forall (m :: * -> *) a. Monad m => a -> m a
    return F [Citation]
    citations

    suffix :: PandocMonad m => MarkdownParser m (F Inlines)
    suffix :: MarkdownParser m (F Inlines)
    suffix = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      Bool
    hasSpace <- Bool
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState 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 ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
    nonspaceChar ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m Bool
    -> ParsecT Text ParserState m Bool
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Bool -> ParsecT Text ParserState m Bool
    forall (m :: * -> *) a. Monad m => a -> m a
    return Bool
    True)
      ParsecT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    spnl
      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 ParserState m [F Inlines]
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MarkdownParser m (F Inlines)
    -> ParsecT Text ParserState m [F Inlines]
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (ParsecT Text ParserState m Char -> ParsecT Text ParserState 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 ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    [Char] -> ParsecT s u m Char
    oneOf ";]") ParsecT Text ParserState m ()
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline)
      F Inlines -> MarkdownParser m (F Inlines)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (F Inlines -> MarkdownParser m (F Inlines))
    -> F Inlines -> MarkdownParser 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

    prefix :: PandocMonad m => MarkdownParser m (F Inlines)
    prefix :: MarkdownParser 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 ParserState m [F Inlines]
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
      MarkdownParser m (F Inlines)
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m [F Inlines]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    manyTill MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline (Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ']' ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m Char
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ((Bool, Text) -> Char)
    -> ParsecT Text ParserState m (Bool, Text)
    -> ParsecT Text ParserState m Char
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (Char -> (Bool, Text) -> Char
    forall a b. a -> b -> a
    const ']') (ParsecT Text ParserState m (Bool, Text)
    -> ParsecT Text ParserState m (Bool, Text)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead ParsecT Text ParserState m (Bool, Text)
    forall s (m :: * -> *) st.
    (Stream s m Char, HasLastStrPosition st) =>
    ParserT s st m (Bool, Text)
    citeKey))

    citeList :: PandocMonad m => MarkdownParser m (F [Citation])
    citeList :: MarkdownParser m (F [Citation])
    citeList = ([Future ParserState Citation] -> F [Citation])
    -> ParsecT Text ParserState m [Future ParserState Citation]
    -> MarkdownParser m (F [Citation])
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap [Future ParserState Citation] -> F [Citation]
    forall (t :: * -> *) (m :: * -> *) a.
    (Traversable t, Monad m) =>
    t (m a) -> m (t a)
    sequence (ParsecT Text ParserState m [Future ParserState Citation]
     -> MarkdownParser m (F [Citation]))
    -> ParsecT Text ParserState m [Future ParserState Citation]
    -> MarkdownParser m (F [Citation])
    forall a b. (a -> b) -> a -> b
    $ ParsecT Text ParserState m (Future ParserState Citation)
    -> ParsecT Text ParserState m ()
    -> ParsecT Text ParserState m [Future ParserState Citation]
    forall s (m :: * -> *) t u a sep.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
    sepBy1 ParsecT Text ParserState m (Future ParserState Citation)
    forall (m :: * -> *).
    PandocMonad m =>
    MarkdownParser m (Future ParserState Citation)
    citation (ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (ParsecT Text ParserState m () -> ParsecT Text ParserState m ())
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall a b. (a -> b) -> a -> b
    $ Char -> ParsecT Text ParserState m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ';' ParsecT Text ParserState m Char
    -> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> ParsecT Text ParserState m ()
    forall (m :: * -> *) st. PandocMonad m => ParserT Text st m ()
    spnl)

    citation :: PandocMonad m => MarkdownParser m (F Citation)
    citation :: MarkdownParser m (Future ParserState Citation)
    citation = MarkdownParser m (Future ParserState Citation)
    -> MarkdownParser m (Future ParserState Citation)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (Future ParserState Citation)
     -> MarkdownParser m (Future ParserState Citation))
    -> MarkdownParser m (Future ParserState Citation)
    -> MarkdownParser m (Future ParserState Citation)
    forall a b. (a -> b) -> a -> b
    $ do
      F Inlines
    pref <- MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    prefix
      (suppress_author :: Bool
    suppress_author, key :: Text
    key) <- ParserT Text ParserState m (Bool, Text)
    forall s (m :: * -> *) st.
    (Stream s m Char, HasLastStrPosition st) =>
    ParserT s st m (Bool, Text)
    citeKey
      F Inlines
    suff <- MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    suffix
      Future ParserState Citation
    -> MarkdownParser m (Future ParserState Citation)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Future ParserState Citation
     -> MarkdownParser m (Future ParserState Citation))
    -> Future ParserState Citation
    -> MarkdownParser m (Future ParserState Citation)
    forall a b. (a -> b) -> a -> b
    $ do
        Inlines
    x <- F Inlines
    pref
        Inlines
    y <- F Inlines
    suff
        Citation -> Future ParserState 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
                       }

    smart :: PandocMonad m => MarkdownParser m (F Inlines)
    smart :: MarkdownParser m (F Inlines)
    smart = do
      Extension -> ParserT Text ParserState m ()
    forall s (m :: * -> *) a st.
    (Stream s m a, HasReaderOptions st) =>
    Extension -> ParserT s st m ()
    guardEnabled Extension
    Ext_smart
      MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    doubleQuoted MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    singleQuoted MarkdownParser m (F Inlines)
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|>
        [MarkdownParser m (F Inlines)] -> MarkdownParser m (F Inlines)
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice ((ParsecT Text ParserState m Inlines
     -> MarkdownParser m (F Inlines))
    -> [ParsecT Text ParserState m Inlines]
    -> [MarkdownParser m (F Inlines)]
    forall a b. (a -> b) -> [a] -> [b]
    map (Inlines -> F Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> F Inlines)
    -> ParsecT Text ParserState m Inlines
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>) [ParsecT Text ParserState m Inlines
    forall s (m :: * -> *) st.
    Stream s m Char =>
    ParserT s st m Inlines
    apostrophe, ParsecT Text ParserState m Inlines
    forall st s (m :: * -> *).
    (HasReaderOptions st, Stream s m Char) =>
    ParserT s st m Inlines
    dash, ParsecT Text ParserState m Inlines
    forall s (m :: * -> *) st.
    Stream s m Char =>
    ParserT s st m Inlines
    ellipses])

    singleQuoted :: PandocMonad m => MarkdownParser m (F Inlines)
    singleQuoted :: MarkdownParser m (F Inlines)
    singleQuoted = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      ParserT Text ParserState m ()
    forall st (m :: * -> *) s.
    (HasLastStrPosition st, HasQuoteContext st m, Stream s m Char) =>
    ParserT s st m ()
    singleQuoteStart
      QuoteContext
    -> MarkdownParser m (F Inlines) -> MarkdownParser 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 (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser 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 ParserState m [F Inlines]
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
          MarkdownParser m (F Inlines)
    -> ParserT Text ParserState m ()
    -> ParsecT Text ParserState 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 MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    singleQuoteEnd

    -- 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 => MarkdownParser m (F Inlines)
    doubleQuoted :: MarkdownParser m (F Inlines)
    doubleQuoted = MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines)
    forall a b. (a -> b) -> a -> b
    $ do
      ParserT Text ParserState m ()
    forall st (m :: * -> *) s.
    (HasQuoteContext st m, Stream s m Char) =>
    ParserT s st m ()
    doubleQuoteStart
      QuoteContext
    -> MarkdownParser m (F Inlines) -> MarkdownParser 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 (MarkdownParser m (F Inlines) -> MarkdownParser m (F Inlines))
    -> MarkdownParser m (F Inlines) -> MarkdownParser 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.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 -> 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 ParserState m [F Inlines]
    -> MarkdownParser m (F Inlines)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
          MarkdownParser m (F Inlines)
    -> ParserT Text ParserState m ()
    -> ParsecT Text ParserState 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 MarkdownParser m (F Inlines)
    forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
    inline ParserT Text ParserState m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    doubleQuoteEnd