Commit 591c9af7 authored by Taddeus Kroes's avatar Taddeus Kroes

Code cleanup

parent 369ee206
...@@ -29,9 +29,9 @@ let prune_duplicates decls = ...@@ -29,9 +29,9 @@ let prune_duplicates decls =
in in
prune 0 decls prune 0 decls
let transform = function let compress =
Util.transform_stylesheet begin function
| Statement (Ruleset (selectors, decls)) -> | Statement (Ruleset (selectors, decls)) ->
Statement (Ruleset (selectors, prune_duplicates decls)) Statement (Ruleset (selectors, prune_duplicates decls))
| v -> v | v -> v
end
let compress = Util.transform_stylesheet transform
...@@ -274,16 +274,16 @@ let make_shorthands decls = ...@@ -274,16 +274,16 @@ let make_shorthands decls =
in in
List.filter keep_prop decls @ shorthands List.filter keep_prop decls @ shorthands
let transform = function let compress =
Util.transform_stylesheet begin function
| Statement (Ruleset (selectors, decls)) -> | Statement (Ruleset (selectors, decls)) ->
Statement (Ruleset (selectors, make_shorthands decls)) Statement (Ruleset (selectors, make_shorthands decls))
| v -> v | v -> v
end
let compress = Util.transform_stylesheet transform let unfold_stylesheet =
Util.transform_stylesheet begin function
let transform_unfold = function
| Statement (Ruleset (selectors, decls)) -> | Statement (Ruleset (selectors, decls)) ->
Statement (Ruleset (selectors, unfold decls)) Statement (Ruleset (selectors, unfold decls))
| v -> v | v -> v
end
let unfold_stylesheet = Util.transform_stylesheet transform_unfold
...@@ -47,10 +47,10 @@ let shorten_font_weight = function ...@@ -47,10 +47,10 @@ let shorten_font_weight = function
| Ident "bold" -> Number (700.0, None) | Ident "bold" -> Number (700.0, None)
| v -> v | v -> v
let transform = function let compress =
Util.transform_stylesheet begin function
| Expr value -> Expr (shorten_expr value) | Expr value -> Expr (shorten_expr value)
| Declaration ("font-weight", value, imp) -> | Declaration ("font-weight", value, imp) ->
Declaration ("font-weight", shorten_font_weight value, imp) Declaration ("font-weight", shorten_font_weight value, imp)
| v -> v | v -> v
end
let compress = Util.transform_stylesheet transform
...@@ -237,7 +237,7 @@ let is_color = Color_names.is_color ...@@ -237,7 +237,7 @@ let is_color = Color_names.is_color
(* Sorting declarations *) (* Sorting declarations *)
let sort_stylesheet = let sort_stylesheet =
let transform_sort_decls = function transform_stylesheet begin function
| Statement (Ruleset (selectors, decls)) -> | Statement (Ruleset (selectors, decls)) ->
let pattern = Str.regexp "^\\([^-]+\\)-" in let pattern = Str.regexp "^\\([^-]+\\)-" in
let stem x = let stem x =
...@@ -246,6 +246,4 @@ let sort_stylesheet = ...@@ -246,6 +246,4 @@ let sort_stylesheet =
let cmp (a, _, _) (b, _, _) = String.compare (stem a) (stem b) in let cmp (a, _, _) (b, _, _) = String.compare (stem a) (stem b) in
Statement (Ruleset (selectors, List.stable_sort cmp decls)) Statement (Ruleset (selectors, List.stable_sort cmp decls))
| v -> v | v -> v
in end
transform_stylesheet transform_sort_decls
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment