else
data = data.replace.apply(data, arguments);
};
+ var lineBreak = process.platform == 'win32' ? '\r\n' : '\n';
options = options || {};
replace(/;[ ]?;+/g, ';');
// multiple line breaks to one
- replace(/ (\r\n|\n)/g, '$1');
- replace(/(\r\n|\n)+/g, '$1');
+ replace(/ (?:\r\n|\n)/g, lineBreak);
+ replace(/(?:\r\n|\n)+/g, lineBreak);
// remove spaces around selectors
replace(/ ([+~>]) /g, '$1');
// zero + unit to zero
replace(/(\s|:|,)0(px|em|ex|cm|mm|in|pt|pc|%)/g, '$1' + '0');
- replace(/rect\(0(px|em|ex|cm|mm|in|pt|pc|%)/g, 'rect(0');
+ replace(/rect\(0(?:px|em|ex|cm|mm|in|pt|pc|%)/g, 'rect(0');
// none to 0
replace(/(border|border-top|border-right|border-bottom|border-left|outline):none/g, '$1:0');
assert = require('assert'),
cleanCSS = require('../index');
+var lineBreak = process.platform == 'win32' ? '\r\n' : '\n';
var cssContext = function(groups, options) {
var context = {};
var clean = function(cleanedCSS) {
]
}),
'line breaks': cssContext({
- 'line breaks': 'div\na\r\n{width:500px}',
- 'line breaks #2': 'div\na\r\n,p{width:500px}',
+ 'line breaks': [
+ 'div\na\r\n{width:500px}',
+ 'div' + lineBreak + 'a' + lineBreak + '{width:500px}'
+ ],
+ 'line breaks #2': [
+ 'div\na\r\n,p{width:500px}',
+ 'div' + lineBreak + 'a' + lineBreak + ',p{width:500px}'
+ ],
'multiple line breaks #2': [
'div \r\n\r\na\r\n,p{width:500px}',
- 'div\r\na\r\n,p{width:500px}'
+ 'div' + lineBreak + 'a' + lineBreak + ',p{width:500px}'
],
'line breaks with whitespace lines': [
'div \n \t\n \na\r\n, p { width:500px }',
- 'div\na\r\n,p{width:500px}'
+ 'div' + lineBreak + 'a' + lineBreak + ',p{width:500px}'
]
}, { keepBreaks: true }),
'selectors': cssContext({