Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leave no whitespace in compress_attributes when removing an attribute #5429

Merged
merged 2 commits into from
Jan 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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