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 Feb 10, 2017
1 parent d97c530 commit c603521
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 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,7 +95,7 @@ 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) + '}}}',
env.highlightedCode = env.highlightedCode.replace('___PHP' + (i + 1) + '___',
"<span class=\"token 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 c603521

Please sign in to comment.