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

Stylist

Synopsis

Documentation

cssPriorityAgent :: StyleSheet s => s -> s Source #

Set the priority for a CSS stylesheet being parsed.

cssPriorityUser :: StyleSheet s => s -> s Source #

Set the priority for a CSS stylesheet being parsed.

cssPriorityAuthor :: StyleSheet s => s -> s Source #

Set the priority for a CSS stylesheet being parsed.

class PropertyParser a where Source #

Defines how to parse CSS properties into an output "style" format.

Minimal complete definition

temp, longhand

Methods

temp :: a Source #

Default styles.

inherit :: a -> a Source #

Creates a style inherited from a parent style.

priority :: a -> [Text] Source #

shorthand :: a -> Text -> [Token] -> [(Text, [Token])] Source #

Expand a shorthand property into longhand properties.

longhand :: a -> a -> Text -> [Token] -> Maybe a Source #

Mutates self to store the given CSS property, if it's syntax is valid. longhand parent self name value

getVars :: a -> Props Source #

Retrieve stored variables, optional.

setVars :: Props -> a -> a Source #

Save variable values, optional.

pseudoEl :: a -> Text -> (a -> Maybe a -> a) -> a Source #

Mutates self to store the given pseudoelement styles, passing a callback so you can alter the parent & (for interactive pseudoclasses) base styles.

class StyleSheet s where Source #

Describes how to store, and to some extent parse, CSS stylesheets. These methods are used to construct the results from parse, etc.

Minimal complete definition

addRule

Methods

setPriority :: Int -> s -> s Source #

Sets the stylesheet priority (useragent vs user vs author), optional. Favor setPriorities for richer API.

setPriorities :: [Int] -> s -> s Source #

Sets the multi-layered stylesheet priority (for the sake of @layer rules), optional.

addRule :: s -> StyleRule -> s Source #

Stores a parsed selector+properties rule.

addAtRule :: s -> Text -> [Token] -> (s, [Token]) Source #

Stores and parses an identified at-rule.

Instances

Instances details
StyleSheet () Source #

In case an indirect caller doesn't actually want to use Haskell Stylist.

Instance details

Defined in Stylist.Parse

Methods

setPriority :: Int -> () -> () Source #

setPriorities :: [Int] -> () -> () Source #

addRule :: () -> StyleRule -> () Source #

addAtRule :: () -> Text -> [Token] -> ((), [Token]) Source #

StyleSheet TrivialStyleSheet Source # 
Instance details

Defined in Stylist.Parse

data TrivialStyleSheet Source #

Gathers StyleRules into a list, mainly for testing.

type Props = [(Text, [Token])] Source #

"key: value;" entries to be parsed into an output type.

data Element Source #

An inversely-linked tree of elements, to apply CSS selectors to.

Constructors

ElementNode 

Fields

data Attribute Source #

A key-value attribute.

Constructors

Attribute Text Text String 

Instances

Instances details
Eq Attribute Source # 
Instance details

Defined in Stylist

Methods

(==) :: Attribute -> Attribute -> Bool

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

Ord Attribute Source # 
Instance details

Defined in Stylist

Methods

compare :: Attribute -> Attribute -> Ordering

(<) :: Attribute -> Attribute -> Bool

(<=) :: Attribute -> Attribute -> Bool

(>) :: Attribute -> Attribute -> Bool

(>=) :: Attribute -> Attribute -> Bool

max :: Attribute -> Attribute -> Attribute

min :: Attribute -> Attribute -> Attribute

elementPath :: Element -> [Int] Source #

Computes the child indices to traverse to reach the given element.

compileAttrTest :: PropertyTest -> String -> Bool Source #

Converts a property text into a callback testing against a string.

matched :: t -> Bool Source #

returns True regardless of value.

attrTest :: Maybe Text -> Text -> PropertyTest -> Element -> Bool Source #

Test whether the element matches a parsed property test, for the given attribute.

hasWord :: String -> String -> Bool Source #

Tests the given word is in the whitespace-seperated value.

hasLang :: [Char] -> [Char] -> Bool Source #

Tests whether the attribute holds the expected value or a sub-locale.

parseUnorderedShorthand :: PropertyParser a => a -> [Text] -> [Token] -> [(Text, [Token])] Source #

Utility for parsing shorthand attributes which don't care in which order the subproperties are specified. Each property must parse only a single function or token.

parseUnorderedShorthand' :: PropertyParser a => a -> [Text] -> [[Token]] -> [(Text, [Token])] Source #

Variant of parseUnorderedShorthand taking pre-split list.

parseOperands :: [Token] -> [[Token]] Source #

Splits a token list so each function is it's own list. Other tokens are split into their own singletons.