module Language.Ltml.Parser.Document
    ( documentHeadingP
    )
where

import Language.Lsd.AST.Common (Keyword)
import Language.Lsd.AST.Type.Document
    ( DocumentHeadingType (DocumentHeadingType)
    )
import Language.Ltml.AST.Document
    ( DocumentHeading (DocumentHeading)
    )
import Language.Ltml.Parser.Common.Lexeme (nLexeme)
import Language.Ltml.Parser.Footnote (FootnoteParser)
import Language.Ltml.Parser.Footnote.Combinators (withSucceedingFootnotes)
import Language.Ltml.Parser.Text (HangingTextP, hangingTextP')

documentHeadingP
    :: (HangingTextP f)
    => Keyword
    -> DocumentHeadingType
    -> FootnoteParser (f DocumentHeading)
documentHeadingP :: forall (f :: * -> *).
HangingTextP f =>
Keyword
-> DocumentHeadingType -> FootnoteParser (f DocumentHeading)
documentHeadingP Keyword
kw (DocumentHeadingType TextType Void
tt) =
    Parser (f DocumentHeading) -> FootnoteParser (f DocumentHeading)
forall a. Parser a -> FootnoteParser a
withSucceedingFootnotes (Parser (f DocumentHeading) -> FootnoteParser (f DocumentHeading))
-> Parser (f DocumentHeading) -> FootnoteParser (f DocumentHeading)
forall a b. (a -> b) -> a -> b
$
        Parser (f DocumentHeading) -> Parser (f DocumentHeading)
forall (m :: * -> *) a. MonadParser m => m a -> m a
nLexeme (Parser (f DocumentHeading) -> Parser (f DocumentHeading))
-> Parser (f DocumentHeading) -> Parser (f DocumentHeading)
forall a b. (a -> b) -> a -> b
$
            ([HeadingTextTree] -> DocumentHeading)
-> f [HeadingTextTree] -> f DocumentHeading
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [HeadingTextTree] -> DocumentHeading
DocumentHeading (f [HeadingTextTree] -> f DocumentHeading)
-> ParsecT Void Text Identity (f [HeadingTextTree])
-> Parser (f DocumentHeading)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Keyword
-> TextType Void
-> ParsecT Void Text Identity (f [HeadingTextTree])
forall (f :: * -> *) (m :: * -> *) lbrk fnref style enumType enum
       special.
(HangingTextP f, ParserWrapper m, LineBreakP lbrk,
 FootnoteRefP fnref, StyleP style, EnumP enumType enum,
 SpecialP m special) =>
Keyword
-> TextType enumType
-> m (f [TextTree lbrk fnref style enum special])
forall (m :: * -> *) lbrk fnref style enumType enum special.
(ParserWrapper m, LineBreakP lbrk, FootnoteRefP fnref,
 StyleP style, EnumP enumType enum, SpecialP m special) =>
Keyword
-> TextType enumType
-> m (f [TextTree lbrk fnref style enum special])
hangingTextP' Keyword
kw TextType Void
tt