~alcinnz/haskell-stylist

ref: b26bb3d190dcd3f81b5acc6c288afc3645dc1420 haskell-stylist/Stylish/Style.hs -rw-r--r-- 647 bytes
b26bb3d1 — Adrian Cochrane Implement basic parser. TODO test. 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Stylish.Style(
        style,
        Style(..),
        Element(..),
        Attribute(..),
    ) where

style :: Style a => Stylist a -> Element -> a
-- Stylist consists of internal types, implements StyleSheet.

class Style s where
    initial :: s
    shorthand :: Text -> [Token] -> [(Text, [Token])]
    shorthand name value
        | Just _ <- longhand initial initial name value = (name, value)
        | otherwise = []
    longhand :: s -> s -> Text -> [Token] -> Maybe s

data Element = Element {
    prev :: Maybe Element,
    parent :: Maybe Element,
    name :: Text,
    attrs :: [Attribute]
}
data Attribute = Attr Text Text