stylist-traits-0.1.3.1: Traits, datatypes, & parsers for Haskell Stylist
Safe HaskellNone
LanguageHaskell2010

Stylist.Parse.Selector

Description

Parses CSS selectors See parseSelectors

Synopsis

Documentation

data Selector Source #

A CSS "selector" indicating which elements should be effected by CSS.

Constructors

Element [SimpleSelector]

Selects a single element.

Child Selector [SimpleSelector]

Represents "a > b" operator.

Descendant Selector [SimpleSelector]

Represents "a b" operator.

Adjacent Selector [SimpleSelector]

Represents "a + b" operator.

Sibling Selector [SimpleSelector]

Represents "a ~ b" operator.

Instances

Instances details
Eq Selector Source # 
Instance details

Defined in Stylist.Parse.Selector

Methods

(==) :: Selector -> Selector -> Bool

(/=) :: Selector -> Selector -> Bool

Show Selector Source # 
Instance details

Defined in Stylist.Parse.Selector

Methods

showsPrec :: Int -> Selector -> ShowS

show :: Selector -> String

showList :: [Selector] -> ShowS

data SimpleSelector Source #

An individual test comprising a CSS stylesheet.

Constructors

Tag Text

Matches a tagname, e.g. "a"

Namespace Text 
Id Text

Matches the "id" attribute, e.g. "#header"

Class Text

Matches the "class" attribute, e.g. ".ad"

Property (Maybe Text) Text PropertyTest

Matches a specified property

Psuedoclass Text [Token]

Matches psuedoclasses provided by the caller (via a nameless property).

Instances

Instances details
Eq SimpleSelector Source # 
Instance details

Defined in Stylist.Parse.Selector

Show SimpleSelector Source # 
Instance details

Defined in Stylist.Parse.Selector

Methods

showsPrec :: Int -> SimpleSelector -> ShowS

show :: SimpleSelector -> String

showList :: [SimpleSelector] -> ShowS

data PropertyTest Source #

How should a property be matched.

Constructors

Exists

Matches whether an attribute actually exists, e.g. "[title]"

Equals Text

Matches whether the attribute is exactly equal to the value, e.g. "="

Suffix Text

Matches whether attribute ends with the given value, e.g. "$="

Prefix Text

Matches whether attribute starts with the given value, e.g. "^="

Substring Text

Matches whether the attribute contains the given value, e.g. "*="

Include Text

Is one of the whitespace-seperated values the one specified? e.g. "~="

Dash Text

Matches whitespace seperated values, or their "-"-seperated prefixes. e.g. "|="

Callback PropertyFunc

Calls the given function to test this property.

Instances

Instances details
Eq PropertyTest Source # 
Instance details

Defined in Stylist.Parse.Selector

Methods

(==) :: PropertyTest -> PropertyTest -> Bool

(/=) :: PropertyTest -> PropertyTest -> Bool

Show PropertyTest Source # 
Instance details

Defined in Stylist.Parse.Selector

Methods

showsPrec :: Int -> PropertyTest -> ShowS

show :: PropertyTest -> String

showList :: [PropertyTest] -> ShowS

data PropertyFunc Source #

Caller-specified functions to extend property selection. Has incorrect Show/Eq implementations so this rare exception doesn't break things.

Constructors

PropertyFunc (String -> Bool) 

Instances

Instances details
Eq PropertyFunc Source # 
Instance details

Defined in Stylist.Parse.Selector

Methods

(==) :: PropertyFunc -> PropertyFunc -> Bool

(/=) :: PropertyFunc -> PropertyFunc -> Bool

Show PropertyFunc Source # 
Instance details

Defined in Stylist.Parse.Selector

Methods

showsPrec :: Int -> PropertyFunc -> ShowS

show :: PropertyFunc -> String

showList :: [PropertyFunc] -> ShowS

parseSelectors :: Parser [Selector] Source #

Parses a CSS selector.