corrade-nucleus-nucleons – Blame information for rev 24
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
20 | office | 1 | /* |
2 | AUTO-GENERATED. DO NOT MODIFY. |
||
3 | Script: test/generate-tests.js |
||
4 | Template: test/data/css/node.mustache |
||
5 | Data: test/data/css/tests.js |
||
6 | |||
7 | The MIT License (MIT) |
||
8 | |||
9 | Copyright (c) 2007-2017 Einar Lielmanis, Liam Newman, and contributors. |
||
10 | |||
11 | Permission is hereby granted, free of charge, to any person |
||
12 | obtaining a copy of this software and associated documentation files |
||
13 | (the "Software"), to deal in the Software without restriction, |
||
14 | including without limitation the rights to use, copy, modify, merge, |
||
15 | publish, distribute, sublicense, and/or sell copies of the Software, |
||
16 | and to permit persons to whom the Software is furnished to do so, |
||
17 | subject to the following conditions: |
||
18 | |||
19 | The above copyright notice and this permission notice shall be |
||
20 | included in all copies or substantial portions of the Software. |
||
21 | |||
22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||
23 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||
24 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
||
25 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
||
26 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
||
27 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||
28 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||
29 | SOFTWARE. |
||
30 | */ |
||
31 | /*jshint unused:false */ |
||
32 | |||
33 | function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_beautify) |
||
34 | { |
||
35 | |||
36 | var default_opts = { |
||
37 | indent_size: 4, |
||
38 | indent_char: ' ', |
||
39 | preserve_newlines: true, |
||
40 | jslint_happy: false, |
||
41 | keep_array_indentation: false, |
||
42 | brace_style: 'collapse', |
||
43 | space_before_conditional: true, |
||
44 | break_chained_methods: false, |
||
45 | selector_separator: '\n', |
||
46 | end_with_newline: false |
||
47 | }; |
||
48 | var opts; |
||
49 | |||
50 | default_opts.indent_size = 1; |
||
51 | default_opts.indent_char = '\t'; |
||
52 | default_opts.selector_separator_newline = true; |
||
53 | default_opts.end_with_newline = false; |
||
54 | default_opts.newline_between_rules = false; |
||
55 | default_opts.space_around_combinator = false; |
||
56 | default_opts.preserve_newlines = false; |
||
57 | default_opts.space_around_selector_separator = false; |
||
58 | |||
59 | function reset_options() |
||
60 | { |
||
61 | opts = JSON.parse(JSON.stringify(default_opts)); |
||
62 | } |
||
63 | |||
64 | function test_css_beautifier(input) |
||
65 | { |
||
66 | return css_beautify(input, opts); |
||
67 | } |
||
68 | |||
69 | var sanitytest; |
||
70 | |||
71 | // test the input on beautifier with the current flag settings |
||
72 | // does not check the indentation / surroundings as bt() does |
||
73 | function test_fragment(input, expected) |
||
74 | { |
||
75 | expected = expected || expected === '' ? expected : input; |
||
76 | sanitytest.expect(input, expected); |
||
77 | // if the expected is different from input, run it again |
||
78 | // expected output should be unchanged when run twice. |
||
79 | if (expected !== input) { |
||
80 | sanitytest.expect(expected, expected); |
||
81 | } |
||
82 | |||
83 | // Everywhere we do newlines, they should be replaced with opts.eol |
||
84 | opts.eol = '\r\\n'; |
||
85 | expected = expected.replace(/[\n]/g, '\r\n'); |
||
86 | sanitytest.expect(input, expected); |
||
87 | if (input.indexOf('\n') !== -1) { |
||
88 | input = input.replace(/[\n]/g, '\r\n'); |
||
89 | sanitytest.expect(input, expected); |
||
90 | // Ensure support for auto eol detection |
||
91 | opts.eol = 'auto'; |
||
92 | sanitytest.expect(input, expected); |
||
93 | } |
||
94 | opts.eol = '\n'; |
||
95 | } |
||
96 | |||
97 | // test css |
||
98 | function t(input, expectation) |
||
99 | { |
||
100 | var wrapped_input, wrapped_expectation; |
||
101 | |||
102 | expectation = expectation || expectation === '' ? expectation : input; |
||
103 | sanitytest.test_function(test_css_beautifier, 'css_beautify'); |
||
104 | test_fragment(input, expectation); |
||
105 | } |
||
106 | |||
107 | function unicode_char(value) { |
||
108 | return String.fromCharCode(value); |
||
109 | } |
||
110 | |||
111 | function beautifier_tests() |
||
112 | { |
||
113 | sanitytest = test_obj; |
||
114 | |||
115 | reset_options(); |
||
116 | //============================================================ |
||
117 | t(".tabs {}"); |
||
118 | |||
119 | |||
120 | //============================================================ |
||
121 | // End With Newline - (eof = "\n") |
||
122 | reset_options(); |
||
123 | opts.end_with_newline = true; |
||
124 | test_fragment('', '\n'); |
||
125 | test_fragment(' .tabs{}', ' .tabs {}\n'); |
||
126 | test_fragment( |
||
127 | ' \n' + |
||
128 | '\n' + |
||
129 | '.tabs{}\n' + |
||
130 | '\n' + |
||
131 | '\n' + |
||
132 | '\n', |
||
133 | // -- output -- |
||
134 | ' .tabs {}\n'); |
||
135 | test_fragment('\n'); |
||
136 | |||
137 | // End With Newline - (eof = "") |
||
138 | reset_options(); |
||
139 | opts.end_with_newline = false; |
||
140 | test_fragment(''); |
||
141 | test_fragment(' .tabs{}', ' .tabs {}'); |
||
142 | test_fragment( |
||
143 | ' \n' + |
||
144 | '\n' + |
||
145 | '.tabs{}\n' + |
||
146 | '\n' + |
||
147 | '\n' + |
||
148 | '\n', |
||
149 | // -- output -- |
||
150 | ' .tabs {}'); |
||
151 | test_fragment('\n', ''); |
||
152 | |||
153 | |||
154 | //============================================================ |
||
155 | // Empty braces |
||
156 | reset_options(); |
||
157 | t('.tabs{}', '.tabs {}'); |
||
158 | t('.tabs { }', '.tabs {}'); |
||
159 | t('.tabs { }', '.tabs {}'); |
||
160 | t( |
||
161 | '.tabs \n' + |
||
162 | '{\n' + |
||
163 | ' \n' + |
||
164 | ' }', |
||
165 | // -- output -- |
||
166 | '.tabs {}'); |
||
167 | |||
168 | |||
169 | //============================================================ |
||
170 | // |
||
171 | reset_options(); |
||
172 | t( |
||
173 | '#cboxOverlay {\n' + |
||
174 | '\tbackground: url(images/overlay.png) repeat 0 0;\n' + |
||
175 | '\topacity: 0.9;\n' + |
||
176 | '\tfilter: alpha(opacity = 90);\n' + |
||
177 | '}', |
||
178 | // -- output -- |
||
179 | '#cboxOverlay {\n' + |
||
180 | '\tbackground: url(images/overlay.png) repeat 0 0;\n' + |
||
181 | '\topacity: 0.9;\n' + |
||
182 | '\tfilter: alpha(opacity=90);\n' + |
||
183 | '}'); |
||
184 | |||
185 | |||
186 | //============================================================ |
||
187 | // Support simple language specific option inheritance/overriding - (c = " ") |
||
188 | reset_options(); |
||
189 | opts.indent_char = ' '; |
||
190 | opts.indent_size = 4; |
||
191 | opts.js = { 'indent_size': 3 }; |
||
192 | opts.css = { 'indent_size': 5 }; |
||
193 | t( |
||
194 | '.selector {\n' + |
||
195 | ' font-size: 12px;\n' + |
||
196 | '}'); |
||
197 | |||
198 | // Support simple language specific option inheritance/overriding - (c = " ") |
||
199 | reset_options(); |
||
200 | opts.indent_char = ' '; |
||
201 | opts.indent_size = 4; |
||
202 | opts.html = { 'js': { 'indent_size': 3 }, 'css': { 'indent_size': 5 } }; |
||
203 | t( |
||
204 | '.selector {\n' + |
||
205 | ' font-size: 12px;\n' + |
||
206 | '}'); |
||
207 | |||
208 | // Support simple language specific option inheritance/overriding - (c = " ") |
||
209 | reset_options(); |
||
210 | opts.indent_char = ' '; |
||
211 | opts.indent_size = 9; |
||
212 | opts.html = { 'js': { 'indent_size': 3 }, 'css': { 'indent_size': 8 }, 'indent_size': 2}; |
||
213 | opts.js = { 'indent_size': 5 }; |
||
214 | opts.css = { 'indent_size': 3 }; |
||
215 | t( |
||
216 | '.selector {\n' + |
||
217 | ' font-size: 12px;\n' + |
||
218 | '}'); |
||
219 | |||
220 | |||
221 | //============================================================ |
||
222 | // Space Around Combinator - (space = " ") |
||
223 | reset_options(); |
||
224 | opts.space_around_combinator = true; |
||
225 | t('a>b{}', 'a > b {}'); |
||
226 | t('a~b{}', 'a ~ b {}'); |
||
227 | t('a+b{}', 'a + b {}'); |
||
228 | t('a+b>c{}', 'a + b > c {}'); |
||
229 | t('a > b{}', 'a > b {}'); |
||
230 | t('a ~ b{}', 'a ~ b {}'); |
||
231 | t('a + b{}', 'a + b {}'); |
||
232 | t('a + b > c{}', 'a + b > c {}'); |
||
233 | t( |
||
234 | 'a > b{width: calc(100% + 45px);}', |
||
235 | // -- output -- |
||
236 | 'a > b {\n' + |
||
237 | '\twidth: calc(100% + 45px);\n' + |
||
238 | '}'); |
||
239 | t( |
||
240 | 'a ~ b{width: calc(100% + 45px);}', |
||
241 | // -- output -- |
||
242 | 'a ~ b {\n' + |
||
243 | '\twidth: calc(100% + 45px);\n' + |
||
244 | '}'); |
||
245 | t( |
||
246 | 'a + b{width: calc(100% + 45px);}', |
||
247 | // -- output -- |
||
248 | 'a + b {\n' + |
||
249 | '\twidth: calc(100% + 45px);\n' + |
||
250 | '}'); |
||
251 | t( |
||
252 | 'a + b > c{width: calc(100% + 45px);}', |
||
253 | // -- output -- |
||
254 | 'a + b > c {\n' + |
||
255 | '\twidth: calc(100% + 45px);\n' + |
||
256 | '}'); |
||
257 | |||
258 | // Space Around Combinator - (space = "") |
||
259 | reset_options(); |
||
260 | opts.space_around_combinator = false; |
||
261 | t('a>b{}', 'a>b {}'); |
||
262 | t('a~b{}', 'a~b {}'); |
||
263 | t('a+b{}', 'a+b {}'); |
||
264 | t('a+b>c{}', 'a+b>c {}'); |
||
265 | t('a > b{}', 'a>b {}'); |
||
266 | t('a ~ b{}', 'a~b {}'); |
||
267 | t('a + b{}', 'a+b {}'); |
||
268 | t('a + b > c{}', 'a+b>c {}'); |
||
269 | t( |
||
270 | 'a > b{width: calc(100% + 45px);}', |
||
271 | // -- output -- |
||
272 | 'a>b {\n' + |
||
273 | '\twidth: calc(100% + 45px);\n' + |
||
274 | '}'); |
||
275 | t( |
||
276 | 'a ~ b{width: calc(100% + 45px);}', |
||
277 | // -- output -- |
||
278 | 'a~b {\n' + |
||
279 | '\twidth: calc(100% + 45px);\n' + |
||
280 | '}'); |
||
281 | t( |
||
282 | 'a + b{width: calc(100% + 45px);}', |
||
283 | // -- output -- |
||
284 | 'a+b {\n' + |
||
285 | '\twidth: calc(100% + 45px);\n' + |
||
286 | '}'); |
||
287 | t( |
||
288 | 'a + b > c{width: calc(100% + 45px);}', |
||
289 | // -- output -- |
||
290 | 'a+b>c {\n' + |
||
291 | '\twidth: calc(100% + 45px);\n' + |
||
292 | '}'); |
||
293 | |||
294 | // Space Around Combinator - (space = " ") |
||
295 | reset_options(); |
||
296 | opts.space_around_selector_separator = true; |
||
297 | t('a>b{}', 'a > b {}'); |
||
298 | t('a~b{}', 'a ~ b {}'); |
||
299 | t('a+b{}', 'a + b {}'); |
||
300 | t('a+b>c{}', 'a + b > c {}'); |
||
301 | t('a > b{}', 'a > b {}'); |
||
302 | t('a ~ b{}', 'a ~ b {}'); |
||
303 | t('a + b{}', 'a + b {}'); |
||
304 | t('a + b > c{}', 'a + b > c {}'); |
||
305 | t( |
||
306 | 'a > b{width: calc(100% + 45px);}', |
||
307 | // -- output -- |
||
308 | 'a > b {\n' + |
||
309 | '\twidth: calc(100% + 45px);\n' + |
||
310 | '}'); |
||
311 | t( |
||
312 | 'a ~ b{width: calc(100% + 45px);}', |
||
313 | // -- output -- |
||
314 | 'a ~ b {\n' + |
||
315 | '\twidth: calc(100% + 45px);\n' + |
||
316 | '}'); |
||
317 | t( |
||
318 | 'a + b{width: calc(100% + 45px);}', |
||
319 | // -- output -- |
||
320 | 'a + b {\n' + |
||
321 | '\twidth: calc(100% + 45px);\n' + |
||
322 | '}'); |
||
323 | t( |
||
324 | 'a + b > c{width: calc(100% + 45px);}', |
||
325 | // -- output -- |
||
326 | 'a + b > c {\n' + |
||
327 | '\twidth: calc(100% + 45px);\n' + |
||
328 | '}'); |
||
329 | |||
330 | |||
331 | //============================================================ |
||
332 | // Selector Separator - (separator = " ", separator1 = " ") |
||
333 | reset_options(); |
||
334 | opts.selector_separator_newline = false; |
||
335 | opts.selector_separator = " "; |
||
336 | t( |
||
337 | '#bla, #foo{color:green}', |
||
338 | // -- output -- |
||
339 | '#bla, #foo {\n' + |
||
340 | '\tcolor: green\n' + |
||
341 | '}'); |
||
342 | t( |
||
343 | '@media print {.tab{}}', |
||
344 | // -- output -- |
||
345 | '@media print {\n' + |
||
346 | '\t.tab {}\n' + |
||
347 | '}'); |
||
348 | t( |
||
349 | '@media print {.tab,.bat{}}', |
||
350 | // -- output -- |
||
351 | '@media print {\n' + |
||
352 | '\t.tab, .bat {}\n' + |
||
353 | '}'); |
||
354 | t( |
||
355 | '#bla, #foo{color:black}', |
||
356 | // -- output -- |
||
357 | '#bla, #foo {\n' + |
||
358 | '\tcolor: black\n' + |
||
359 | '}'); |
||
360 | t( |
||
361 | 'a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', |
||
362 | // -- output -- |
||
363 | 'a:first-child, a:first-child {\n' + |
||
364 | '\tcolor: red;\n' + |
||
365 | '\tdiv:first-child, div:hover {\n' + |
||
366 | '\t\tcolor: black;\n' + |
||
367 | '\t}\n' + |
||
368 | '}'); |
||
369 | |||
370 | // Selector Separator - (separator = " ", separator1 = " ") |
||
371 | reset_options(); |
||
372 | opts.selector_separator_newline = false; |
||
373 | opts.selector_separator = " "; |
||
374 | t( |
||
375 | '#bla, #foo{color:green}', |
||
376 | // -- output -- |
||
377 | '#bla, #foo {\n' + |
||
378 | '\tcolor: green\n' + |
||
379 | '}'); |
||
380 | t( |
||
381 | '@media print {.tab{}}', |
||
382 | // -- output -- |
||
383 | '@media print {\n' + |
||
384 | '\t.tab {}\n' + |
||
385 | '}'); |
||
386 | t( |
||
387 | '@media print {.tab,.bat{}}', |
||
388 | // -- output -- |
||
389 | '@media print {\n' + |
||
390 | '\t.tab, .bat {}\n' + |
||
391 | '}'); |
||
392 | t( |
||
393 | '#bla, #foo{color:black}', |
||
394 | // -- output -- |
||
395 | '#bla, #foo {\n' + |
||
396 | '\tcolor: black\n' + |
||
397 | '}'); |
||
398 | t( |
||
399 | 'a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', |
||
400 | // -- output -- |
||
401 | 'a:first-child, a:first-child {\n' + |
||
402 | '\tcolor: red;\n' + |
||
403 | '\tdiv:first-child, div:hover {\n' + |
||
404 | '\t\tcolor: black;\n' + |
||
405 | '\t}\n' + |
||
406 | '}'); |
||
407 | |||
408 | // Selector Separator - (separator = "\n", separator1 = "\n\t") |
||
409 | reset_options(); |
||
410 | opts.selector_separator_newline = true; |
||
411 | opts.selector_separator = " "; |
||
412 | t( |
||
413 | '#bla, #foo{color:green}', |
||
414 | // -- output -- |
||
415 | '#bla,\n#foo {\n' + |
||
416 | '\tcolor: green\n' + |
||
417 | '}'); |
||
418 | t( |
||
419 | '@media print {.tab{}}', |
||
420 | // -- output -- |
||
421 | '@media print {\n' + |
||
422 | '\t.tab {}\n' + |
||
423 | '}'); |
||
424 | t( |
||
425 | '@media print {.tab,.bat{}}', |
||
426 | // -- output -- |
||
427 | '@media print {\n' + |
||
428 | '\t.tab,\n\t.bat {}\n' + |
||
429 | '}'); |
||
430 | t( |
||
431 | '#bla, #foo{color:black}', |
||
432 | // -- output -- |
||
433 | '#bla,\n#foo {\n' + |
||
434 | '\tcolor: black\n' + |
||
435 | '}'); |
||
436 | t( |
||
437 | 'a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', |
||
438 | // -- output -- |
||
439 | 'a:first-child,\na:first-child {\n' + |
||
440 | '\tcolor: red;\n' + |
||
441 | '\tdiv:first-child,\n\tdiv:hover {\n' + |
||
442 | '\t\tcolor: black;\n' + |
||
443 | '\t}\n' + |
||
444 | '}'); |
||
445 | |||
446 | // Selector Separator - (separator = "\n", separator1 = "\n\t") |
||
447 | reset_options(); |
||
448 | opts.selector_separator_newline = true; |
||
449 | opts.selector_separator = " "; |
||
450 | t( |
||
451 | '#bla, #foo{color:green}', |
||
452 | // -- output -- |
||
453 | '#bla,\n#foo {\n' + |
||
454 | '\tcolor: green\n' + |
||
455 | '}'); |
||
456 | t( |
||
457 | '@media print {.tab{}}', |
||
458 | // -- output -- |
||
459 | '@media print {\n' + |
||
460 | '\t.tab {}\n' + |
||
461 | '}'); |
||
462 | t( |
||
463 | '@media print {.tab,.bat{}}', |
||
464 | // -- output -- |
||
465 | '@media print {\n' + |
||
466 | '\t.tab,\n\t.bat {}\n' + |
||
467 | '}'); |
||
468 | t( |
||
469 | '#bla, #foo{color:black}', |
||
470 | // -- output -- |
||
471 | '#bla,\n#foo {\n' + |
||
472 | '\tcolor: black\n' + |
||
473 | '}'); |
||
474 | t( |
||
475 | 'a:first-child,a:first-child{color:red;div:first-child,div:hover{color:black;}}', |
||
476 | // -- output -- |
||
477 | 'a:first-child,\na:first-child {\n' + |
||
478 | '\tcolor: red;\n' + |
||
479 | '\tdiv:first-child,\n\tdiv:hover {\n' + |
||
480 | '\t\tcolor: black;\n' + |
||
481 | '\t}\n' + |
||
482 | '}'); |
||
483 | |||
484 | |||
485 | //============================================================ |
||
486 | // Preserve Newlines - (separator_input = "\n\n", separator_output = "\n\n") |
||
487 | reset_options(); |
||
488 | opts.preserve_newlines = true; |
||
489 | t('.div {}\n\n.span {}'); |
||
490 | t( |
||
491 | '#bla, #foo{\n' + |
||
492 | '\tcolor:black;\n\n\tfont-size: 12px;\n' + |
||
493 | '}', |
||
494 | // -- output -- |
||
495 | '#bla,\n' + |
||
496 | '#foo {\n' + |
||
497 | '\tcolor: black;\n\n\tfont-size: 12px;\n' + |
||
498 | '}'); |
||
499 | |||
500 | // Preserve Newlines - (separator_input = "\n\n", separator_output = "\n") |
||
501 | reset_options(); |
||
502 | opts.preserve_newlines = false; |
||
503 | t('.div {}\n\n.span {}', '.div {}\n.span {}'); |
||
504 | t( |
||
505 | '#bla, #foo{\n' + |
||
506 | '\tcolor:black;\n\n\tfont-size: 12px;\n' + |
||
507 | '}', |
||
508 | // -- output -- |
||
509 | '#bla,\n' + |
||
510 | '#foo {\n' + |
||
511 | '\tcolor: black;\n\tfont-size: 12px;\n' + |
||
512 | '}'); |
||
513 | |||
514 | |||
515 | //============================================================ |
||
516 | // Preserve Newlines and newline_between_rules |
||
517 | reset_options(); |
||
518 | opts.preserve_newlines = true; |
||
519 | opts.newline_between_rules = true; |
||
520 | t( |
||
521 | '.div {}.span {}', |
||
522 | // -- output -- |
||
523 | '.div {}\n' + |
||
524 | '\n' + |
||
525 | '.span {}'); |
||
526 | t( |
||
527 | '#bla, #foo{\n' + |
||
528 | '\tcolor:black;\n' + |
||
529 | '\tfont-size: 12px;\n' + |
||
530 | '}', |
||
531 | // -- output -- |
||
532 | '#bla,\n' + |
||
533 | '#foo {\n' + |
||
534 | '\tcolor: black;\n' + |
||
535 | '\tfont-size: 12px;\n' + |
||
536 | '}'); |
||
537 | t( |
||
538 | '#bla, #foo{\n' + |
||
539 | '\tcolor:black;\n' + |
||
540 | '\n' + |
||
541 | '\n' + |
||
542 | '\tfont-size: 12px;\n' + |
||
543 | '}', |
||
544 | // -- output -- |
||
545 | '#bla,\n' + |
||
546 | '#foo {\n' + |
||
547 | '\tcolor: black;\n' + |
||
548 | '\n' + |
||
549 | '\n' + |
||
550 | '\tfont-size: 12px;\n' + |
||
551 | '}'); |
||
552 | t( |
||
553 | '#bla,\n' + |
||
554 | '\n' + |
||
555 | '#foo {\n' + |
||
556 | '\tcolor: black;\n' + |
||
557 | '\tfont-size: 12px;\n' + |
||
558 | '}'); |
||
559 | t( |
||
560 | 'a {\n' + |
||
561 | '\tb: c;\n' + |
||
562 | '\n' + |
||
563 | '\n' + |
||
564 | '\td: {\n' + |
||
565 | '\t\te: f;\n' + |
||
566 | '\t}\n' + |
||
567 | '}'); |
||
568 | t( |
||
569 | '.div {}\n' + |
||
570 | '\n' + |
||
571 | '.span {}'); |
||
572 | t( |
||
573 | '.div {\n' + |
||
574 | '\ta: 1;\n' + |
||
575 | '\n' + |
||
576 | '\n' + |
||
577 | '\tb: 2;\n' + |
||
578 | '}\n' + |
||
579 | '\n' + |
||
580 | '\n' + |
||
581 | '\n' + |
||
582 | '.span {\n' + |
||
583 | '\ta: 1;\n' + |
||
584 | '}'); |
||
585 | t( |
||
586 | '.div {\n' + |
||
587 | '\n' + |
||
588 | '\n' + |
||
589 | '\ta: 1;\n' + |
||
590 | '\n' + |
||
591 | '\n' + |
||
592 | '\tb: 2;\n' + |
||
593 | '}\n' + |
||
594 | '\n' + |
||
595 | '\n' + |
||
596 | '\n' + |
||
597 | '.span {\n' + |
||
598 | '\ta: 1;\n' + |
||
599 | '}'); |
||
600 | t( |
||
601 | '@media screen {\n' + |
||
602 | '\t.div {\n' + |
||
603 | '\t\ta: 1;\n' + |
||
604 | '\n' + |
||
605 | '\n' + |
||
606 | '\t\tb: 2;\n' + |
||
607 | '\t}\n' + |
||
608 | '\n' + |
||
609 | '\n' + |
||
610 | '\n' + |
||
611 | '\t.span {\n' + |
||
612 | '\t\ta: 1;\n' + |
||
613 | '\t}\n' + |
||
614 | '}\n' + |
||
615 | '\n' + |
||
616 | '.div {}\n' + |
||
617 | '\n' + |
||
618 | '.span {}'); |
||
619 | |||
620 | |||
621 | //============================================================ |
||
622 | // Preserve Newlines and add tabs |
||
623 | reset_options(); |
||
624 | opts.preserve_newlines = true; |
||
625 | t( |
||
626 | '.tool-tip {\n' + |
||
627 | '\tposition: relative;\n' + |
||
628 | '\n' + |
||
629 | '\t\t\n' + |
||
630 | '\t.tool-tip-content {\n' + |
||
631 | '\t\t&>* {\n' + |
||
632 | '\t\t\tmargin-top: 0;\n' + |
||
633 | '\t\t}\n' + |
||
634 | '\t\t\n' + |
||
635 | '\n' + |
||
636 | '\t\t.mixin-box-shadow(.2rem .2rem .5rem rgba(0, 0, 0, .15));\n' + |
||
637 | '\t\tpadding: 1rem;\n' + |
||
638 | '\t\tposition: absolute;\n' + |
||
639 | '\t\tz-index: 10;\n' + |
||
640 | '\t}\n' + |
||
641 | '}', |
||
642 | // -- output -- |
||
643 | '.tool-tip {\n' + |
||
644 | '\tposition: relative;\n' + |
||
645 | '\n' + |
||
646 | '\n' + |
||
647 | '\t.tool-tip-content {\n' + |
||
648 | '\t\t&>* {\n' + |
||
649 | '\t\t\tmargin-top: 0;\n' + |
||
650 | '\t\t}\n' + |
||
651 | '\n\n\t\t.mixin-box-shadow(.2rem .2rem .5rem rgba(0, 0, 0, .15));\n' + |
||
652 | '\t\tpadding: 1rem;\n' + |
||
653 | '\t\tposition: absolute;\n' + |
||
654 | '\t\tz-index: 10;\n' + |
||
655 | '\t}\n' + |
||
656 | '}'); |
||
657 | |||
658 | |||
659 | //============================================================ |
||
660 | // Newline Between Rules - (separator = "\n") |
||
661 | reset_options(); |
||
662 | opts.newline_between_rules = true; |
||
663 | t( |
||
664 | '.div {}\n' + |
||
665 | '.span {}', |
||
666 | // -- output -- |
||
667 | '.div {}\n' + |
||
668 | '\n.span {}'); |
||
669 | t( |
||
670 | '.div{}\n' + |
||
671 | ' \n' + |
||
672 | '.span{}', |
||
673 | // -- output -- |
||
674 | '.div {}\n' + |
||
675 | '\n.span {}'); |
||
676 | t( |
||
677 | '.div {} \n' + |
||
678 | ' \n' + |
||
679 | '.span { } \n', |
||
680 | // -- output -- |
||
681 | '.div {}\n' + |
||
682 | '\n.span {}'); |
||
683 | t( |
||
684 | '.div {\n' + |
||
685 | ' \n' + |
||
686 | '} \n' + |
||
687 | ' .span {\n' + |
||
688 | ' } ', |
||
689 | // -- output -- |
||
690 | '.div {}\n' + |
||
691 | '\n.span {}'); |
||
692 | t( |
||
693 | '.selector1 {\n' + |
||
694 | '\tmargin: 0; /* This is a comment including an url http://domain.com/path/to/file.ext */\n' + |
||
695 | '}\n' + |
||
696 | '.div{height:15px;}', |
||
697 | // -- output -- |
||
698 | '.selector1 {\n' + |
||
699 | '\tmargin: 0;\n' + |
||
700 | '\t/* This is a comment including an url http://domain.com/path/to/file.ext */\n' + |
||
701 | '}\n' + |
||
702 | '\n.div {\n' + |
||
703 | '\theight: 15px;\n' + |
||
704 | '}'); |
||
705 | t( |
||
706 | '.tabs{width:10px;//end of line comment\n' + |
||
707 | 'height:10px;//another\n' + |
||
708 | '}\n' + |
||
709 | '.div{height:15px;}', |
||
710 | // -- output -- |
||
711 | '.tabs {\n' + |
||
712 | '\twidth: 10px; //end of line comment\n' + |
||
713 | '\theight: 10px; //another\n' + |
||
714 | '}\n' + |
||
715 | '\n.div {\n' + |
||
716 | '\theight: 15px;\n' + |
||
717 | '}'); |
||
718 | t( |
||
719 | '#foo {\n' + |
||
720 | '\tbackground-image: url(foo@2x.png);\n' + |
||
721 | '\t@font-face {\n' + |
||
722 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
723 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
724 | '\t}\n' + |
||
725 | '}\n' + |
||
726 | '.div{height:15px;}', |
||
727 | // -- output -- |
||
728 | '#foo {\n' + |
||
729 | '\tbackground-image: url(foo@2x.png);\n' + |
||
730 | '\t@font-face {\n' + |
||
731 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
732 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
733 | '\t}\n' + |
||
734 | '}\n' + |
||
735 | '\n.div {\n' + |
||
736 | '\theight: 15px;\n' + |
||
737 | '}'); |
||
738 | t( |
||
739 | '@media screen {\n' + |
||
740 | '\t#foo:hover {\n' + |
||
741 | '\t\tbackground-image: url(foo@2x.png);\n' + |
||
742 | '\t}\n' + |
||
743 | '\t@font-face {\n' + |
||
744 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
745 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
746 | '\t}\n' + |
||
747 | '}\n' + |
||
748 | '.div{height:15px;}', |
||
749 | // -- output -- |
||
750 | '@media screen {\n' + |
||
751 | '\t#foo:hover {\n' + |
||
752 | '\t\tbackground-image: url(foo@2x.png);\n' + |
||
753 | '\t}\n' + |
||
754 | '\t@font-face {\n' + |
||
755 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
756 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
757 | '\t}\n' + |
||
758 | '}\n' + |
||
759 | '\n.div {\n' + |
||
760 | '\theight: 15px;\n' + |
||
761 | '}'); |
||
762 | t( |
||
763 | '@font-face {\n' + |
||
764 | '\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
765 | '\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
766 | '}\n' + |
||
767 | '@media screen {\n' + |
||
768 | '\t#foo:hover {\n' + |
||
769 | '\t\tbackground-image: url(foo.png);\n' + |
||
770 | '\t}\n' + |
||
771 | '\t@media screen and (min-device-pixel-ratio: 2) {\n' + |
||
772 | '\t\t@font-face {\n' + |
||
773 | '\t\t\tfont-family: "Helvetica Neue"\n' + |
||
774 | '\t\t}\n' + |
||
775 | '\t\t#foo:hover {\n' + |
||
776 | '\t\t\tbackground-image: url(foo@2x.png);\n' + |
||
777 | '\t\t}\n' + |
||
778 | '\t}\n' + |
||
779 | '}', |
||
780 | // -- output -- |
||
781 | '@font-face {\n' + |
||
782 | '\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
783 | '\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
784 | '}\n' + |
||
785 | '\n@media screen {\n' + |
||
786 | '\t#foo:hover {\n' + |
||
787 | '\t\tbackground-image: url(foo.png);\n' + |
||
788 | '\t}\n' + |
||
789 | '\t@media screen and (min-device-pixel-ratio: 2) {\n' + |
||
790 | '\t\t@font-face {\n' + |
||
791 | '\t\t\tfont-family: "Helvetica Neue"\n' + |
||
792 | '\t\t}\n' + |
||
793 | '\t\t#foo:hover {\n' + |
||
794 | '\t\t\tbackground-image: url(foo@2x.png);\n' + |
||
795 | '\t\t}\n' + |
||
796 | '\t}\n' + |
||
797 | '}'); |
||
798 | t( |
||
799 | 'a:first-child{color:red;div:first-child{color:black;}}\n' + |
||
800 | '.div{height:15px;}', |
||
801 | // -- output -- |
||
802 | 'a:first-child {\n' + |
||
803 | '\tcolor: red;\n' + |
||
804 | '\tdiv:first-child {\n' + |
||
805 | '\t\tcolor: black;\n' + |
||
806 | '\t}\n' + |
||
807 | '}\n' + |
||
808 | '\n.div {\n' + |
||
809 | '\theight: 15px;\n' + |
||
810 | '}'); |
||
811 | t( |
||
812 | 'a:first-child{color:red;div:not(.peq){color:black;}}\n' + |
||
813 | '.div{height:15px;}', |
||
814 | // -- output -- |
||
815 | 'a:first-child {\n' + |
||
816 | '\tcolor: red;\n' + |
||
817 | '\tdiv:not(.peq) {\n' + |
||
818 | '\t\tcolor: black;\n' + |
||
819 | '\t}\n' + |
||
820 | '}\n' + |
||
821 | '\n.div {\n' + |
||
822 | '\theight: 15px;\n' + |
||
823 | '}'); |
||
824 | |||
825 | // Newline Between Rules - (separator = "") |
||
826 | reset_options(); |
||
827 | opts.newline_between_rules = false; |
||
828 | t( |
||
829 | '.div {}\n' + |
||
830 | '.span {}'); |
||
831 | t( |
||
832 | '.div{}\n' + |
||
833 | ' \n' + |
||
834 | '.span{}', |
||
835 | // -- output -- |
||
836 | '.div {}\n' + |
||
837 | '.span {}'); |
||
838 | t( |
||
839 | '.div {} \n' + |
||
840 | ' \n' + |
||
841 | '.span { } \n', |
||
842 | // -- output -- |
||
843 | '.div {}\n' + |
||
844 | '.span {}'); |
||
845 | t( |
||
846 | '.div {\n' + |
||
847 | ' \n' + |
||
848 | '} \n' + |
||
849 | ' .span {\n' + |
||
850 | ' } ', |
||
851 | // -- output -- |
||
852 | '.div {}\n' + |
||
853 | '.span {}'); |
||
854 | t( |
||
855 | '.selector1 {\n' + |
||
856 | '\tmargin: 0; /* This is a comment including an url http://domain.com/path/to/file.ext */\n' + |
||
857 | '}\n' + |
||
858 | '.div{height:15px;}', |
||
859 | // -- output -- |
||
860 | '.selector1 {\n' + |
||
861 | '\tmargin: 0;\n' + |
||
862 | '\t/* This is a comment including an url http://domain.com/path/to/file.ext */\n' + |
||
863 | '}\n' + |
||
864 | '.div {\n' + |
||
865 | '\theight: 15px;\n' + |
||
866 | '}'); |
||
867 | t( |
||
868 | '.tabs{width:10px;//end of line comment\n' + |
||
869 | 'height:10px;//another\n' + |
||
870 | '}\n' + |
||
871 | '.div{height:15px;}', |
||
872 | // -- output -- |
||
873 | '.tabs {\n' + |
||
874 | '\twidth: 10px; //end of line comment\n' + |
||
875 | '\theight: 10px; //another\n' + |
||
876 | '}\n' + |
||
877 | '.div {\n' + |
||
878 | '\theight: 15px;\n' + |
||
879 | '}'); |
||
880 | t( |
||
881 | '#foo {\n' + |
||
882 | '\tbackground-image: url(foo@2x.png);\n' + |
||
883 | '\t@font-face {\n' + |
||
884 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
885 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
886 | '\t}\n' + |
||
887 | '}\n' + |
||
888 | '.div{height:15px;}', |
||
889 | // -- output -- |
||
890 | '#foo {\n' + |
||
891 | '\tbackground-image: url(foo@2x.png);\n' + |
||
892 | '\t@font-face {\n' + |
||
893 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
894 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
895 | '\t}\n' + |
||
896 | '}\n' + |
||
897 | '.div {\n' + |
||
898 | '\theight: 15px;\n' + |
||
899 | '}'); |
||
900 | t( |
||
901 | '@media screen {\n' + |
||
902 | '\t#foo:hover {\n' + |
||
903 | '\t\tbackground-image: url(foo@2x.png);\n' + |
||
904 | '\t}\n' + |
||
905 | '\t@font-face {\n' + |
||
906 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
907 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
908 | '\t}\n' + |
||
909 | '}\n' + |
||
910 | '.div{height:15px;}', |
||
911 | // -- output -- |
||
912 | '@media screen {\n' + |
||
913 | '\t#foo:hover {\n' + |
||
914 | '\t\tbackground-image: url(foo@2x.png);\n' + |
||
915 | '\t}\n' + |
||
916 | '\t@font-face {\n' + |
||
917 | '\t\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
918 | '\t\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
919 | '\t}\n' + |
||
920 | '}\n' + |
||
921 | '.div {\n' + |
||
922 | '\theight: 15px;\n' + |
||
923 | '}'); |
||
924 | t( |
||
925 | '@font-face {\n' + |
||
926 | '\tfont-family: "Bitstream Vera Serif Bold";\n' + |
||
927 | '\tsrc: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");\n' + |
||
928 | '}\n' + |
||
929 | '@media screen {\n' + |
||
930 | '\t#foo:hover {\n' + |
||
931 | '\t\tbackground-image: url(foo.png);\n' + |
||
932 | '\t}\n' + |
||
933 | '\t@media screen and (min-device-pixel-ratio: 2) {\n' + |
||
934 | '\t\t@font-face {\n' + |
||
935 | '\t\t\tfont-family: "Helvetica Neue"\n' + |
||
936 | '\t\t}\n' + |
||
937 | '\t\t#foo:hover {\n' + |
||
938 | '\t\t\tbackground-image: url(foo@2x.png);\n' + |
||
939 | '\t\t}\n' + |
||
940 | '\t}\n' + |
||
941 | '}'); |
||
942 | t( |
||
943 | 'a:first-child{color:red;div:first-child{color:black;}}\n' + |
||
944 | '.div{height:15px;}', |
||
945 | // -- output -- |
||
946 | 'a:first-child {\n' + |
||
947 | '\tcolor: red;\n' + |
||
948 | '\tdiv:first-child {\n' + |
||
949 | '\t\tcolor: black;\n' + |
||
950 | '\t}\n' + |
||
951 | '}\n' + |
||
952 | '.div {\n' + |
||
953 | '\theight: 15px;\n' + |
||
954 | '}'); |
||
955 | t( |
||
956 | 'a:first-child{color:red;div:not(.peq){color:black;}}\n' + |
||
957 | '.div{height:15px;}', |
||
958 | // -- output -- |
||
959 | 'a:first-child {\n' + |
||
960 | '\tcolor: red;\n' + |
||
961 | '\tdiv:not(.peq) {\n' + |
||
962 | '\t\tcolor: black;\n' + |
||
963 | '\t}\n' + |
||
964 | '}\n' + |
||
965 | '.div {\n' + |
||
966 | '\theight: 15px;\n' + |
||
967 | '}'); |
||
968 | |||
969 | |||
970 | //============================================================ |
||
971 | // Functions braces |
||
972 | reset_options(); |
||
973 | t('.tabs(){}', '.tabs() {}'); |
||
974 | t('.tabs (){}', '.tabs () {}'); |
||
975 | t( |
||
976 | '.tabs (pa, pa(1,2)), .cols { }', |
||
977 | // -- output -- |
||
978 | '.tabs (pa, pa(1, 2)),\n' + |
||
979 | '.cols {}'); |
||
980 | t( |
||
981 | '.tabs(pa, pa(1,2)), .cols { }', |
||
982 | // -- output -- |
||
983 | '.tabs(pa, pa(1, 2)),\n' + |
||
984 | '.cols {}'); |
||
985 | t('.tabs ( ) { }', '.tabs () {}'); |
||
986 | t('.tabs( ) { }', '.tabs() {}'); |
||
987 | t( |
||
988 | '.tabs (t, t2) \n' + |
||
989 | '{\n' + |
||
990 | ' key: val(p1 ,p2); \n' + |
||
991 | ' }', |
||
992 | // -- output -- |
||
993 | '.tabs (t, t2) {\n' + |
||
994 | '\tkey: val(p1, p2);\n' + |
||
995 | '}'); |
||
996 | t( |
||
997 | '.box-shadow(@shadow: 0 1px 3px rgba(0, 0, 0, .25)) {\n' + |
||
998 | '\t-webkit-box-shadow: @shadow;\n' + |
||
999 | '\t-moz-box-shadow: @shadow;\n' + |
||
1000 | '\tbox-shadow: @shadow;\n' + |
||
1001 | '}'); |
||
1002 | |||
1003 | |||
1004 | //============================================================ |
||
1005 | // Comments |
||
1006 | reset_options(); |
||
1007 | t('/* test */'); |
||
1008 | t( |
||
1009 | '.tabs{/* test */}', |
||
1010 | // -- output -- |
||
1011 | '.tabs {\n' + |
||
1012 | '\t/* test */\n' + |
||
1013 | '}'); |
||
1014 | t( |
||
1015 | '.tabs{/* test */}', |
||
1016 | // -- output -- |
||
1017 | '.tabs {\n' + |
||
1018 | '\t/* test */\n' + |
||
1019 | '}'); |
||
1020 | t( |
||
1021 | '/* header */.tabs {}', |
||
1022 | // -- output -- |
||
1023 | '/* header */\n' + |
||
1024 | '\n' + |
||
1025 | '.tabs {}'); |
||
1026 | t( |
||
1027 | '.tabs {\n' + |
||
1028 | '/* non-header */\n' + |
||
1029 | 'width:10px;}', |
||
1030 | // -- output -- |
||
1031 | '.tabs {\n' + |
||
1032 | '\t/* non-header */\n' + |
||
1033 | '\twidth: 10px;\n' + |
||
1034 | '}'); |
||
1035 | t('/* header'); |
||
1036 | t('// comment'); |
||
1037 | t( |
||
1038 | '.selector1 {\n' + |
||
1039 | '\tmargin: 0; /* This is a comment including an url http://domain.com/path/to/file.ext */\n' + |
||
1040 | '}', |
||
1041 | // -- output -- |
||
1042 | '.selector1 {\n' + |
||
1043 | '\tmargin: 0;\n' + |
||
1044 | '\t/* This is a comment including an url http://domain.com/path/to/file.ext */\n' + |
||
1045 | '}'); |
||
1046 | |||
1047 | // single line comment support (less/sass) |
||
1048 | t( |
||
1049 | '.tabs{\n' + |
||
1050 | '// comment\n' + |
||
1051 | 'width:10px;\n' + |
||
1052 | '}', |
||
1053 | // -- output -- |
||
1054 | '.tabs {\n' + |
||
1055 | '\t// comment\n' + |
||
1056 | '\twidth: 10px;\n' + |
||
1057 | '}'); |
||
1058 | t( |
||
1059 | '.tabs{// comment\n' + |
||
1060 | 'width:10px;\n' + |
||
1061 | '}', |
||
1062 | // -- output -- |
||
1063 | '.tabs {\n' + |
||
1064 | '\t// comment\n' + |
||
1065 | '\twidth: 10px;\n' + |
||
1066 | '}'); |
||
1067 | t( |
||
1068 | '//comment\n' + |
||
1069 | '.tabs{width:10px;}', |
||
1070 | // -- output -- |
||
1071 | '//comment\n' + |
||
1072 | '.tabs {\n' + |
||
1073 | '\twidth: 10px;\n' + |
||
1074 | '}'); |
||
1075 | t( |
||
1076 | '.tabs{//comment\n' + |
||
1077 | '//2nd single line comment\n' + |
||
1078 | 'width:10px;}', |
||
1079 | // -- output -- |
||
1080 | '.tabs {\n' + |
||
1081 | '\t//comment\n' + |
||
1082 | '\t//2nd single line comment\n' + |
||
1083 | '\twidth: 10px;\n' + |
||
1084 | '}'); |
||
1085 | t( |
||
1086 | '.tabs{width:10px;//end of line comment\n' + |
||
1087 | '}', |
||
1088 | // -- output -- |
||
1089 | '.tabs {\n' + |
||
1090 | '\twidth: 10px; //end of line comment\n' + |
||
1091 | '}'); |
||
1092 | t( |
||
1093 | '.tabs{width:10px;//end of line comment\n' + |
||
1094 | 'height:10px;}', |
||
1095 | // -- output -- |
||
1096 | '.tabs {\n' + |
||
1097 | '\twidth: 10px; //end of line comment\n' + |
||
1098 | '\theight: 10px;\n' + |
||
1099 | '}'); |
||
1100 | t( |
||
1101 | '.tabs{width:10px;//end of line comment\n' + |
||
1102 | 'height:10px;//another\n' + |
||
1103 | '}', |
||
1104 | // -- output -- |
||
1105 | '.tabs {\n' + |
||
1106 | '\twidth: 10px; //end of line comment\n' + |
||
1107 | '\theight: 10px; //another\n' + |
||
1108 | '}'); |
||
1109 | |||
1110 | |||
1111 | //============================================================ |
||
1112 | // Handle LESS property name interpolation |
||
1113 | reset_options(); |
||
1114 | t( |
||
1115 | 'tag {\n' + |
||
1116 | '\t@{prop}: none;\n' + |
||
1117 | '}'); |
||
1118 | t( |
||
1119 | 'tag{@{prop}:none;}', |
||
1120 | // -- output -- |
||
1121 | 'tag {\n' + |
||
1122 | '\t@{prop}: none;\n' + |
||
1123 | '}'); |
||
1124 | t( |
||
1125 | 'tag{ @{prop}: none;}', |
||
1126 | // -- output -- |
||
1127 | 'tag {\n' + |
||
1128 | '\t@{prop}: none;\n' + |
||
1129 | '}'); |
||
1130 | |||
1131 | // can also be part of property name |
||
1132 | t( |
||
1133 | 'tag {\n' + |
||
1134 | '\tdynamic-@{prop}: none;\n' + |
||
1135 | '}'); |
||
1136 | t( |
||
1137 | 'tag{dynamic-@{prop}:none;}', |
||
1138 | // -- output -- |
||
1139 | 'tag {\n' + |
||
1140 | '\tdynamic-@{prop}: none;\n' + |
||
1141 | '}'); |
||
1142 | t( |
||
1143 | 'tag{ dynamic-@{prop}: none;}', |
||
1144 | // -- output -- |
||
1145 | 'tag {\n' + |
||
1146 | '\tdynamic-@{prop}: none;\n' + |
||
1147 | '}'); |
||
1148 | |||
1149 | |||
1150 | //============================================================ |
||
1151 | // Handle LESS property name interpolation, test #631 |
||
1152 | reset_options(); |
||
1153 | t( |
||
1154 | '.generate-columns(@n, @i: 1) when (@i =< @n) {\n' + |
||
1155 | '\t.column-@{i} {\n' + |
||
1156 | '\t\twidth: (@i * 100% / @n);\n' + |
||
1157 | '\t}\n' + |
||
1158 | '\t.generate-columns(@n, (@i + 1));\n' + |
||
1159 | '}'); |
||
1160 | t( |
||
1161 | '.generate-columns(@n,@i:1) when (@i =< @n){.column-@{i}{width:(@i * 100% / @n);}.generate-columns(@n,(@i + 1));}', |
||
1162 | // -- output -- |
||
1163 | '.generate-columns(@n, @i: 1) when (@i =< @n) {\n' + |
||
1164 | '\t.column-@{i} {\n' + |
||
1165 | '\t\twidth: (@i * 100% / @n);\n' + |
||
1166 | '\t}\n' + |
||
1167 | '\t.generate-columns(@n, (@i + 1));\n' + |
||
1168 | '}'); |
||
1169 | |||
1170 | |||
1171 | //============================================================ |
||
1172 | // Psuedo-classes vs Variables |
||
1173 | reset_options(); |
||
1174 | t('@page :first {}'); |
||
1175 | |||
1176 | // Assume the colon goes with the @name. If we're in LESS, this is required regardless of the at-string. |
||
1177 | t('@page:first {}', '@page: first {}'); |
||
1178 | t('@page: first {}'); |
||
1179 | |||
1180 | |||
1181 | //============================================================ |
||
1182 | // SASS/SCSS |
||
1183 | reset_options(); |
||
1184 | |||
1185 | // Basic Interpolation |
||
1186 | t( |
||
1187 | 'p {\n' + |
||
1188 | '\t$font-size: 12px;\n' + |
||
1189 | '\t$line-height: 30px;\n' + |
||
1190 | '\tfont: #{$font-size}/#{$line-height};\n' + |
||
1191 | '}'); |
||
1192 | t('p.#{$name} {}'); |
||
1193 | t( |
||
1194 | '@mixin itemPropertiesCoverItem($items, $margin) {\n' + |
||
1195 | '\twidth: calc((100% - ((#{$items} - 1) * #{$margin}rem)) / #{$items});\n' + |
||
1196 | '\tmargin: 1.6rem #{$margin}rem 1.6rem 0;\n' + |
||
1197 | '}'); |
||
1198 | |||
1199 | // Multiple filed issues in LESS due to not(:blah) |
||
1200 | t('&:first-of-type:not(:last-child) {}'); |
||
1201 | t( |
||
1202 | 'div {\n' + |
||
1203 | '\t&:not(:first-of-type) {\n' + |
||
1204 | '\t\tbackground: red;\n' + |
||
1205 | '\t}\n' + |
||
1206 | '}'); |
||
1207 | |||
1208 | |||
1209 | //============================================================ |
||
1210 | // Proper handling of colon in selectors |
||
1211 | reset_options(); |
||
1212 | opts.selector_separator_newline = false; |
||
1213 | t('a :b {}'); |
||
1214 | t('a ::b {}'); |
||
1215 | t('a:b {}'); |
||
1216 | t('a::b {}'); |
||
1217 | t( |
||
1218 | 'a {}, a::b {}, a ::b {}, a:b {}, a :b {}', |
||
1219 | // -- output -- |
||
1220 | 'a {}\n' + |
||
1221 | ', a::b {}\n' + |
||
1222 | ', a ::b {}\n' + |
||
1223 | ', a:b {}\n' + |
||
1224 | ', a :b {}'); |
||
1225 | t( |
||
1226 | '.card-blue ::-webkit-input-placeholder {\n' + |
||
1227 | '\tcolor: #87D1FF;\n' + |
||
1228 | '}'); |
||
1229 | t( |
||
1230 | 'div [attr] :not(.class) {\n' + |
||
1231 | '\tcolor: red;\n' + |
||
1232 | '}'); |
||
1233 | |||
1234 | |||
1235 | //============================================================ |
||
1236 | // Regresssion Tests |
||
1237 | reset_options(); |
||
1238 | opts.selector_separator_newline = false; |
||
1239 | t( |
||
1240 | '@media(min-width:768px) {\n' + |
||
1241 | '\t.selector::after {\n' + |
||
1242 | '\t\t/* property: value */\n' + |
||
1243 | '\t}\n' + |
||
1244 | '\t.other-selector {\n' + |
||
1245 | '\t\t/* property: value */\n' + |
||
1246 | '\t}\n' + |
||
1247 | '}'); |
||
1248 | t( |
||
1249 | '.fa-rotate-270 {\n' + |
||
1250 | '\tfilter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);\n' + |
||
1251 | '}'); |
||
1252 | |||
1253 | |||
1254 | //============================================================ |
||
1255 | // |
||
1256 | reset_options(); |
||
1257 | |||
1258 | |||
1259 | } |
||
1260 | |||
1261 | function beautifier_unconverted_tests() |
||
1262 | { |
||
1263 | sanitytest = test_obj; |
||
1264 | |||
1265 | reset_options(); |
||
1266 | //============================================================ |
||
1267 | // test basic css beautifier |
||
1268 | t(".tabs {}"); |
||
1269 | t(".tabs{color:red;}", ".tabs {\n\tcolor: red;\n}"); |
||
1270 | t(".tabs{color:rgb(255, 255, 0)}", ".tabs {\n\tcolor: rgb(255, 255, 0)\n}"); |
||
1271 | t(".tabs{background:url('back.jpg')}", ".tabs {\n\tbackground: url('back.jpg')\n}"); |
||
1272 | t("#bla, #foo{color:red}", "#bla,\n#foo {\n\tcolor: red\n}"); |
||
1273 | t("@media print {.tab{}}", "@media print {\n\t.tab {}\n}"); |
||
1274 | t("@media print {.tab{background-image:url(foo@2x.png)}}", "@media print {\n\t.tab {\n\t\tbackground-image: url(foo@2x.png)\n\t}\n}"); |
||
1275 | |||
1276 | t("a:before {\n" + |
||
1277 | "\tcontent: 'a{color:black;}\"\"\\'\\'\"\\n\\n\\na{color:black}\';\n" + |
||
1278 | "}"); |
||
1279 | |||
1280 | //lead-in whitespace determines base-indent. |
||
1281 | // lead-in newlines are stripped. |
||
1282 | t("\n\na, img {padding: 0.2px}", "a,\nimg {\n\tpadding: 0.2px\n}"); |
||
1283 | t(" a, img {padding: 0.2px}", " a,\n img {\n \tpadding: 0.2px\n }"); |
||
1284 | t(" \t \na, img {padding: 0.2px}", " \t a,\n \t img {\n \t \tpadding: 0.2px\n \t }"); |
||
1285 | t("\n\n a, img {padding: 0.2px}", "a,\nimg {\n\tpadding: 0.2px\n}"); |
||
1286 | |||
1287 | // separate selectors |
||
1288 | t("#bla, #foo{color:red}", "#bla,\n#foo {\n\tcolor: red\n}"); |
||
1289 | t("a, img {padding: 0.2px}", "a,\nimg {\n\tpadding: 0.2px\n}"); |
||
1290 | |||
1291 | // block nesting |
||
1292 | t("#foo {\n\tbackground-image: url(foo@2x.png);\n\t@font-face {\n\t\tfont-family: 'Bitstream Vera Serif Bold';\n\t\tsrc: url('http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf');\n\t}\n}"); |
||
1293 | t("@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo@2x.png);\n\t}\n\t@font-face {\n\t\tfont-family: 'Bitstream Vera Serif Bold';\n\t\tsrc: url('http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf');\n\t}\n}"); |
||
1294 | /* |
||
1295 | @font-face { |
||
1296 | font-family: 'Bitstream Vera Serif Bold'; |
||
1297 | src: url('http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf'); |
||
1298 | } |
||
1299 | @media screen { |
||
1300 | #foo:hover { |
||
1301 | background-image: url(foo.png); |
||
1302 | } |
||
1303 | @media screen and (min-device-pixel-ratio: 2) { |
||
1304 | @font-face { |
||
1305 | font-family: 'Helvetica Neue' |
||
1306 | } |
||
1307 | #foo:hover { |
||
1308 | background-image: url(foo@2x.png); |
||
1309 | } |
||
1310 | } |
||
1311 | } |
||
1312 | */ |
||
1313 | t("@font-face {\n\tfont-family: 'Bitstream Vera Serif Bold';\n\tsrc: url('http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf');\n}\n@media screen {\n\t#foo:hover {\n\t\tbackground-image: url(foo.png);\n\t}\n\t@media screen and (min-device-pixel-ratio: 2) {\n\t\t@font-face {\n\t\t\tfont-family: 'Helvetica Neue'\n\t\t}\n\t\t#foo:hover {\n\t\t\tbackground-image: url(foo@2x.png);\n\t\t}\n\t}\n}"); |
||
1314 | |||
1315 | // less-css cases |
||
1316 | t('.well{@well-bg:@bg-color;@well-fg:@fg-color;}','.well {\n\t@well-bg: @bg-color;\n\t@well-fg: @fg-color;\n}'); |
||
1317 | t('.well {&.active {\nbox-shadow: 0 1px 1px @border-color, 1px 0 1px @border-color;}}', |
||
1318 | '.well {\n' + |
||
1319 | '\t&.active {\n' + |
||
1320 | '\t\tbox-shadow: 0 1px 1px @border-color, 1px 0 1px @border-color;\n' + |
||
1321 | '\t}\n' + |
||
1322 | '}'); |
||
1323 | t('a {\n' + |
||
1324 | '\tcolor: blue;\n' + |
||
1325 | '\t&:hover {\n' + |
||
1326 | '\t\tcolor: green;\n' + |
||
1327 | '\t}\n' + |
||
1328 | '\t& & &&&.active {\n' + |
||
1329 | '\t\tcolor: green;\n' + |
||
1330 | '\t}\n' + |
||
1331 | '}'); |
||
1332 | |||
1333 | // Not sure if this is sensible |
||
1334 | // but I believe it is correct to not remove the space in "&: hover". |
||
1335 | t('a {\n' + |
||
1336 | '\t&: hover {\n' + |
||
1337 | '\t\tcolor: green;\n' + |
||
1338 | '\t}\n' + |
||
1339 | '}'); |
||
1340 | |||
1341 | // import |
||
1342 | t('@import "test";'); |
||
1343 | |||
1344 | // don't break nested pseudo-classes |
||
1345 | t("a:first-child{color:red;div:first-child{color:black;}}", |
||
1346 | "a:first-child {\n\tcolor: red;\n\tdiv:first-child {\n\t\tcolor: black;\n\t}\n}"); |
||
1347 | |||
1348 | // handle SASS/LESS parent reference |
||
1349 | t("div{&:first-letter {text-transform: uppercase;}}", |
||
1350 | "div {\n\t&:first-letter {\n\t\ttext-transform: uppercase;\n\t}\n}"); |
||
1351 | |||
1352 | //nested modifiers (&:hover etc) |
||
1353 | t(".tabs{&:hover{width:10px;}}", ".tabs {\n\t&:hover {\n\t\twidth: 10px;\n\t}\n}"); |
||
1354 | t(".tabs{&.big{width:10px;}}", ".tabs {\n\t&.big {\n\t\twidth: 10px;\n\t}\n}"); |
||
1355 | t(".tabs{&>big{width:10px;}}", ".tabs {\n\t&>big {\n\t\twidth: 10px;\n\t}\n}"); |
||
1356 | t(".tabs{&+.big{width:10px;}}", ".tabs {\n\t&+.big {\n\t\twidth: 10px;\n\t}\n}"); |
||
1357 | |||
1358 | //nested rules |
||
1359 | t(".tabs{.child{width:10px;}}", ".tabs {\n\t.child {\n\t\twidth: 10px;\n\t}\n}"); |
||
1360 | |||
1361 | //variables |
||
1362 | t("@myvar:10px;.tabs{width:10px;}", "@myvar: 10px;\n.tabs {\n\twidth: 10px;\n}"); |
||
1363 | t("@myvar:10px; .tabs{width:10px;}", "@myvar: 10px;\n.tabs {\n\twidth: 10px;\n}"); |
||
1364 | |||
1365 | // test options |
||
1366 | opts.indent_size = 2; |
||
1367 | opts.indent_char = ' '; |
||
1368 | opts.selector_separator_newline = false; |
||
1369 | |||
1370 | // pseudo-classes and pseudo-elements |
||
1371 | t("#foo:hover {\n background-image: url(foo@2x.png)\n}"); |
||
1372 | t("#foo *:hover {\n color: purple\n}"); |
||
1373 | t("::selection {\n color: #ff0000;\n}"); |
||
1374 | |||
1375 | // TODO: don't break nested pseduo-classes |
||
1376 | t("@media screen {.tab,.bat:hover {color:red}}", "@media screen {\n .tab, .bat:hover {\n color: red\n }\n}"); |
||
1377 | |||
1378 | // particular edge case with braces and semicolons inside tags that allows custom text |
||
1379 | t("a:not(\"foobar\\\";{}omg\"){\ncontent: 'example\\';{} text';\ncontent: \"example\\\";{} text\";}", |
||
1380 | "a:not(\"foobar\\\";{}omg\") {\n content: 'example\\';{} text';\n content: \"example\\\";{} text\";\n}"); |
||
1381 | |||
1382 | // may not eat the space before "[" |
||
1383 | t('html.js [data-custom="123"] {\n opacity: 1.00;\n}'); |
||
1384 | t('html.js *[data-custom="123"] {\n opacity: 1.00;\n}'); |
||
1385 | } |
||
1386 | |||
1387 | beautifier_tests(); |
||
1388 | beautifier_unconverted_tests(); |
||
1389 | } |
||
1390 | |||
1391 | if (typeof exports !== "undefined") { |
||
1392 | exports.run_css_tests = run_css_tests; |
||
1393 | } |