Skip to content

Commit

Permalink
Merge pull request #5429 from plotly/no-whitespace-in-compress-attrs
Browse files Browse the repository at this point in the history
Leave no whitespace in compress_attributes when removing an attribute
  • Loading branch information
archmoj authored Jan 21, 2021
2 parents 6191e66 + 1436b9c commit f852131
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tasks/compress_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@ var through = require('through2');
* of the plotly.js bundles
*/

var WHITESPACE_BEFORE = '\\s*';
var OPTIONAL_COMMA = ',?';

// one line string with or without trailing comma
function makeStringRegex(attr) {
return makeRegex(
attr + ': \'.*\'' + ',?'
WHITESPACE_BEFORE + attr + ': \'.*\'' + OPTIONAL_COMMA
);
}

// joined array of strings with or without trailing comma
function makeJoinedArrayRegex(attr) {
return makeRegex(
attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + ',?'
WHITESPACE_BEFORE + attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + OPTIONAL_COMMA
);
}

// array with or without trailing comma
function makeArrayRegex(attr) {
return makeRegex(
attr + ': \\[[\\s\\S]*?\\]' + ',?'
WHITESPACE_BEFORE + attr + ': \\[[\\s\\S]*?\\]' + OPTIONAL_COMMA
);
}

Expand Down

0 comments on commit f852131

Please sign in to comment.