Commit 005a09debeae21ad38821346f69c9f2aba0347fc

Lea Verou 2014-04-25T15:47:03

Merge pull request #245 from themightychris/patch-1 support for PHP's #-style comments

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/components/prism-php.js b/components/prism-php.js
index 9d20b4f..9599f69 100644
--- a/components/prism-php.js
+++ b/components/prism-php.js
@@ -13,7 +13,11 @@
 
 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/ig,
-	'constant': /\b[A-Z0-9_]{2,}\b/g
+	'constant': /\b[A-Z0-9_]{2,}\b/g,
+	'comment': {
+		pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])(\/\/|#).*?(\r?\n|$))/g,
+		lookbehind: true
+	},
 });
 
 Prism.languages.insertBefore('php', 'keyword', {