/[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 63 by james, Mon Dec 27 19:45:02 2004 UTC
# Line 1  Line 1 
1    --
2    -- This file is part of FactorCSS
3    -- Licensed under the MIT License,
4    --                http://www.opensource.org/licenses/mit-license
5    -- Copyright 2004 James Bursa <james@semichrome.net>
6    --
7    
8  -- Datatypes for CSS  -- Datatypes for CSS
9    
10  module CSS where  module CSS where
# Line 62  data Value Line 69  data Value
69          deriving Show          deriving Show
70    
71    
72    is_ruleset :: Statement -> Bool
73    is_ruleset (Ruleset sels decls) = True
74    is_ruleset _ = False
75    
76    is_media :: Statement -> Bool
77    is_media (Media media stmts) = True
78    is_media _ = False
79    
80    is_page :: Statement -> Bool
81    is_page (Page page decls) = True
82    is_page _ = False
83    
84    
85  show_stylesheet :: Stylesheet -> [String]  show_stylesheet :: Stylesheet -> [String]
86  show_stylesheet (Stylesheet c is ss) = show_charset c ++  show_stylesheet (Stylesheet c is ss) = show_charset c ++
87                  map show_import (reverse is) ++                  map show_import (reverse is) ++
# Line 77  show_import (url, media) = "@import " ++ Line 97  show_import (url, media) = "@import " ++
97    
98  show_statement :: Statement -> String  show_statement :: Statement -> String
99  show_statement (Ruleset ss ds) =  show_statement (Ruleset ss ds) =
100                  (concat . intersperse ", " . map show_selector) ss ++                  show_selectors ss ++
101                  " { " ++                  " { " ++
102                  (concat . intersperse "; " . map show_declaration) ds ++                  (concat . intersperse "; " . map show_declaration) ds ++
103                  " }"                  " }"
104    show_statement (Media media stmts) =
105                    "@media " ++ (concat . intersperse ", ") media ++
106                    " {\n" ++
107                    (unlines . map ('\t':) . map show_statement) stmts ++
108                    "}"
109  show_statement z = "(statement)"  show_statement z = "(statement)"
110    
111    show_selectors :: [Selector] -> String
112    show_selectors = concat . intersperse ", " . map show_selector
113    
114  show_selector :: Selector -> String  show_selector :: Selector -> String
115  show_selector [] = ""  show_selector [] = ""
116  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.63

  ViewVC Help
Powered by ViewVC 1.1.26