mangrove-0.1.0.0: src/Web/Mangrove/Parse/Tree/AfterAfterBody.hs
{-|
Description: Token processing rules between a closing @\</html\>@ tag containing standard body content.
Copyright: (c) 2020 Sam May
License: MPL-2.0
Maintainer: ag.eitilt@gmail.com
Stability: stable
Portability: portable
-}
module Web.Mangrove.Parse.Tree.AfterAfterBody
( treeAfterAfterBody
) where
import Web.Mangrove.Parse.Common.Error
import Web.Mangrove.Parse.Tree.Common
import Web.Mangrove.Parse.Tree.InBody
import Web.Mangrove.Parse.Tree.Patch
import Web.Willow.Common.Parser
import Web.Willow.Common.Parser.Switch
-- | __HTML:__
-- @[the "after after body" insertion mode]
-- (https://html.spec.whatwg.org/multipage/parsing.html#the-after-after-body-insertion-mode)@
--
-- The parsing instructions corresponding to the 'AfterAfterBody' section of the
-- state machine.
treeAfterAfterBody :: TreeBuilder TreeOutput
treeAfterAfterBody = next >>= switch
[ If isComment $ insertComment' InDocument
, If isDoctype $ \t' -> do
push t'
treeInBody
, If isWhitespace $ \t' -> do
push t'
treeInBody
, If (isStartTag ["html"]) $ \t' -> do
push t'
treeInBody
, If isEOF stopParsing
, Else $ \t' -> do
push t'
switchMode InBody
packTreeErrors_ [UnexpectedContentAfterBody]
]