mangrove-0.1.0.0: src/Web/Mangrove/Parse/Tree/AfterFrameset.hs
{-|
Description: Token processing rules between the closing @\</frameset\>@ and @\</html\>@ tags.
Copyright: (c) 2020 Sam May
License: MPL-2.0
Maintainer: ag.eitilt@gmail.com
Stability: stable
Portability: portable
-}
module Web.Mangrove.Parse.Tree.AfterFrameset
( treeAfterFrameset
) where
import Web.Mangrove.Parse.Common.Error
import Web.Mangrove.Parse.Tree.Common
import Web.Mangrove.Parse.Tree.InBody
import Web.Mangrove.Parse.Tree.InHead
import Web.Mangrove.Parse.Tree.Patch
import Web.Willow.Common.Parser
import Web.Willow.Common.Parser.Switch
-- | __HTML:__
-- @[the "after frameset" insertion mode]
-- (https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-afterframeset)@
--
-- The parsing instructions corresponding to the 'AfterFrameset' section of the
-- state machine.
treeAfterFrameset :: TreeBuilder TreeOutput
treeAfterFrameset = next >>= switch
[ If isWhitespace insertCharacter
, If isComment insertComment
, If isDoctype $ \t' ->
packTreeErrors [UnexpectedDoctype $ tokenDocumentType t'] t'
, If (isStartTag ["html"]) $ \t' -> do
push t'
treeInBody
, If (isEndTag ["html"]) $ \t' -> switchMode AfterAfterFrameset *> packTreeErrors [] t'
, If (isStartTag ["noframes"]) $ \t' -> do
push t'
treeInHead
, If isEOF stopParsing
, Else $ packTreeErrors [UnexpectedNodeAfterFrameset]
]