module FF.HTML.Spec.Loose.Selector where
open import Agda.Builtin.String using (String)
open import Cubical.Data.Bool.Base using (Bool; false)
open import Cubical.Data.List.Base using (List; [])
import FF.HTML.Selector.Core as Selector
import FF.HTML.Selector.Semantics as Semantics
import FF.HTML.Spec.Loose as Loose
CompoundT : _
CompoundT = Selector.CompoundSelector Loose.spec
ComplexT : _
ComplexT = Selector.ComplexSelector Loose.spec
SelectorT : _
SelectorT = Selector.SelectorList Loose.spec
TypedSimpleT : String -> _
TypedSimpleT tagName = Selector.TypedSimple Loose.spec tagName
UntypedSimpleT : _
UntypedSimpleT = Selector.UntypedSimple Loose.spec
any : CompoundT
any = Selector.universal []
tag : String -> CompoundT
tag tagName = Selector.typed tagName []
tagWith : (tagName : String) -> List (TypedSimpleT tagName) -> CompoundT
tagWith = Selector.typed
idIs : String -> UntypedSimpleT
idIs = Selector.rawId
classContains : String -> UntypedSimpleT
classContains = Selector.rawClass
attrPresent : String -> UntypedSimpleT
attrPresent name = Selector.rawAttribute name Selector.rawPresent
attrEquals : String -> String -> UntypedSimpleT
attrEquals name value =
Selector.rawAttribute name
(Selector.rawMatch Selector.exact value Selector.documentCase)
noPseudo : Semantics.ElementContext Loose.spec -> String -> Bool
noPseudo _ _ = false
noFunctionalPseudo :
Semantics.ElementContext Loose.spec ->
String ->
String ->
Bool
noFunctionalPseudo _ _ _ = false
matcherWith : Semantics.TextDeciders -> Semantics.SelectorMatcher Loose.spec
matcherWith text =
Semantics.matcherFromRenderer
Loose.renderer
text
(\ keyName -> Semantics.sameText text keyName "id")
(\ keyName -> Semantics.sameText text keyName "class")
noPseudo
noFunctionalPseudo
matcher : Semantics.SelectorMatcher Loose.spec
matcher = matcherWith Semantics.exactOnlyTextDeciders
render : SelectorT -> String
render = Selector.renderSelectorList Loose.renderer
matchesRootWith : Semantics.TextDeciders -> SelectorT -> Loose.HtmlT -> Bool
matchesRootWith text = Semantics.matchesRoot (matcherWith text)
matchesRoot : SelectorT -> Loose.HtmlT -> Bool
matchesRoot = Semantics.matchesRoot matcher
selectWith : Semantics.TextDeciders -> SelectorT -> Loose.HtmlT -> List Loose.HtmlT
selectWith text = Semantics.select (matcherWith text)
select : SelectorT -> Loose.HtmlT -> List Loose.HtmlT
select = Semantics.select matcher