/[james]/factorcss/CSS.hs
ViewVC logotype

Diff of /factorcss/CSS.hs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 61 by james, Sun Dec 19 22:10:41 2004 UTC revision 62 by james, Mon Dec 27 19:11:07 2004 UTC
# Line 62  data Value Line 62  data Value
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) ++
# Line 77  show_import (url, media) = "@import " ++ Line 90  show_import (url, media) = "@import " ++
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 ++

Legend:
Removed from v.61  
changed lines
  Added in v.62

  ViewVC Help
Powered by ViewVC 1.1.26