Skip to content

Commit d33d259

Browse files
RunDevelopmentmAAdhaTTah
authored andcommitted
Ignore duplicates in insertBefore (#1628)
Fix #1525 and implement option number 2.
1 parent 7277591 commit d33d259

File tree

10 files changed

+15
-20
lines changed

10 files changed

+15
-20
lines changed

components/prism-core.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ var _ = _self.Prism = {
9696
/**
9797
* Insert a token before another token in a language literal
9898
* As this needs to recreate the object (we cannot actually insert before keys in object literals),
99-
* we cannot just provide an object, we need anobject and a key.
99+
* we cannot just provide an object, we need an object and a key.
100100
* @param inside The key (or language id) of the parent
101101
* @param before The key to insert before.
102102
* @param insert Object with the key/value pairs to insert
@@ -108,20 +108,20 @@ var _ = _self.Prism = {
108108
var ret = {};
109109

110110
for (var token in grammar) {
111-
112111
if (grammar.hasOwnProperty(token)) {
113112

114113
if (token == before) {
115-
116114
for (var newToken in insert) {
117-
118115
if (insert.hasOwnProperty(newToken)) {
119116
ret[newToken] = insert[newToken];
120117
}
121118
}
122119
}
123120

124-
ret[token] = grammar[token];
121+
// Do not insert token which also occur in insert. See #1525
122+
if (!insert.hasOwnProperty(token)) {
123+
ret[token] = grammar[token];
124+
}
125125
}
126126
}
127127

components/prism-core.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/prism-csharp.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/prism-jolie.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Prism.languages.jolie = Prism.languages.extend('clike', {
1212
});
1313

1414
delete Prism.languages.jolie['class-name'];
15-
delete Prism.languages.jolie['function'];
1615

1716
Prism.languages.insertBefore( 'jolie', 'keyword', {
1817
'function':

0 commit comments

Comments
 (0)