packages feed

mangrove-0.1.0.0: src/Web/Mangrove/Parse/Tree/AfterAfterFrameset.hs

{-|
Description:    Token processing rules between a closing @\</html\>@ tag containing frames of embedded external content.

Copyright:      (c) 2020 Sam May
License:        MPL-2.0
Maintainer:     ag.eitilt@gmail.com

Stability:      stable
Portability:    portable
-}
module Web.Mangrove.Parse.Tree.AfterAfterFrameset
    ( treeAfterAfterFrameset
    ) 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 after frameset" insertion mode]
--      (https://html.spec.whatwg.org/multipage/parsing.html#the-after-after-frameset-insertion-mode)@
-- 
-- The parsing instructions corresponding to the 'AfterAfterFrameset' section
-- of the state machine.
treeAfterAfterFrameset :: TreeBuilder TreeOutput
treeAfterAfterFrameset = next >>= switch
    [ If isComment $ insertComment' InDocument
    , If isDoctype $ \t' -> push t' *> treeInBody
    , If isWhitespace $ \t' -> push t' *> treeInBody
    , If (isStartTag ["html"]) $ \t' -> push t' *> treeInBody
    , If isEOF stopParsing
    , If (isStartTag ["noframes"]) $ \t' -> push t' *> treeInHead
    , Else $ packTreeErrors [UnexpectedNodeAfterFrameset]
    ]