main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 5 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1006 bytes
|
Rev | Line | |
---|
[79a0317] | 1 | var SUPPORTED_COMPACT_BLOCK_MATCHER = /^@media\W/;
|
---|
| 2 | var SUPPORTED_QUOTE_REMOVAL_MATCHER = /^@(?:keyframes|-moz-keyframes|-o-keyframes|-webkit-keyframes)\W/;
|
---|
| 3 |
|
---|
| 4 | function tidyBlock(values, spaceAfterClosingBrace) {
|
---|
| 5 | var withoutSpaceAfterClosingBrace;
|
---|
| 6 | var withoutQuotes;
|
---|
| 7 | var i;
|
---|
| 8 |
|
---|
| 9 | for (i = values.length - 1; i >= 0; i--) {
|
---|
| 10 | withoutSpaceAfterClosingBrace = !spaceAfterClosingBrace && SUPPORTED_COMPACT_BLOCK_MATCHER.test(values[i][1]);
|
---|
| 11 | withoutQuotes = SUPPORTED_QUOTE_REMOVAL_MATCHER.test(values[i][1]);
|
---|
| 12 |
|
---|
| 13 | values[i][1] = values[i][1]
|
---|
| 14 | .replace(/\n|\r\n/g, ' ')
|
---|
| 15 | .replace(/\s+/g, ' ')
|
---|
| 16 | .replace(/(,|:|\() /g, '$1')
|
---|
| 17 | .replace(/ \)/g, ')');
|
---|
| 18 |
|
---|
| 19 | if (withoutQuotes) {
|
---|
| 20 | values[i][1] = values[i][1]
|
---|
| 21 | .replace(/'([a-zA-Z][a-zA-Z\d\-_]+)'/, '$1')
|
---|
| 22 | .replace(/"([a-zA-Z][a-zA-Z\d\-_]+)"/, '$1');
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | if (withoutSpaceAfterClosingBrace) {
|
---|
| 26 | values[i][1] = values[i][1]
|
---|
| 27 | .replace(/\) /g, ')');
|
---|
| 28 | }
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | return values;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | module.exports = tidyBlock;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.