Skip to content

Commit

Permalink
Merge pull request #998 from Golmote/before-insert-code-restore
Browse files Browse the repository at this point in the history
Don't restore env.code from backupCode in Handlebars, PHP and Smarty …
  • Loading branch information
Golmote authored Jul 14, 2016
2 parents c1a0c1b + d8fefde commit 36739b3
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 30 deletions.
9 changes: 0 additions & 9 deletions components/prism-handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,13 @@

env.tokenStack = [];

env.backupCode = env.code;
env.code = env.code.replace(handlebars_pattern, function(match) {
env.tokenStack.push(match);

return '___HANDLEBARS' + env.tokenStack.length + '___';
});
});

// Restore env.code for other plugins (e.g. line-numbers)
Prism.hooks.add('before-insert', function(env) {
if (env.language === 'handlebars') {
env.code = env.backupCode;
delete env.backupCode;
}
});

// Re-insert the tokens after highlighting
// and highlight them with defined grammar
Prism.hooks.add('after-highlight', function(env) {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-handlebars.min.js

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

9 changes: 0 additions & 9 deletions components/prism-php.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,13 @@ if (Prism.languages.markup) {

env.tokenStack = [];

env.backupCode = env.code;
env.code = env.code.replace(/(?:<\?php|<\?)[\w\W]*?(?:\?>)/ig, function(match) {
env.tokenStack.push(match);

return '{{{PHP' + env.tokenStack.length + '}}}';
});
});

// Restore env.code for other plugins (e.g. line-numbers)
Prism.hooks.add('before-insert', function(env) {
if (env.language === 'php') {
env.code = env.backupCode;
delete env.backupCode;
}
});

// Re-insert the tokens after highlighting
Prism.hooks.add('after-highlight', function(env) {
if (env.language !== 'php') {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-php.min.js

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

9 changes: 0 additions & 9 deletions components/prism-smarty.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@

env.tokenStack = [];

env.backupCode = env.code;
env.code = env.code.replace(smarty_pattern, function(match) {

// Smarty tags inside {literal} block are ignored
Expand All @@ -101,14 +100,6 @@
});
});

// Restore env.code for other plugins (e.g. line-numbers)
Prism.hooks.add('before-insert', function(env) {
if (env.language === 'smarty') {
env.code = env.backupCode;
delete env.backupCode;
}
});

// Re-insert the tokens after highlighting
// and highlight them with defined grammar
Prism.hooks.add('after-highlight', function(env) {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-smarty.min.js

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

0 comments on commit 36739b3

Please sign in to comment.