From 96df0344c607ed4a73870b7986b8afebc0478207 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Sun, 22 Jul 2018 12:30:02 +0200 Subject: [PATCH] Replaced all occurrences of `new RegExp` with `RegExp` --- components/prism-http.js | 2 +- components/prism-http.min.js | 2 +- components/prism-lisp.js | 46 +++++++++---------- components/prism-lisp.min.js | 2 +- .../prism-normalize-whitespace.js | 6 +-- .../prism-normalize-whitespace.min.js | 2 +- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/components/prism-http.js b/components/prism-http.js index 82bfed78c8..306bcd8c5d 100644 --- a/components/prism-http.js +++ b/components/prism-http.js @@ -39,7 +39,7 @@ for (var contentType in httpLanguages) { if (httpLanguages[contentType]) { var options = {}; options[contentType] = { - pattern: new RegExp('(content-type:\\s*' + contentType + '[\\w\\W]*?)(?:\\r?\\n|\\r){2}[\\w\\W]*', 'i'), + pattern: RegExp('(content-type:\\s*' + contentType + '[\\w\\W]*?)(?:\\r?\\n|\\r){2}[\\w\\W]*', 'i'), lookbehind: true, inside: { rest: httpLanguages[contentType] diff --git a/components/prism-http.min.js b/components/prism-http.min.js index 0db32ce3f1..8b2c7eed07 100644 --- a/components/prism-http.min.js +++ b/components/prism-http.min.js @@ -1 +1 @@ -Prism.languages.http={"request-line":{pattern:/^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\s(?:https?:\/\/|\/)\S+\sHTTP\/[0-9.]+/m,inside:{property:/^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b/,"attr-name":/:\w+/}},"response-status":{pattern:/^HTTP\/1.[01] \d+.*/m,inside:{property:{pattern:/(^HTTP\/1.[01] )\d+.*/i,lookbehind:!0}}},"header-name":{pattern:/^[\w-]+:(?=.)/m,alias:"keyword"}};var httpLanguages={"application/json":Prism.languages.javascript,"application/xml":Prism.languages.markup,"text/xml":Prism.languages.markup,"text/html":Prism.languages.markup};for(var contentType in httpLanguages)if(httpLanguages[contentType]){var options={};options[contentType]={pattern:new RegExp("(content-type:\\s*"+contentType+"[\\w\\W]*?)(?:\\r?\\n|\\r){2}[\\w\\W]*","i"),lookbehind:!0,inside:{rest:httpLanguages[contentType]}},Prism.languages.insertBefore("http","header-name",options)} \ No newline at end of file +Prism.languages.http={"request-line":{pattern:/^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\s(?:https?:\/\/|\/)\S+\sHTTP\/[0-9.]+/m,inside:{property:/^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b/,"attr-name":/:\w+/}},"response-status":{pattern:/^HTTP\/1.[01] \d+.*/m,inside:{property:{pattern:/(^HTTP\/1.[01] )\d+.*/i,lookbehind:!0}}},"header-name":{pattern:/^[\w-]+:(?=.)/m,alias:"keyword"}};var httpLanguages={"application/json":Prism.languages.javascript,"application/xml":Prism.languages.markup,"text/xml":Prism.languages.markup,"text/html":Prism.languages.markup};for(var contentType in httpLanguages)if(httpLanguages[contentType]){var options={};options[contentType]={pattern:RegExp("(content-type:\\s*"+contentType+"[\\w\\W]*?)(?:\\r?\\n|\\r){2}[\\w\\W]*","i"),lookbehind:!0,inside:{rest:httpLanguages[contentType]}},Prism.languages.insertBefore("http","header-name",options)} \ No newline at end of file diff --git a/components/prism-lisp.js b/components/prism-lisp.js index b8b0451405..4c2dceb5db 100644 --- a/components/prism-lisp.js +++ b/components/prism-lisp.js @@ -3,11 +3,11 @@ // simple form // e.g. (interactive ... or (interactive) function simple_form(name) { - return new RegExp('(\\()' + name + '(?=[\\s\\)])'); + return RegExp('(\\()' + name + '(?=[\\s\\)])'); } // booleans and numbers function primitive(pattern) { - return new RegExp('([\\s([])' + pattern + '(?=[\\s)])'); + return RegExp('([\\s([])' + pattern + '(?=[\\s)])'); } // Patterns in regular expressions @@ -36,24 +36,24 @@ greedy: true, inside: { argument: /[-A-Z]+(?=[.,\s])/, - symbol: new RegExp('`' + symbol + "'") + symbol: RegExp('`' + symbol + "'") } }, 'quoted-symbol': { - pattern: new RegExp("#?'" + symbol), + pattern: RegExp("#?'" + symbol), alias: ['variable', 'symbol'] }, 'lisp-property': { - pattern: new RegExp(':' + symbol), + pattern: RegExp(':' + symbol), alias: 'property' }, splice: { - pattern: new RegExp(',@?' + symbol), + pattern: RegExp(',@?' + symbol), alias: ['symbol', 'variable'] }, keyword: [ { - pattern: new RegExp( + pattern: RegExp( par + '(?:(?:lexical-)?let\\*?|(?:cl-)?letf|if|when|while|unless|cons|cl-loop|and|or|not|cond|setq|error|message|null|require|provide|use-package)' + space @@ -61,7 +61,7 @@ lookbehind: true }, { - pattern: new RegExp( + pattern: RegExp( par + '(?:for|do|collect|return|finally|append|concat|in|by)' + space ), lookbehind: true @@ -86,15 +86,15 @@ lookbehind: true }, defvar: { - pattern: new RegExp(par + 'def(?:var|const|custom|group)\\s+' + symbol), + pattern: RegExp(par + 'def(?:var|const|custom|group)\\s+' + symbol), lookbehind: true, inside: { keyword: /^def[a-z]+/, - variable: new RegExp(symbol) + variable: RegExp(symbol) } }, defun: { - pattern: new RegExp( + pattern: RegExp( par + '(?:cl-)?(?:defun\\*?|defmacro)\\s+' + symbol + @@ -107,14 +107,14 @@ // reference the language object. arguments: null, function: { - pattern: new RegExp('(^\\s)' + symbol), + pattern: RegExp('(^\\s)' + symbol), lookbehind: true }, punctuation: /[()]/ } }, lambda: { - pattern: new RegExp(par + 'lambda\\s+\\((?:&?' + symbol + '\\s*)*\\)'), + pattern: RegExp(par + 'lambda\\s+\\((?:&?' + symbol + '\\s*)*\\)'), lookbehind: true, inside: { keyword: /^lambda/, @@ -125,7 +125,7 @@ } }, car: { - pattern: new RegExp(par + symbol), + pattern: RegExp(par + symbol), lookbehind: true }, punctuation: [ @@ -140,14 +140,14 @@ }; var arg = { - 'lisp-marker': new RegExp(marker), + 'lisp-marker': RegExp(marker), rest: { argument: { - pattern: new RegExp(symbol), + pattern: RegExp(symbol), alias: 'variable' }, varform: { - pattern: new RegExp(par + symbol + '\\s+\\S[\\s\\S]*' + endpar), + pattern: RegExp(par + symbol + '\\s+\\S[\\s\\S]*' + endpar), lookbehind: true, inside: { string: language.string, @@ -163,23 +163,23 @@ var forms = '\\S+(?:\\s+\\S+)*'; var arglist = { - pattern: new RegExp(par + '[\\s\\S]*' + endpar), + pattern: RegExp(par + '[\\s\\S]*' + endpar), lookbehind: true, inside: { 'rest-vars': { - pattern: new RegExp('&(?:rest|body)\\s+' + forms), + pattern: RegExp('&(?:rest|body)\\s+' + forms), inside: arg }, 'other-marker-vars': { - pattern: new RegExp('&(?:optional|aux)\\s+' + forms), + pattern: RegExp('&(?:optional|aux)\\s+' + forms), inside: arg }, keys: { - pattern: new RegExp('&key\\s+' + forms + '(?:\\s+&allow-other-keys)?'), + pattern: RegExp('&key\\s+' + forms + '(?:\\s+&allow-other-keys)?'), inside: arg }, argument: { - pattern: new RegExp(symbol), + pattern: RegExp(symbol), alias: 'variable' }, punctuation: /[()]/ @@ -194,4 +194,4 @@ Prism.languages.elisp = language; Prism.languages.emacs = language; Prism.languages['emacs-lisp'] = language; -}(Prism)); \ No newline at end of file +}(Prism)); diff --git a/components/prism-lisp.min.js b/components/prism-lisp.min.js index 6aa700bca6..9fa2a4e1dd 100644 --- a/components/prism-lisp.min.js +++ b/components/prism-lisp.min.js @@ -1 +1 @@ -!function(e){function n(e){return new RegExp("(\\()"+e+"(?=[\\s\\)])")}function a(e){return new RegExp("([\\s([])"+e+"(?=[\\s)])")}var t="[-+*/_~!@$%^=<>{}\\w]+",r="&"+t,i="(\\()",s="(?=\\))",o="(?=\\s)",l={heading:{pattern:/;;;.*/,alias:["comment","title"]},comment:/;.*/,string:{pattern:/"(?:[^"\\]*|\\.)*"/,greedy:!0,inside:{argument:/[-A-Z]+(?=[.,\s])/,symbol:new RegExp("`"+t+"'")}},"quoted-symbol":{pattern:new RegExp("#?'"+t),alias:["variable","symbol"]},"lisp-property":{pattern:new RegExp(":"+t),alias:"property"},splice:{pattern:new RegExp(",@?"+t),alias:["symbol","variable"]},keyword:[{pattern:new RegExp(i+"(?:(?:lexical-)?let\\*?|(?:cl-)?letf|if|when|while|unless|cons|cl-loop|and|or|not|cond|setq|error|message|null|require|provide|use-package)"+o),lookbehind:!0},{pattern:new RegExp(i+"(?:for|do|collect|return|finally|append|concat|in|by)"+o),lookbehind:!0}],declare:{pattern:n("declare"),lookbehind:!0,alias:"keyword"},interactive:{pattern:n("interactive"),lookbehind:!0,alias:"keyword"},"boolean":{pattern:a("(?:t|nil)"),lookbehind:!0},number:{pattern:a("[-+]?\\d+(?:\\.\\d*)?"),lookbehind:!0},defvar:{pattern:new RegExp(i+"def(?:var|const|custom|group)\\s+"+t),lookbehind:!0,inside:{keyword:/^def[a-z]+/,variable:new RegExp(t)}},defun:{pattern:new RegExp(i+"(?:cl-)?(?:defun\\*?|defmacro)\\s+"+t+"\\s+\\([\\s\\S]*?\\)"),lookbehind:!0,inside:{keyword:/^(?:cl-)?def\S+/,arguments:null,"function":{pattern:new RegExp("(^\\s)"+t),lookbehind:!0},punctuation:/[()]/}},lambda:{pattern:new RegExp(i+"lambda\\s+\\((?:&?"+t+"\\s*)*\\)"),lookbehind:!0,inside:{keyword:/^lambda/,arguments:null,punctuation:/[()]/}},car:{pattern:new RegExp(i+t),lookbehind:!0},punctuation:[/(['`,]?\(|[)\[\]])/,{pattern:/(\s)\.(?=\s)/,lookbehind:!0}]},p={"lisp-marker":new RegExp(r),rest:{argument:{pattern:new RegExp(t),alias:"variable"},varform:{pattern:new RegExp(i+t+"\\s+\\S[\\s\\S]*"+s),lookbehind:!0,inside:{string:l.string,"boolean":l.boolean,number:l.number,symbol:l.symbol,punctuation:/[()]/}}}},d="\\S+(?:\\s+\\S+)*",u={pattern:new RegExp(i+"[\\s\\S]*"+s),lookbehind:!0,inside:{"rest-vars":{pattern:new RegExp("&(?:rest|body)\\s+"+d),inside:p},"other-marker-vars":{pattern:new RegExp("&(?:optional|aux)\\s+"+d),inside:p},keys:{pattern:new RegExp("&key\\s+"+d+"(?:\\s+&allow-other-keys)?"),inside:p},argument:{pattern:new RegExp(t),alias:"variable"},punctuation:/[()]/}};l.lambda.inside.arguments=u,l.defun.inside.arguments=e.util.clone(u),l.defun.inside.arguments.inside.sublist=u,e.languages.lisp=l,e.languages.elisp=l,e.languages.emacs=l,e.languages["emacs-lisp"]=l}(Prism); \ No newline at end of file +!function(e){function n(e){return RegExp("(\\()"+e+"(?=[\\s\\)])")}function a(e){return RegExp("([\\s([])"+e+"(?=[\\s)])")}var t="[-+*/_~!@$%^=<>{}\\w]+",r="&"+t,i="(\\()",s="(?=\\))",o="(?=\\s)",l={heading:{pattern:/;;;.*/,alias:["comment","title"]},comment:/;.*/,string:{pattern:/"(?:[^"\\]*|\\.)*"/,greedy:!0,inside:{argument:/[-A-Z]+(?=[.,\s])/,symbol:RegExp("`"+t+"'")}},"quoted-symbol":{pattern:RegExp("#?'"+t),alias:["variable","symbol"]},"lisp-property":{pattern:RegExp(":"+t),alias:"property"},splice:{pattern:RegExp(",@?"+t),alias:["symbol","variable"]},keyword:[{pattern:RegExp(i+"(?:(?:lexical-)?let\\*?|(?:cl-)?letf|if|when|while|unless|cons|cl-loop|and|or|not|cond|setq|error|message|null|require|provide|use-package)"+o),lookbehind:!0},{pattern:RegExp(i+"(?:for|do|collect|return|finally|append|concat|in|by)"+o),lookbehind:!0}],declare:{pattern:n("declare"),lookbehind:!0,alias:"keyword"},interactive:{pattern:n("interactive"),lookbehind:!0,alias:"keyword"},"boolean":{pattern:a("(?:t|nil)"),lookbehind:!0},number:{pattern:a("[-+]?\\d+(?:\\.\\d*)?"),lookbehind:!0},defvar:{pattern:RegExp(i+"def(?:var|const|custom|group)\\s+"+t),lookbehind:!0,inside:{keyword:/^def[a-z]+/,variable:RegExp(t)}},defun:{pattern:RegExp(i+"(?:cl-)?(?:defun\\*?|defmacro)\\s+"+t+"\\s+\\([\\s\\S]*?\\)"),lookbehind:!0,inside:{keyword:/^(?:cl-)?def\S+/,arguments:null,"function":{pattern:RegExp("(^\\s)"+t),lookbehind:!0},punctuation:/[()]/}},lambda:{pattern:RegExp(i+"lambda\\s+\\((?:&?"+t+"\\s*)*\\)"),lookbehind:!0,inside:{keyword:/^lambda/,arguments:null,punctuation:/[()]/}},car:{pattern:RegExp(i+t),lookbehind:!0},punctuation:[/(['`,]?\(|[)\[\]])/,{pattern:/(\s)\.(?=\s)/,lookbehind:!0}]},p={"lisp-marker":RegExp(r),rest:{argument:{pattern:RegExp(t),alias:"variable"},varform:{pattern:RegExp(i+t+"\\s+\\S[\\s\\S]*"+s),lookbehind:!0,inside:{string:l.string,"boolean":l.boolean,number:l.number,symbol:l.symbol,punctuation:/[()]/}}}},d="\\S+(?:\\s+\\S+)*",u={pattern:RegExp(i+"[\\s\\S]*"+s),lookbehind:!0,inside:{"rest-vars":{pattern:RegExp("&(?:rest|body)\\s+"+d),inside:p},"other-marker-vars":{pattern:RegExp("&(?:optional|aux)\\s+"+d),inside:p},keys:{pattern:RegExp("&key\\s+"+d+"(?:\\s+&allow-other-keys)?"),inside:p},argument:{pattern:RegExp(t),alias:"variable"},punctuation:/[()]/}};l.lambda.inside.arguments=u,l.defun.inside.arguments=e.util.clone(u),l.defun.inside.arguments.inside.sublist=u,e.languages.lisp=l,e.languages.elisp=l,e.languages.emacs=l,e.languages["emacs-lisp"]=l}(Prism); \ No newline at end of file diff --git a/plugins/normalize-whitespace/prism-normalize-whitespace.js b/plugins/normalize-whitespace/prism-normalize-whitespace.js index 0b66de03a0..b6c6472793 100644 --- a/plugins/normalize-whitespace/prism-normalize-whitespace.js +++ b/plugins/normalize-whitespace/prism-normalize-whitespace.js @@ -60,7 +60,7 @@ NormalizeWhitespace.prototype = { }, spacesToTabs: function (input, spaces) { spaces = spaces|0 || 4; - return input.replace(new RegExp(' {' + spaces + '}', 'g'), '\t'); + return input.replace(RegExp(' {' + spaces + '}', 'g'), '\t'); }, removeTrailing: function (input) { return input.replace(/\s*?$/gm, ''); @@ -80,7 +80,7 @@ NormalizeWhitespace.prototype = { if (!indents[0].length) return input; - return input.replace(new RegExp('^' + indents[0], 'gm'), ''); + return input.replace(RegExp('^' + indents[0], 'gm'), ''); }, indent: function (input, tabs) { return input.replace(/^[^\S\n\r]*(?=\S)/gm, new Array(++tabs).join('\t') + '$&'); @@ -187,4 +187,4 @@ Prism.hooks.add('before-sanity-check', function (env) { } }); -}()); \ No newline at end of file +}()); diff --git a/plugins/normalize-whitespace/prism-normalize-whitespace.min.js b/plugins/normalize-whitespace/prism-normalize-whitespace.min.js index b38d064c25..39fa5795a9 100644 --- a/plugins/normalize-whitespace/prism-normalize-whitespace.min.js +++ b/plugins/normalize-whitespace/prism-normalize-whitespace.min.js @@ -1 +1 @@ -!function(){function e(e){this.defaults=r({},e)}function n(e){return e.replace(/-(\w)/g,function(e,n){return n.toUpperCase()})}function t(e){for(var n=0,t=0;tn&&(o[s]="\n"+o[s],a=l)}r[i]=o.join("")}return r.join("\n")}},"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof Prism&&(Prism.plugins.NormalizeWhitespace=new e({"remove-trailing":!0,"remove-indent":!0,"left-trim":!0,"right-trim":!0}),Prism.hooks.add("before-sanity-check",function(e){var n=Prism.plugins.NormalizeWhitespace;if(!e.settings||e.settings["whitespace-normalization"]!==!1){if((!e.element||!e.element.parentNode)&&e.code)return e.code=n.normalize(e.code,e.settings),void 0;var t=e.element.parentNode,r=/\bno-whitespace-normalization\b/;if(e.code&&t&&"pre"===t.nodeName.toLowerCase()&&!r.test(t.className)&&!r.test(e.element.className)){for(var i=t.childNodes,o="",a="",s=!1,l=0;ln&&(o[s]="\n"+o[s],a=l)}r[i]=o.join("")}return r.join("\n")}},"undefined"!=typeof module&&module.exports&&(module.exports=e),"undefined"!=typeof Prism&&(Prism.plugins.NormalizeWhitespace=new e({"remove-trailing":!0,"remove-indent":!0,"left-trim":!0,"right-trim":!0}),Prism.hooks.add("before-sanity-check",function(e){var n=Prism.plugins.NormalizeWhitespace;if(!e.settings||e.settings["whitespace-normalization"]!==!1){if((!e.element||!e.element.parentNode)&&e.code)return e.code=n.normalize(e.code,e.settings),void 0;var t=e.element.parentNode,r=/\bno-whitespace-normalization\b/;if(e.code&&t&&"pre"===t.nodeName.toLowerCase()&&!r.test(t.className)&&!r.test(e.element.className)){for(var i=t.childNodes,o="",a="",s=!1,l=0;l