Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1023)

Unified Diff: lib/src/prism/components/prism-php.js

Issue 1418513006: update elements and fix some bugs (Closed) Base URL: git@github.com:dart-lang/polymer_elements.git@master
Patch Set: code review updates Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/prism/components/prism-perl.min.js ('k') | lib/src/prism/components/prism-php-extras.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « lib/src/prism/components/prism-perl.min.js ('k') | lib/src/prism/components/prism-php-extras.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698