diff --git a/build/ploticon.js b/build/ploticon.js index 2577efbb557..84b86fb0aa6 100644 --- a/build/ploticon.js +++ b/build/ploticon.js @@ -1,5 +1,3 @@ -/* jshint quotmark:true */ - 'use strict'; module.exports = { diff --git a/tasks/util/compress_attributes.js b/tasks/util/compress_attributes.js index 488c6a9594a..e417312c410 100644 --- a/tasks/util/compress_attributes.js +++ b/tasks/util/compress_attributes.js @@ -5,22 +5,31 @@ var through = require('through2'); * of the plotly.js bundles */ -var attributeNamesToRemove = [ - 'description', 'requiredOpts', 'otherOpts', 'hrName', 'role' -]; - -// ref: http://www.regexr.com/3bj6p -var regexStr = ''; -attributeNamesToRemove.forEach(function(attr, i) { - // one line string with or without trailing comma - regexStr += attr + ': \'.*\'' + ',?' + '|'; - // array of strings with or without trailing comma - regexStr += attr + ':.*\\n*.*\\.join\\(\\\'\\s\\\'\\)'; - - // attr:.*\n.*\.join\(\'\s\'\) - - if(i !== attributeNamesToRemove.length-1) regexStr += '|'; -}); + +// one line string with or without trailing comma +function makeStringRegex(attr) { + return attr + ': \'.*\'' + ',?'; +} + +// joined array of strings with or without trailing comma +function makeJoinedArrayRegex(attr) { + return attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + ',?'; +} + +// array with or without trailing comma +function makeArrayRegex(attr) { + return attr + ': \\[[\\s\\S]*?\\]' + ',?'; +} + +// ref: http://www.regexr.com/3cmac +var regexStr = [ + makeStringRegex('description'), + makeJoinedArrayRegex('description'), + makeArrayRegex('requiredOpts'), + makeArrayRegex('otherOpts'), + makeStringRegex('hrName'), + makeStringRegex('role') +].join('|'); var regex = new RegExp(regexStr, 'g');