Skip to content

Commit

Permalink
Add css-color
Browse files Browse the repository at this point in the history
  • Loading branch information
asamuzaK committed Dec 4, 2024
1 parent 9711014 commit b1ba181
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 202 deletions.
12 changes: 10 additions & 2 deletions lib/parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
********************************************************************/
'use strict';

const { resolve } = require('@asamuzakjp/css-color');
const namedColors = require('./named_colors.json');
const { hslToRgb } = require('./utils/colorSpace');

Expand Down Expand Up @@ -323,7 +324,7 @@ exports.parseColor = function parseColor(val) {
return 'rgb(' + red + ', ' + green + ', ' + blue + ')';
}

res = colorRegEx2.exec(val);
res = val.includes(',') && colorRegEx2.exec(val);
if (res) {
parts = res[1].split(/\s*,\s*/);
if (parts.length !== 3) {
Expand All @@ -346,7 +347,7 @@ exports.parseColor = function parseColor(val) {
return 'rgb(' + red + ', ' + green + ', ' + blue + ')';
}

res = colorRegEx3.exec(val);
res = val.includes(',') && colorRegEx3.exec(val);
if (res) {
parts = res[1].split(/\s*,\s*/);
if (parts.length !== 4) {
Expand Down Expand Up @@ -402,6 +403,13 @@ exports.parseColor = function parseColor(val) {
if (type === exports.TYPES.COLOR) {
return val;
}

res = resolve(val, {
format: 'specifiedValue'

Check failure on line 408 in lib/parsers.js

View workflow job for this annotation

GitHub Actions / Lint and tests (18)

Insert `,`

Check failure on line 408 in lib/parsers.js

View workflow job for this annotation

GitHub Actions / Lint and tests (20)

Insert `,`

Check failure on line 408 in lib/parsers.js

View workflow job for this annotation

GitHub Actions / Lint and tests (latest)

Insert `,`
});
if (res) {
return res;
}
return undefined;
};

Expand Down
Loading

0 comments on commit b1ba181

Please sign in to comment.