@@ -5,22 +5,31 @@ var through = require('through2');
5
5
* of the plotly.js bundles
6
6
*/
7
7
8
- var attributeNamesToRemove = [
9
- 'description' , 'requiredOpts' , 'otherOpts' , 'hrName' , 'role'
10
- ] ;
11
-
12
- // ref: http://www.regexr.com/3bj6p
13
- var regexStr = '' ;
14
- attributeNamesToRemove . forEach ( function ( attr , i ) {
15
- // one line string with or without trailing comma
16
- regexStr += attr + ': \'.*\'' + ',?' + '|' ;
17
- // array of strings with or without trailing comma
18
- regexStr += attr + ':.*\\n*.*\\.join\\(\\\'\\s\\\'\\)' ;
19
-
20
- // attr:.*\n.*\.join\(\'\s\'\)
21
-
22
- if ( i !== attributeNamesToRemove . length - 1 ) regexStr += '|' ;
23
- } ) ;
8
+
9
+ // one line string with or without trailing comma
10
+ function makeStringRegex ( attr ) {
11
+ return attr + ': \'.*\'' + ',?' ;
12
+ }
13
+
14
+ // joined array of strings with or without trailing comma
15
+ function makeJoinedArrayRegex ( attr ) {
16
+ return attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + ',?' ;
17
+ }
18
+
19
+ // array with or without trailing comma
20
+ function makeArrayRegex ( attr ) {
21
+ return attr + ': \\[[\\s\\S]*?\\]' + ',?' ;
22
+ }
23
+
24
+ // ref: http://www.regexr.com/3cmac
25
+ var regexStr = [
26
+ makeStringRegex ( 'description' ) ,
27
+ makeJoinedArrayRegex ( 'description' ) ,
28
+ makeArrayRegex ( 'requiredOpts' ) ,
29
+ makeArrayRegex ( 'otherOpts' ) ,
30
+ makeStringRegex ( 'hrName' ) ,
31
+ makeStringRegex ( 'role' )
32
+ ] . join ( '|' ) ;
24
33
25
34
var regex = new RegExp ( regexStr , 'g' ) ;
26
35
0 commit comments