File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ @media screen, projection {
2
+ html {
3
+ background : # fffef0 ;
4
+ color : # 300 ;
5
+ }
6
+ body {
7
+ max-width : 35em ;
8
+ margin : 0 auto;
9
+ }
10
+ }
11
+
12
+ @media print {
13
+ html {
14
+ background : # fff ;
15
+ color : # 000 ;
16
+ }
17
+ body {
18
+ padding : 1in ;
19
+ border : 0.5pt solid # 666 ;
20
+ }
21
+ }
Original file line number Diff line number Diff line change
1
+
2
+ /**
3
+ * Module dependencies.
4
+ */
5
+
6
+ var parse = require ( 'css-parse' )
7
+ , stringify = require ( '..' )
8
+ , fs = require ( 'fs' )
9
+ , read = fs . readFileSync
10
+ , css = read ( 'examples/media.css' , 'utf8' ) ;
11
+
12
+ console . log ( stringify ( parse ( css ) , { compress : false } ) ) ;
Original file line number Diff line number Diff line change @@ -22,8 +22,10 @@ module.exports = function(node, options){
22
22
function visit ( options ) {
23
23
var _rule = rule ( options ) ;
24
24
var _keyframes = keyframes ( options ) ;
25
+ var _media = media ( options ) ;
25
26
return function ( node ) {
26
27
if ( node . keyframes ) return _keyframes ( node ) ;
28
+ if ( node . media ) return _media ( node ) ;
27
29
if ( node . import ) return atimport ( node ) ;
28
30
return _rule ( node ) ;
29
31
}
@@ -37,6 +39,20 @@ function atimport(rule) {
37
39
return '@import ' + rule . import + ';' ;
38
40
}
39
41
42
+ /**
43
+ * Compile media.
44
+ */
45
+
46
+ function media ( options ) {
47
+ return function ( media ) {
48
+ return '@media '
49
+ + media . media
50
+ + ' {\n'
51
+ + media . rules . map ( indent ( visit ( options ) ) ) . join ( '\n\n' )
52
+ + '\n}' ;
53
+ }
54
+ }
55
+
40
56
/**
41
57
* Compile keyframes.
42
58
*/
You can’t perform that action at this time.
0 commit comments