62 |
deriving Show |
deriving Show |
63 |
|
|
64 |
|
|
65 |
|
is_ruleset :: Statement -> Bool |
66 |
|
is_ruleset (Ruleset sels decls) = True |
67 |
|
is_ruleset _ = False |
68 |
|
|
69 |
|
is_media :: Statement -> Bool |
70 |
|
is_media (Media media stmts) = True |
71 |
|
is_media _ = False |
72 |
|
|
73 |
|
is_page :: Statement -> Bool |
74 |
|
is_page (Page page decls) = True |
75 |
|
is_page _ = False |
76 |
|
|
77 |
|
|
78 |
show_stylesheet :: Stylesheet -> [String] |
show_stylesheet :: Stylesheet -> [String] |
79 |
show_stylesheet (Stylesheet c is ss) = show_charset c ++ |
show_stylesheet (Stylesheet c is ss) = show_charset c ++ |
80 |
map show_import (reverse is) ++ |
map show_import (reverse is) ++ |
90 |
|
|
91 |
show_statement :: Statement -> String |
show_statement :: Statement -> String |
92 |
show_statement (Ruleset ss ds) = |
show_statement (Ruleset ss ds) = |
93 |
(concat . intersperse ", " . map show_selector) ss ++ |
show_selectors ss ++ |
94 |
" { " ++ |
" { " ++ |
95 |
(concat . intersperse "; " . map show_declaration) ds ++ |
(concat . intersperse "; " . map show_declaration) ds ++ |
96 |
" }" |
" }" |
97 |
|
show_statement (Media media stmts) = |
98 |
|
"@media " ++ (concat . intersperse ", ") media ++ |
99 |
|
" {\n" ++ |
100 |
|
(unlines . map ('\t':) . map show_statement) stmts ++ |
101 |
|
"}" |
102 |
show_statement z = "(statement)" |
show_statement z = "(statement)" |
103 |
|
|
104 |
|
show_selectors :: [Selector] -> String |
105 |
|
show_selectors = concat . intersperse ", " . map show_selector |
106 |
|
|
107 |
show_selector :: Selector -> String |
show_selector :: Selector -> String |
108 |
show_selector [] = "" |
show_selector [] = "" |
109 |
show_selector ((ss, c):zs) = show_simple_selector ss ++ |
show_selector ((ss, c):zs) = show_simple_selector ss ++ |