Skip to content

Commit

Permalink
Updated all String.propotype.replace calls for literal strings
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Mar 26, 2020
1 parent 504a63b commit 5d7aab5
Show file tree
Hide file tree
Showing 33 changed files with 60 additions and 56 deletions.
2 changes: 1 addition & 1 deletion components/prism-csharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
function nested(pattern, depthLog2) {
for (var i = 0; i < depthLog2; i++) {
pattern = pattern.replace(/<<self>>/g, '(?:' + pattern + ')');
pattern = pattern.replace(/<<self>>/g, function () { return '(?:' + pattern + ')'; });
}
return pattern.replace(/<<self>>/g, '[^\\s\\S]');
}
Expand Down
2 changes: 1 addition & 1 deletion components/prism-csharp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions components/prism-ftl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// FTL expression with 4 levels of nesting supported
var FTL_EXPR = /(?!<#--)[^()"']|\((?:<expr>)*\)|<#--[\s\S]*?-->|"(?:[^\\"]|\\.)*"|'(?:[^\\']|\\.)*'/.source;
for (var i = 0; i < 2; i++) {
FTL_EXPR = FTL_EXPR.replace(/<expr>/g, FTL_EXPR);
FTL_EXPR = FTL_EXPR.replace(/<expr>/g, function () { return FTL_EXPR; });
}
FTL_EXPR = FTL_EXPR.replace(/<expr>/g, '[^\s\S]');

Expand All @@ -18,11 +18,11 @@
greedy: true
},
{
pattern: RegExp(/("|')(?:(?!\1|\$\{)[^\\]|\\.|\$\{(?:<expr>)*?\})*\1/.source.replace(/<expr>/g, FTL_EXPR)),
pattern: RegExp(/("|')(?:(?!\1|\$\{)[^\\]|\\.|\$\{(?:<expr>)*?\})*\1/.source.replace(/<expr>/g, function () { return FTL_EXPR; })),
greedy: true,
inside: {
'interpolation': {
pattern: RegExp(/((?:^|[^\\])(?:\\\\)*)\$\{(?:<expr>)*?\}/.source.replace(/<expr>/g, FTL_EXPR)),
pattern: RegExp(/((?:^|[^\\])(?:\\\\)*)\$\{(?:<expr>)*?\}/.source.replace(/<expr>/g, function () { return FTL_EXPR; })),
lookbehind: true,
inside: {
'interpolation-punctuation': {
Expand Down Expand Up @@ -86,7 +86,7 @@
};

Prism.hooks.add('before-tokenize', function (env) {
var pattern = RegExp(/<#--[\s\S]*?-->|<\/?[#@][a-zA-Z](?:<expr>)*?>|\$\{(?:<expr>)*?\}/.source.replace(/<expr>/g, FTL_EXPR), 'gi');
var pattern = RegExp(/<#--[\s\S]*?-->|<\/?[#@][a-zA-Z](?:<expr>)*?>|\$\{(?:<expr>)*?\}/.source.replace(/<expr>/g, function () { return FTL_EXPR; }), 'gi');
Prism.languages['markup-templating'].buildPlaceholders(env, 'ftl', pattern);
});

Expand Down
2 changes: 1 addition & 1 deletion components/prism-ftl.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/prism-haml.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
filter = typeof filter === 'string' ? {filter: filter, language: filter} : filter;
if (Prism.languages[filter.language]) {
all_filters['filter-' + filter.filter] = {
pattern: RegExp(filter_pattern.replace('{{filter_name}}', filter.filter)),
pattern: RegExp(filter_pattern.replace('{{filter_name}}', function () { return filter.filter; })),
lookbehind: true,
inside: {
'filter-name': {
Expand Down
Loading

0 comments on commit 5d7aab5

Please sign in to comment.