-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | CSS selectors for HXT -- -- This package makes it possible to easily traverse (X)HTML/XML -- documents using CSS selectors. It supports all CSS level 3 selectors -- except the ones that do not make sense outside a web browser (e.g. -- such as :hover or ::first-letter). Also, there is no -- support for namespaced selectors. @package hxt-css @version 0.1.0.1 -- | Data types for the abstract syntax tree of CSS selectors. We (mostly) -- follow the naming conventions of the CSS Level 3 specification -- document (http://www.w3.org/TR/css3-selectors/). The type -- hierarchy tries to strike a balance between correctness and -- complexity. As a result, it is possible to construct values that -- correspond to invalid selectors. For example, -- --
-- Negation (Negation UniversalSelector) ---- -- is not valid according to the spec, as double negation is not allowed. -- Note that parseCSS never produces invalid selectors. module Text.XML.HXT.CSS.TypeDefs -- | The top-level selector type. newtype SelectorsGroup -- |
-- E, F --SelectorsGroup :: [Selector] -> SelectorsGroup data Selector -- |
-- E --Selector :: SimpleSelectorSeq -> Selector -- |
-- E F --Descendant :: SimpleSelectorSeq -> Selector -> Selector -- |
-- E > F --Child :: SimpleSelectorSeq -> Selector -> Selector -- |
-- E + F --AdjSibling :: SimpleSelectorSeq -> Selector -> Selector -- |
-- E ~ F --FolSibling :: SimpleSelectorSeq -> Selector -> Selector newtype SimpleSelectorSeq -- |
-- tag#id.class:pseudo --SimpleSelectorSeq :: [SimpleSelector] -> SimpleSelectorSeq data SimpleSelector -- |
-- * --UniversalSelector :: SimpleSelector -- |
-- tag --TypeSelector :: String -> SimpleSelector -- |
-- #id --IdSelector :: String -> SimpleSelector -- |
-- .class --ClassSelector :: String -> SimpleSelector -- |
-- [..] --AttrSelector :: String -> AttrTest -> SimpleSelector -- |
-- :pseudo --Pseudo :: PseudoClass -> SimpleSelector -- |
-- :pseudo(2) --PseudoNth :: PseudoNthClass -> SimpleSelector -- |
-- :not(..) --Negation :: SimpleSelector -> SimpleSelector data AttrTest -- |
-- [attr] --AttrExists :: AttrTest -- |
-- [attr=var] --AttrEq :: String -> AttrTest -- |
-- [attr~=var] --AttrContainsSp :: String -> AttrTest -- |
-- [attr|=var] --AttrBeginHy :: String -> AttrTest -- |
-- [attr^=var] --AttrPrefix :: String -> AttrTest -- |
-- [attr$=var] --AttrSuffix :: String -> AttrTest -- |
-- [attr*=var] --AttrSubstr :: String -> AttrTest -- | Pseudo classes. data PseudoClass -- |
-- :first-child --PseudoFirstChild :: PseudoClass -- |
-- :last-child --PseudoLastChild :: PseudoClass -- |
-- :only-child --PseudoOnlyChild :: PseudoClass -- |
-- :first-of-type --PseudoFirstOfType :: PseudoClass -- |
-- :last-of-type --PseudoLastOfType :: PseudoClass -- |
-- :only-of-type --PseudoOnlyOfType :: PseudoClass -- |
-- :empty --PseudoEmpty :: PseudoClass -- |
-- :root --PseudoRoot :: PseudoClass -- | Pseudo classes that expect a argument of type Nth. data PseudoNthClass -- |
-- :nth-child(..) --PseudoNthChild :: Nth -> PseudoNthClass -- |
-- :nth-last-child(..) --PseudoNthLastChild :: Nth -> PseudoNthClass -- |
-- :nth-of-type(..) --PseudoNthOfType :: Nth -> PseudoNthClass -- |
-- :nth-last-of-type(..) --PseudoNthLastOfType :: Nth -> PseudoNthClass -- | Type of the argument of the :nth-child -- (PseudoNthClass) family of pseudo classes. Nth a -- b matches with all integers that can be written in the form -- an+b for some nonnegative integer n. data Nth -- |
-- an+b --Nth :: Int -> Int -> Nth -- |
-- odd --Odd :: Nth -- |
-- even --Even :: Nth -- | Find a PseudoClass given its name (without the colon). findPseudoClass :: String -> Maybe PseudoClass -- | Find a PseudoNthClass given its name (without the colon). findPseudoNthClass :: String -> Maybe (Nth -> PseudoNthClass) -- | Check whether an integer satisfies a "Diophantine" constraint given in -- form of a value of type Nth. testNth :: Nth -> Int -> Bool instance Show AttrTest instance Eq AttrTest instance Show PseudoClass instance Eq PseudoClass instance Show Nth instance Eq Nth instance Show PseudoNthClass instance Eq PseudoNthClass instance Show SimpleSelector instance Eq SimpleSelector instance Show SimpleSelectorSeq instance Eq SimpleSelectorSeq instance Show Selector instance Eq Selector instance Show SelectorsGroup instance Eq SelectorsGroup -- | A parser for CSS selectors. module Text.XML.HXT.CSS.Parser -- | Parse a string to an AST. If the parser fails, it returns a left value -- with an error message. safeParseCSS :: String -> Either String SelectorsGroup -- | Like safeParseCSS, but calls error if given an invalid -- CSS selector. parseCSS :: String -> SelectorsGroup -- | Turn a CSS selector into an HXT arrow. module Text.XML.HXT.CSS -- | Select elements from an HTML document with a CSS selector. css :: (ArrowXml a, Css s) => s -> a XmlTree XmlTree -- | Like css, except that the selector is anchored at the top. For -- example, cssShallow "div" will only select -- div elements that are in the input of the arrow, it will not -- recursively search for divs contained deeper in the document -- tree. The latter can be selected by cssShallow "* div" -- but is recommended to use css for that. In other words, -- cssShallow "div" corresponds to the "/div" -- XPath expression, whereas cssShallow "* div" -- corresponds to "//div". cssShallow :: (ArrowXml a, Css s) => s -> a XmlTree XmlTree -- | Like css, except that it operates on navigatable XML trees. cssNav :: (ArrowXml a, Css s) => s -> a XmlNavTree XmlNavTree -- | Like cssShallow, except that it operates on navigatable XML -- trees. cssShallowNav :: (ArrowXml a, Css s) => s -> a XmlNavTree XmlNavTree -- | Things that can be used as a CSS selector. The String instance -- uses safeParseCSS to parse the string. class Css s where selectDeep s = multi (isElemN >>> select s) instance Css PseudoNthClass instance Css PseudoClass instance Css SimpleSelector instance Css SimpleSelectorSeq instance Css Selector instance Css SelectorsGroup instance Css [Char]