Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't restore env.code from backupCode in Handlebars, PHP and Smarty … #998

Merged
merged 1 commit into from
Jul 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.