colorguard
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -1,2 +0,2 @@ | ||
var visit = require('rework-visit'); | ||
var walk = require('rework-walk'); | ||
var rework = require('rework'); | ||
@@ -31,3 +31,3 @@ var cssColorNames = require('css-color-names'); | ||
function hue2rgb(p, q, t){ | ||
function hue2rgb(p, q, t) { | ||
if(t < 0) t += 1; | ||
@@ -41,3 +41,3 @@ if(t > 1) t -= 1; | ||
function hslToRgb(h, s, l){ | ||
function hslToRgb(h, s, l) { | ||
var r; | ||
@@ -105,4 +105,6 @@ var g; | ||
visit(style, function(declarations){ | ||
declarationParser(declarations, functions, functionMatcher, args); | ||
walk(style, function(rule) { | ||
if (rule.declarations) { | ||
declarationParser(rule.declarations, functions, functionMatcher, args); | ||
} | ||
}); | ||
@@ -135,3 +137,3 @@ } | ||
declarations.forEach(function(decl){ | ||
declarations.forEach(function(decl) { | ||
// We don't care about comments | ||
@@ -156,3 +158,3 @@ if ('comment' == decl.type) return; | ||
// replace the function with... | ||
decl.value = decl.value.replace(functionMatcher, function(_, name, args){ | ||
decl.value = decl.value.replace(functionMatcher, function(_, name, args) { | ||
@@ -228,5 +230,13 @@ // Split out the values between the commas | ||
Object.keys(cssColorNames).forEach(function(colorName) { | ||
css = css.replace(new RegExp("[^A-Za-z]" + colorName, 'ig'), cssColorNames[colorName]); | ||
css = css.replace(new RegExp("[^A-Za-z]" + colorName + "[^A-Za-z]", 'ig'), cssColorNames[colorName]); | ||
}); | ||
// In this section, we more or less ruin the actual css, but not for our purposes. The following | ||
// changes are necessary for the parser to not barf at us. We'll need to undo this if we ever | ||
// wanted to use the rework output. For now, it's fine as long as we keep the line numbers the | ||
// same. | ||
// https://github.com/SlexAxton/css-colorguard/issues/2 | ||
css = css.replace(/url\(.*#.*\)/ig, 'url(removedforparser)'); | ||
// Run rework over it so we can parse out all the colors | ||
@@ -233,0 +243,0 @@ rework(css).use(findColors()).toString(); |
{ | ||
"name": "colorguard", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Keep a watchful eye on your css colors", | ||
@@ -32,3 +32,3 @@ "main": "index.js", | ||
"rework": "^1.0.0", | ||
"rework-visit": "^1.0.0", | ||
"rework-walk": "^1.0.0", | ||
"yargs": "^1.2.6" | ||
@@ -35,0 +35,0 @@ }, |
@@ -83,2 +83,8 @@ [![Build Status](https://travis-ci.org/SlexAxton/css-colorguard.svg?branch=master)](https://travis-ci.org/SlexAxton/css-colorguard) | ||
### Build Time | ||
CSS Colorguard can also be used in conjunction with other javascript build systems, such as [Gulp](https://github.com/gulpjs/gulp)! | ||
- [gulp-colorguard](https://github.com/pgilad/gulp-colorguard) | ||
## The Output | ||
@@ -85,0 +91,0 @@ |
@@ -8,3 +8,3 @@ var colorguard = require('..'); | ||
// It should ignore comments too | ||
colorguard.inspect(css).stats.counts['#000000'].should.equal(7); | ||
colorguard.inspect(css).stats.counts['#000000'].should.equal(8); | ||
}); | ||
@@ -11,0 +11,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21317
331
163
+ Addedrework-walk@^1.0.0
+ Addedrework-walk@1.0.0(transitive)
- Removedrework-visit@^1.0.0
- Removedrework-visit@1.0.0(transitive)