Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- cssPriorityAgent :: StyleSheet s => s -> s
- cssPriorityUser :: StyleSheet s => s -> s
- cssPriorityAuthor :: StyleSheet s => s -> s
- class PropertyParser a where
- data TrivialPropertyParser = TrivialPropertyParser [(String, [Token])]
- class StyleSheet s where
- setPriority :: Int -> s -> s
- setPriorities :: [Int] -> s -> s
- addRule :: s -> StyleRule -> s
- addAtRule :: s -> Text -> [Token] -> (s, [Token])
- data TrivialStyleSheet = TrivialStyleSheet [StyleRule]
- type Props = [(Text, [Token])]
- data Element = ElementNode {}
- data Attribute = Attribute Text Text String
- elementPath :: Element -> [Int]
- compileAttrTest :: PropertyTest -> String -> Bool
- matched :: t -> Bool
- attrTest :: Maybe Text -> Text -> PropertyTest -> Element -> Bool
- hasWord :: String -> String -> Bool
- hasLang :: [Char] -> [Char] -> Bool
- parseUnorderedShorthand :: PropertyParser a => a -> [Text] -> [Token] -> [(Text, [Token])]
- parseUnorderedShorthand' :: PropertyParser a => a -> [Text] -> [[Token]] -> [(Text, [Token])]
- parseOperands :: [Token] -> [[Token]]
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.
Default styles.
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.
Instances
PropertyParser TrivialPropertyParser Source # | |
Defined in Stylist temp :: TrivialPropertyParser Source # inherit :: TrivialPropertyParser -> TrivialPropertyParser Source # priority :: TrivialPropertyParser -> [Text] Source # shorthand :: TrivialPropertyParser -> Text -> [Token] -> [(Text, [Token])] Source # longhand :: TrivialPropertyParser -> TrivialPropertyParser -> Text -> [Token] -> Maybe TrivialPropertyParser Source # getVars :: TrivialPropertyParser -> Props Source # setVars :: Props -> TrivialPropertyParser -> TrivialPropertyParser Source # pseudoEl :: TrivialPropertyParser -> Text -> (TrivialPropertyParser -> Maybe TrivialPropertyParser -> TrivialPropertyParser) -> TrivialPropertyParser Source # |
data TrivialPropertyParser Source #
Gathers properties as a key'd list.
Works well with lookup
.
TrivialPropertyParser [(String, [Token])] |
Instances
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.
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
StyleSheet () Source # | In case an indirect caller doesn't actually want to use Haskell Stylist. |
StyleSheet TrivialStyleSheet Source # | |
Defined in Stylist.Parse setPriority :: Int -> TrivialStyleSheet -> TrivialStyleSheet Source # setPriorities :: [Int] -> TrivialStyleSheet -> TrivialStyleSheet Source # addRule :: TrivialStyleSheet -> StyleRule -> TrivialStyleSheet Source # addAtRule :: TrivialStyleSheet -> Text -> [Token] -> (TrivialStyleSheet, [Token]) Source # |
data TrivialStyleSheet Source #
Gathers StyleRules into a list, mainly for testing.
Instances
Eq TrivialStyleSheet Source # | |
Defined in Stylist.Parse (==) :: TrivialStyleSheet -> TrivialStyleSheet -> Bool (/=) :: TrivialStyleSheet -> TrivialStyleSheet -> Bool | |
Show TrivialStyleSheet Source # | |
Defined in Stylist.Parse showsPrec :: Int -> TrivialStyleSheet -> ShowS show :: TrivialStyleSheet -> String showList :: [TrivialStyleSheet] -> ShowS | |
StyleSheet TrivialStyleSheet Source # | |
Defined in Stylist.Parse setPriority :: Int -> TrivialStyleSheet -> TrivialStyleSheet Source # setPriorities :: [Int] -> TrivialStyleSheet -> TrivialStyleSheet Source # addRule :: TrivialStyleSheet -> StyleRule -> TrivialStyleSheet Source # addAtRule :: TrivialStyleSheet -> Text -> [Token] -> (TrivialStyleSheet, [Token]) Source # |
An inversely-linked tree of elements, to apply CSS selectors to.
A key-value attribute.
Attribute Text Text String |
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.
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.