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

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

    Parsers for Org-mode inline elements.
    -}
    module Text.Pandoc.Readers.Org.BlockStarts
      ( exampleLineStart
      , hline
      , noteMarker
      , tableStart
      , drawerStart
      , headerStart
      , metaLineStart
      , latexEnvStart
      , commentLineStart
      , bulletListStart
      , orderedListStart
      , endOfBlock
      ) where

    import Control.Monad (void)
    import Data.Text (Text)
    import qualified Data.Text as T
    import Text.Pandoc.Readers.Org.Parsing

    -- | Horizontal Line (five -- dashes or more)
    hline :: Monad m => OrgParser m ()
    hline :: OrgParser m ()
    hline = OrgParser m () -> OrgParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m () -> OrgParser m ())
    -> OrgParser m () -> OrgParser m ()
    forall a b. (a -> b) -> a -> b
    $ do
      OrgParser m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string "-----"
      ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many (Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '-')
      OrgParser m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces
      ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall (m :: * -> *). Monad m => OrgParser m Char
    newline
      () -> OrgParser m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()

    -- | Read the start of a header line, return the header level
    headerStart :: Monad m => OrgParser m Int
    headerStart :: OrgParser m Int
    headerStart = OrgParser m Int -> OrgParser m Int
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Int -> OrgParser m Int)
    -> OrgParser m Int -> OrgParser m Int
    forall a b. (a -> b) -> a -> b
    $
      (String -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length (String -> Int)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> OrgParser m Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '*')) OrgParser m Int
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> OrgParser m Int
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m [a]
    many1 (Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ' ') OrgParser m Int
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m Int
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    updateLastPreCharPos

    tableStart :: Monad m => OrgParser m Char
    tableStart :: OrgParser m Char
    tableStart = OrgParser m Char -> OrgParser m Char
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Char -> OrgParser m Char)
    -> OrgParser m Char -> OrgParser m Char
    forall a b. (a -> b) -> a -> b
    $ ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m Char -> OrgParser m Char
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> Char -> OrgParser m Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '|'

    gridTableStart :: Monad m => OrgParser m ()
    gridTableStart :: OrgParser m ()
    gridTableStart = OrgParser m () -> OrgParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m () -> OrgParser m ())
    -> OrgParser m () -> OrgParser m ()
    forall a b. (a -> b) -> a -> b
    $ OrgParser m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces OrgParser m ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m ()
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '+' OrgParser m ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m ()
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '-'

    latexEnvStart :: Monad m => OrgParser m Text
    latexEnvStart :: OrgParser m Text
    latexEnvStart = OrgParser m Text -> OrgParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Text -> OrgParser m Text)
    -> OrgParser m Text -> OrgParser m Text
    forall a b. (a -> b) -> a -> b
    $
      ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string "\\begin{"
                 ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> OrgParser m Text -> OrgParser m Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> OrgParser m Text
    forall (m :: * -> *). Monad m => OrgParser m Text
    latexEnvName
                 OrgParser m Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> OrgParser m Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string "}"
                 OrgParser m Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    blankline
     where
       latexEnvName :: Monad m => OrgParser m Text
       latexEnvName :: OrgParser m Text
    latexEnvName = OrgParser m Text -> OrgParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Text -> OrgParser m Text)
    -> OrgParser m Text -> OrgParser m Text
    forall a b. (a -> b) -> a -> b
    $ Text -> Text -> Text
    forall a. Monoid a => a -> a -> a
    mappend (Text -> Text -> Text)
    -> OrgParser m Text
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Text -> Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char ParserT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    alphaNum ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) (Text -> Text)
    -> OrgParser m Text -> OrgParser m Text
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Text -> OrgParser m Text -> OrgParser m Text
    forall s (m :: * -> *) t a u.
    Stream s m t =>
    a -> ParsecT s u m a -> ParsecT s u m a
    option "" (Text -> OrgParser m Text
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Text -> ParsecT s u m Text
    textStr "*")

    bulletListStart :: Monad m => OrgParser m Int
    bulletListStart :: OrgParser m Int
    bulletListStart = OrgParser m Int -> OrgParser m Int
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Int -> OrgParser m Int)
    -> OrgParser m Int -> OrgParser m Int
    forall a b. (a -> b) -> a -> b
    $ do
      Int
    ind <- String -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length (String -> Int)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> OrgParser m Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    spaceChar
       -- Unindented lists cannot use '*' bullets.
      String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m Char
    oneOf (if Int
    ind Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == 0 then "+-" else "*+-")
      OrgParser m ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    skipSpaces1 OrgParser m () -> OrgParser m () -> OrgParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> OrgParser m () -> OrgParser m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead OrgParser m ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    eol
      Int -> OrgParser m Int
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Int
    ind Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + 1)

    genericListStart :: Monad m
                     => OrgParser m Text
                     -> OrgParser m Int
    genericListStart :: OrgParser m Text -> OrgParser m Int
    genericListStart listMarker :: OrgParser m Text
    listMarker = OrgParser m Int -> OrgParser m Int
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Int -> OrgParser m Int)
    -> OrgParser m Int -> OrgParser m Int
    forall a b. (a -> b) -> a -> b
    $ do
      Int
    ind <- String -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length (String -> Int)
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> OrgParser m Int
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
    many ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    spaceChar
      OrgParser m Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void OrgParser m Text
    listMarker
      ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    skipSpaces1 ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead ParsecT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    eol
      Int -> OrgParser m Int
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Int
    ind Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + 1)

    eol :: Monad m => OrgParser m ()
    eol :: OrgParser m ()
    eol = ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void (Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '\n')

    orderedListStart :: Monad m => OrgParser m Int
    orderedListStart :: OrgParser m Int
    orderedListStart = OrgParser m Text -> OrgParser m Int
    forall (m :: * -> *).
    Monad m =>
    OrgParser m Text -> OrgParser m Int
    genericListStart OrgParser m Text
    forall st. ParsecT Text st (ReaderT OrgParserLocal m) Text
    orderedListMarker
      -- Ordered list markers allowed in org-mode
      where orderedListMarker :: ParsecT Text st (ReaderT OrgParserLocal m) Text
    orderedListMarker = Text -> Char -> Text
    T.snoc (Text -> Char -> Text)
    -> ParsecT Text st (ReaderT OrgParserLocal m) Text
    -> ParsecT Text st (ReaderT OrgParserLocal m) (Char -> Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> ParserT Text st (ReaderT OrgParserLocal m) Char
    -> ParsecT Text st (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) t st.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m Text
    many1Char ParserT Text st (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    digit ParsecT Text st (ReaderT OrgParserLocal m) (Char -> Text)
    -> ParserT Text st (ReaderT OrgParserLocal m) Char
    -> ParsecT Text st (ReaderT OrgParserLocal m) Text
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> String -> ParserT Text st (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m Char
    oneOf ".)"

    drawerStart :: Monad m => OrgParser m Text
    drawerStart :: OrgParser m Text
    drawerStart = OrgParser m Text -> OrgParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Text -> OrgParser m Text)
    -> OrgParser m Text -> OrgParser m Text
    forall a b. (a -> b) -> a -> b
    $ ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m Text -> OrgParser m Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> OrgParser m Text
    forall u. ParsecT Text u (ReaderT OrgParserLocal m) Text
    drawerName OrgParser m Text
    -> ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    -> OrgParser m Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParserT Text OrgParserState (ReaderT OrgParserLocal m) ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces OrgParser m Text
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall (m :: * -> *). Monad m => OrgParser m Char
    newline
     where drawerName :: ParsecT Text u (ReaderT OrgParserLocal m) Text
    drawerName = Char -> ParsecT Text u (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':' ParsecT Text u (ReaderT OrgParserLocal m) Char
    -> ParsecT Text u (ReaderT OrgParserLocal m) Text
    -> ParsecT Text u (ReaderT OrgParserLocal m) Text
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> ParsecT Text u (ReaderT OrgParserLocal m) Char
    -> ParsecT Text u (ReaderT OrgParserLocal m) Char
    -> ParsecT Text u (ReaderT OrgParserLocal m) Text
    forall s (m :: * -> *) t st a.
    Stream s m t =>
    ParserT s st m Char -> ParserT s st m a -> ParserT s st m Text
    manyTillChar ParsecT Text u (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    nonspaceChar (Char -> ParsecT Text u (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ':')

    metaLineStart :: Monad m => OrgParser m ()
    metaLineStart :: OrgParser m ()
    metaLineStart = OrgParser m () -> OrgParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m () -> OrgParser m ())
    -> OrgParser m () -> OrgParser m ()
    forall a b. (a -> b) -> a -> b
    $ OrgParser m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces OrgParser m ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> OrgParser m ()
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string "#+"

    commentLineStart :: Monad m => OrgParser m ()
    commentLineStart :: OrgParser m ()
    commentLineStart = OrgParser m () -> OrgParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m () -> OrgParser m ())
    -> OrgParser m () -> OrgParser m ()
    forall a b. (a -> b) -> a -> b
    $
      -- the first char after '#' must be a plain space character or a newline
      OrgParser m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces OrgParser m ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> OrgParser m ()
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string "#" OrgParser m ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m ()
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
    <* ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead (String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m Char
    oneOf " \n")

    exampleLineStart :: Monad m => OrgParser m ()
    exampleLineStart :: OrgParser m ()
    exampleLineStart = () ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> OrgParser m ()
    forall (f :: * -> *) a b. Functor f => a -> f b -> f a
    <$ ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m ()
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
    skipSpaces OrgParser m ()
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
    *> String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) String
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m String
    string ": ")

    noteMarker :: Monad m => OrgParser m Text
    noteMarker :: OrgParser m Text
    noteMarker = OrgParser m Text -> OrgParser m Text
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m Text -> OrgParser m Text)
    -> OrgParser m Text -> OrgParser m Text
    forall a b. (a -> b) -> a -> b
    $ do
      Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char '['
      [OrgParser m Text] -> OrgParser m Text
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice [ ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m Text
    forall end s (m :: * -> *) t st.
    (Show end, Stream s m t) =>
    ParserT s st m Char -> ParserT s st m end -> ParserT s st m Text
    many1TillChar ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    digit (Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ']')
             , Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    (<>) (Text -> Text -> Text)
    -> OrgParser m Text
    -> ParsecT
         Text OrgParserState (ReaderT OrgParserLocal m) (Text -> Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Text -> OrgParser m Text
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Text -> ParsecT s u m Text
    textStr "fn:"
                    ParsecT
      Text OrgParserState (ReaderT OrgParserLocal m) (Text -> Text)
    -> OrgParser m Text -> OrgParser m Text
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m Text
    forall end s (m :: * -> *) t st.
    (Show end, Stream s m t) =>
    ParserT s st m Char -> ParserT s st m end -> ParserT s st m Text
    many1TillChar (String
    -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    String -> ParsecT s u m Char
    noneOf "\n\r\t ") (Char -> ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) u.
    Stream s m Char =>
    Char -> ParsecT s u m Char
    char ']')
             ]

    -- | Succeeds if the parser is at the end of a block.
    endOfBlock :: Monad m => OrgParser m ()
    endOfBlock :: OrgParser m ()
    endOfBlock = OrgParser m () -> OrgParser m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    ParsecT s u m a -> ParsecT s u m a
    lookAhead (OrgParser m () -> OrgParser m ())
    -> (OrgParser m () -> OrgParser m ())
    -> OrgParser m ()
    -> OrgParser m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . OrgParser m () -> OrgParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m () -> OrgParser m ())
    -> OrgParser m () -> OrgParser m ()
    forall a b. (a -> b) -> a -> b
    $
      ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
    blankline OrgParser m () -> OrgParser m () -> OrgParser m ()
    forall s u (m :: * -> *) a.
    ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
    <|> OrgParser m ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    anyBlockStart
     where
       -- Succeeds if there is a new block starting at this position.
       anyBlockStart :: Monad m => OrgParser m ()
       anyBlockStart :: OrgParser m ()
    anyBlockStart = OrgParser m () -> OrgParser m ()
    forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
    try (OrgParser m () -> OrgParser m ())
    -> ([OrgParser m ()] -> OrgParser m ())
    -> [OrgParser m ()]
    -> OrgParser m ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [OrgParser m ()] -> OrgParser m ()
    forall s (m :: * -> *) t u a.
    Stream s m t =>
    [ParsecT s u m a] -> ParsecT s u m a
    choice ([OrgParser m ()] -> OrgParser m ())
    -> [OrgParser m ()] -> OrgParser m ()
    forall a b. (a -> b) -> a -> b
    $
         [ OrgParser m ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    exampleLineStart
         , OrgParser m ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    hline
         , OrgParser m ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    metaLineStart
         , OrgParser m ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    commentLineStart
         , OrgParser m ()
    forall (m :: * -> *). Monad m => OrgParser m ()
    gridTableStart
         , ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> OrgParser m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *). Monad m => OrgParser m Text
    noteMarker
         , ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    -> OrgParser m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Char
    forall (m :: * -> *). Monad m => OrgParser m Char
    tableStart
         , ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> OrgParser m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *). Monad m => OrgParser m Text
    drawerStart
         , ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Int
    -> OrgParser m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Int
    forall (m :: * -> *). Monad m => OrgParser m Int
    headerStart
         , ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    -> OrgParser m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Text
    forall (m :: * -> *). Monad m => OrgParser m Text
    latexEnvStart
         , ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Int
    -> OrgParser m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Int
    forall (m :: * -> *). Monad m => OrgParser m Int
    bulletListStart
         , ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Int
    -> OrgParser m ()
    forall (f :: * -> *) a. Functor f => f a -> f ()
    void ParsecT Text OrgParserState (ReaderT OrgParserLocal m) Int
    forall (m :: * -> *). Monad m => OrgParser m Int
    orderedListStart
         ]