Skip to content

Commit e70d6f5

Browse files
committed
fixed docs
1 parent eccb7f8 commit e70d6f5

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lib/utils/options/replace.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ replace.fileCss = (filepath, options, cb) => {
8080
let result;
8181
// matches from . or # every character until : or . or ) (for pseudo elements or dots or even in :not(.class))
8282
// todo update regex
83-
const regex = /(#|\.)[^\s:\.\{)[>+,\s]+/gm;
84-
const removeMultiLineComments = /\/\*([\s\S]*?)\*\//g;
85-
const removeDoubleQuotes = /"[^"]*"/g;
86-
const removeSingleQuotes = /'[^']*'/g;
87-
const removeSizesWithDots = /\.([0-9]*?)(em|rem|%|vh|vw|s|cm|ex|in|mm|pc|pt|px|vmin)/g;
88-
const removeOnlyNumbers = /\.([0-9]*?)[0-9](\s|;|}|\))/g;
89-
const removeUrlAttributes = /url\(([\s\S]*?)\)/g;
90-
const removeHexCodes = /#([a-zA-Z0-9]{3,6})(\s|;|}|!|,)/g; // also removes also ids with 3 or 6 digits
83+
const regex = /(#|\.)[^\s:\.\{)[>+,\s]+/gm; // matches all selectors beginning with . or # - e.g. .matching#alsomatch .matchmetoo
84+
const matchMultiLineComments = /\/\*([\s\S]*?)\*\//g; // match /* */ from files
85+
const matchDoubleQuotes = /"[^"]*"/g; // match everything within " " (double quotes)
86+
const matchSingleQuotes = /'[^']*'/g; // match everything within " " (double quotes)
87+
const matchSizesWithDots = /\.([0-9]*?)(em|rem|%|vh|vw|s|cm|ex|in|mm|pc|pt|px|vmin)/g; // match everything which starts with . and has numbers in it and ends with em, rem,... - necessary for .9em or .10s
88+
const matchOnlyNumbers = /\.([0-9]*?)[0-9](\s|;|}|\))/g; // match if there are just numbers between . and \s or ; or } or ) - otherwise it will be regogniced as class
89+
const matchUrlAttributes = /url\(([\s\S]*?)\)/g; // matches url() attributes from css - it can contain .woff or .html or similiar
90+
const matchHexCodes = /#([a-zA-Z0-9]{3,6})(\s|;|}|!|,)/g; // matches hex colors with 3 or 6 values - unfortunately also matches also ids with 3 or 6 digits - e.g. matches #fff #header #0d0d0d
9191

9292
// set cb if options are not set
9393
if (typeof cb !== 'function') {
@@ -105,13 +105,13 @@ replace.fileCss = (filepath, options, cb) => {
105105

106106
rcs.selectorLibrary.set(
107107
data
108-
.replace(removeMultiLineComments, ' ')
109-
.replace(removeUrlAttributes, ' ')
110-
.replace(removeHexCodes, ' ')
111-
.replace(removeDoubleQuotes, ' ')
112-
.replace(removeSingleQuotes, ' ')
113-
.replace(removeSizesWithDots, ' ')
114-
.replace(removeOnlyNumbers, ' ')
108+
.replace(matchMultiLineComments, ' ')
109+
.replace(matchUrlAttributes, ' ')
110+
.replace(matchHexCodes, ' ')
111+
.replace(matchDoubleQuotes, ' ')
112+
.replace(matchSingleQuotes, ' ')
113+
.replace(matchSizesWithDots, ' ')
114+
.replace(matchOnlyNumbers, ' ')
115115
.match(regex)
116116
);
117117

0 commit comments

Comments
 (0)