{-# LANGUAGE OverloadedStrings #-} {-| Description: Token processing rules within a @\@ markup section. Copyright: (c) 2020 Sam May License: MPL-2.0 Maintainer: ag.eitilt@gmail.com Stability: stable Portability: portable -} module Web.Mangrove.Parse.Tree.InColumnGroup ( treeInColumnGroup ) 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 "in column group" insertion mode] -- (https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-incolgroup)@ -- -- The parsing instructions corresponding to the 'InColumnGroup' section of the -- state machine. treeInColumnGroup :: TreeBuilder TreeOutput treeInColumnGroup = 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 (isStartTag ["col"]) insertNullElement , If (isEndTag ["colgroup"]) $ \t' -> do current <- currentNode if maybe False (nodeIsElement "colgroup") current then do switchMode InTable closeCurrentNode t' else packTreeErrors [UnmatchedEndTag $ tokenElement t'] t' , If (isEndTag ["col"]) $ packTreeErrors [UnexpectedEndColInColumnGroup] , If (isStartTag ["template"]) $ \t' -> do push t' treeInHead , If (isEndTag ["template"]) $ \t' -> do push t' treeInHead , If isEOF $ \t' -> do push t' treeInBody , Else $ \t' -> do current <- currentNode if maybe False (nodeIsElement "colgroup") current then do push t' switchMode InTable close <- closeCurrentNode_ packTree_ close else packTreeErrors [UnexpectedElementWithImpliedEndTag] t' ]