Index: lib/src/prism/components/prism-php.js |
diff --git a/lib/src/prism/components/prism-php.js b/lib/src/prism/components/prism-php.js |
index 825729f96f73ebe12d1d113eb9dc84ebadae677c..ae1e97ef0db92dbdbf4fd48b9a4a644e68b4462c 100644 |
--- a/lib/src/prism/components/prism-php.js |
+++ b/lib/src/prism/components/prism-php.js |
@@ -15,7 +15,7 @@ Prism.languages.php = Prism.languages.extend('clike', { |
'keyword': /\b(and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch)\b/i, |
'constant': /\b[A-Z0-9_]{2,}\b/, |
'comment': { |
- pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])(\/\/).*?(\r?\n|$))/, |
+ pattern: /(^|[^\\])(?:\/\*[\w\W]*?\*\/|\/\/.*)/, |
lookbehind: true |
} |
}); |
@@ -24,15 +24,15 @@ Prism.languages.php = Prism.languages.extend('clike', { |
// common than strings containing hashes... |
Prism.languages.insertBefore('php', 'class-name', { |
'shell-comment': { |
- pattern: /(^|[^\\])#.*?(\r?\n|$)/, |
+ pattern: /(^|[^\\])#.*/, |
lookbehind: true, |
alias: 'comment' |
} |
}); |
Prism.languages.insertBefore('php', 'keyword', { |
- 'delimiter': /(\?>|<\?php|<\?)/i, |
- 'variable': /(\$\w+)\b/i, |
+ 'delimiter': /\?>|<\?(?:php)?/i, |
+ 'variable': /\$\w+\b/i, |
'package': { |
pattern: /(\\|namespace\s+|use\s+)[\w\\]+/, |
lookbehind: true, |
@@ -85,7 +85,8 @@ if (Prism.languages.markup) { |
} |
for (var i = 0, t; t = env.tokenStack[i]; i++) { |
- env.highlightedCode = env.highlightedCode.replace('{{{PHP' + (i + 1) + '}}}', Prism.highlight(t, env.grammar, 'php')); |
+ // The replace prevents $$, $&, $`, $', $n, $nn from being interpreted as special patterns |
+ env.highlightedCode = env.highlightedCode.replace('{{{PHP' + (i + 1) + '}}}', Prism.highlight(t, env.grammar, 'php').replace(/\$/g, '$$$$')); |
} |
env.element.innerHTML = env.highlightedCode; |