Skip to content

Commit

Permalink
Use different replacement marker for PHP, because curly braces are
Browse files Browse the repository at this point in the history
highlighted as punctuation in JavaScript and CSS.
  • Loading branch information
zeitgeist87 committed Mar 10, 2017
1 parent 76698cd commit 4daff89
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions components/prism-php.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if (Prism.languages.markup) {
env.code = env.code.replace(/(?:<\?php|<\?)[\w\W]*?(?:\?>|$)/ig, function(match) {
env.tokenStack.push(match);

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

// Switch the grammar to markup
Expand All @@ -95,8 +95,8 @@ if (Prism.languages.markup) {

for (var i = 0, t; t = env.tokenStack[i]; i++) {
// The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns
env.highlightedCode = env.highlightedCode.replace('{{{PHP' + (i + 1) + '}}}',
"<span class=\"token php\">" +
env.highlightedCode = env.highlightedCode.replace('___PHP' + (i + 1) + '___',
"<span class=\"token php language-php\">" +
Prism.highlight(t, env.grammar, 'php').replace(/\$/g, '$$$$') +
"</span>");
}
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.

0 comments on commit 4daff89

Please sign in to comment.