File tree Expand file tree Collapse file tree 3 files changed +112
-2
lines changed Expand file tree Collapse file tree 3 files changed +112
-2
lines changed Original file line number Diff line number Diff line change @@ -213,6 +213,50 @@ module.exports = function(css){
213
213
return { media : media , rules : style } ;
214
214
}
215
215
216
+ /**
217
+ * Parse paged media.
218
+ */
219
+
220
+ function atpage ( ) {
221
+ var m = match ( / ^ @ p a g e * / ) ;
222
+ if ( ! m ) return ;
223
+
224
+ var sel = selector ( ) || [ ] ;
225
+ var decls = [ ] ;
226
+
227
+ if ( ! open ( ) ) return ;
228
+ comments ( ) ;
229
+
230
+ // declarations
231
+ var decl ;
232
+ while ( decl = declaration ( ) || atmargin ( ) ) {
233
+ decls . push ( decl ) ;
234
+ comments ( ) ;
235
+ }
236
+
237
+ if ( ! close ( ) ) return ;
238
+
239
+ return {
240
+ type : "page" ,
241
+ selectors : sel ,
242
+ declarations : decls
243
+ } ;
244
+ }
245
+
246
+ /**
247
+ * Parse margin at-rules
248
+ */
249
+
250
+ function atmargin ( ) {
251
+ var m = match ( / ^ @ ( [ a - z \- ] + ) * / ) ;
252
+ if ( ! m ) return ;
253
+ var type = m [ 1 ]
254
+
255
+ return {
256
+ type : type ,
257
+ declarations : declarations ( )
258
+ }
259
+ }
216
260
217
261
/**
218
262
* Parse import
@@ -281,8 +325,8 @@ module.exports = function(css){
281
325
|| supports ( )
282
326
|| atimport ( )
283
327
|| atcharset ( )
284
- || atnamespace ( ) ;
285
-
328
+ || atnamespace ( )
329
+ || atpage ( ) ;
286
330
}
287
331
288
332
/**
Original file line number Diff line number Diff line change
1
+ @page toc, index: blank {
2
+ color : green;
3
+
4
+ @top-left {
5
+ content : "foo" ;
6
+ color : blue;
7
+ }
8
+ @top-right {
9
+ content : "bar" ;
10
+ }
11
+ }
12
+
13
+ @page {
14
+ font-size : 16pt ;
15
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "stylesheet" : {
3
+ "rules" : [
4
+ {
5
+ "type" : " page" ,
6
+ "selectors" : [
7
+ " toc" ,
8
+ " index:blank"
9
+ ],
10
+ "declarations" : [
11
+ {
12
+ "property" : " color" ,
13
+ "value" : " green"
14
+ },
15
+ {
16
+ "type" : " top-left" ,
17
+ "declarations" : [
18
+ {
19
+ "property" : " content" ,
20
+ "value" : " \" foo\" "
21
+ },
22
+ {
23
+ "property" : " color" ,
24
+ "value" : " blue"
25
+ }
26
+ ]
27
+ },
28
+ {
29
+ "type" : " top-right" ,
30
+ "declarations" : [
31
+ {
32
+ "property" : " content" ,
33
+ "value" : " \" bar\" "
34
+ }
35
+ ]
36
+ }
37
+ ]
38
+ },
39
+ {
40
+ "type" : " page" ,
41
+ "selectors" : [],
42
+ "declarations" : [
43
+ {
44
+ "property" : " font-size" ,
45
+ "value" : " 16pt"
46
+ }
47
+ ]
48
+ }
49
+ ]
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments