Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-whitespace

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-whitespace - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

.travis.yml

8

History.md
1.1.0 / 2013-06-02
==================
* add component support
* add support for regular css multi-line comments. Closes #12
* add stripping of blank lines. Closes #14
* remove blank() from lexer
1.0.0 / 2013-02-27

@@ -3,0 +11,0 @@ ==================

6

index.js

@@ -6,4 +6,4 @@

var parse = require('./lib/parser')
, compile = require('./lib/compiler');
var parse = require('./lib/parser');
var compile = require('./lib/compiler');

@@ -22,2 +22,2 @@ /**

return compile(parse(str));
};
};

@@ -6,4 +6,3 @@

var debug = require('debug')('css-whitespace:parser')
, util = require('util');
var debug = require('debug')('css-whitespace:parser');

@@ -26,2 +25,3 @@ /**

if (debug.enabled) {
var util = require('util');
console.log(util.inspect(node, false, 12, true));

@@ -52,2 +52,4 @@ }

return prop(node);
case 'comment':
return comment(node);
default:

@@ -74,2 +76,10 @@ throw new Error('invalid node "' + node[0] + '"');

/**
* Visit comment.
*/
function comment(node) {
return indent() + '/*' + node[1] + '*/\n';
}
/**
* Visit prop.

@@ -76,0 +86,0 @@ */

@@ -56,5 +56,9 @@

module.exports = function(str) {
var indents = [0]
, stash = [];
var indents = [0];
var stash = [];
// strip blanks
str = str.replace(/\r/g, '');
str = str.replace(/\n\s*\n/gm, '\n');
return scan();

@@ -92,4 +96,4 @@

return stashed()
|| blank()
|| comment()
|| csscomment()
|| indentation()

@@ -109,9 +113,9 @@ || prop()

/**
* Blank line.
* Comment.
*/
function blank() {
var m = str.match(/^\n *\n/);
function comment() {
var m = str.match(/^\/\/([^\n]*)/);
if (!m) return;
str = str.slice(m[0].length - 1);
str = str.slice(m[0].length);
return next();

@@ -121,13 +125,18 @@ }

/**
* Comment.
* Multiline comment.
*/
function comment() {
var m = str.match(/^\/\/([^\n]*)/);
if (!m) return;
str = str.slice(m[0].length);
return next();
function csscomment() {
if ('/' != str[0] || '*' != str[1]) return;
str = str.slice(2);
var i = 0;
while ('*' != str[i] && '/' != str[i + 1]) ++i;
var buf = str.slice(0, i);
str = str.slice(buf.length + 2);
return ['comment', buf];
}
/**

@@ -134,0 +143,0 @@ * INDENT

@@ -5,5 +5,4 @@ /**

var scan = require('./lexer')
, util = require('util')
, debug = require('debug')('css-whitespace:lexer');
var debug = require('debug')('css-whitespace:lexer');
var scan = require('./lexer');

@@ -22,2 +21,3 @@ /**

if (debug.enabled) {
var util = require('util');
console.log(util.inspect(toks, false, 12, true));

@@ -83,2 +83,3 @@ }

if (is('prop')) return prop();
return next();
}

@@ -113,2 +114,2 @@

}
}
}
{
"name": "css-whitespace",
"version": "1.0.0",
"version": "1.1.0",
"description": "Whitespace significant CSS to regular CSS",

@@ -14,3 +14,6 @@ "keywords": ["css", "parser", "rework"],

},
"main": "index"
"main": "index",
"scripts": {
"test": "mocha --require should --reporter spec"
}
}

@@ -1,2 +0,1 @@

# css-whitespace

@@ -11,2 +10,3 @@

$ npm install css-whitespace
$ component install visionmedia/css-whitespace
```

@@ -32,3 +32,3 @@

background: black
colour: white
color: white

@@ -43,3 +43,3 @@ form

padding: 0
button

@@ -60,3 +60,3 @@ border-radius: 0

background: black;
colour: white;
color: white;
}

@@ -80,4 +80,4 @@

## License
## License
MIT

@@ -9,5 +9,8 @@

, read = fs.readFileSync
, parse = require('../lib/parser')
var str = read('testing/index.css', 'utf8');
var css = compile(str);
console.log(css);
console.log(css);
console.log(require('util').inspect(parse(str), false, 15, true));

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc