More example testing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
diff --git a/components/prism-clike.js b/components/prism-clike.js
index 4125c49..bda722c 100644
--- a/components/prism-clike.js
+++ b/components/prism-clike.js
@@ -8,7 +8,7 @@ Prism.languages.clike = {
pattern: /((?:class|interface|extends|implements|trait|instanceof|new)\s+)[a-z0-9_\.\\]+/ig,
lookbehind: true,
inside: {
- punctuation: /\.|\\/
+ punctuation: /(\.|\\)/
}
},
'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|catch|finally|null|break|continue)\b/g,
diff --git a/components/prism-clike.min.js b/components/prism-clike.min.js
index 53a8fa5..f5288fc 100644
--- a/components/prism-clike.min.js
+++ b/components/prism-clike.min.js
@@ -1 +1 @@
-Prism.languages.clike={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g,lookbehind:!0},string:/("|')(\\?.)*?\1/g,"class-name":{pattern:/((?:class|interface|extends|implements|trait|instanceof|new)\s+)[a-z0-9_\.\\]+/ig,lookbehind:!0,inside:{punctuation:/\(|\./}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,"function":{pattern:/[a-z0-9_]+\(/ig,inside:{punctuation:/\(/}},number:/\b-?(0x)?\d*\.?[\da-f]+\b/g, operator:/[-+]{1,2}|!|=?<|=?>|={1,2}|(&){1,2}|\|?\||\?|\*|\//g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g};
\ No newline at end of file
+Prism.languages.clike={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g,lookbehind:!0},string:/("|')(\\?.)*?\1/g,"class-name":{pattern:/((?:class|interface|extends|implements|trait|instanceof|new)\s+)[a-z0-9_\.\\]+/ig,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,"function":{pattern:/[a-z0-9_]+\(/ig,inside:{punctuation:/\(/}},number:/\b-?(0x)?\d*\.?[\da-f]+\b/g,operator:/[-+]{1,2}|!|=?<|=?>|={1,2}|(&){1,2}|\|?\||\?|\*|\//g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g};
\ No newline at end of file
diff --git a/components/prism-php.js b/components/prism-php.js
index 840b95a..c40fae1 100644
--- a/components/prism-php.js
+++ b/components/prism-php.js
@@ -12,7 +12,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|extends|private|protected|parent|static|throw|null|echo|print|trait|namespace|use|final|yield|goto)\b/ig,
+ 'keyword': /(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|extends|private|protected|parent|static|throw|null|echo|print|trait|namespace|use|final|yield|goto)/ig,
'constant': /[A-Z0-9_]{2,}/g
});
diff --git a/components/prism-php.min.js b/components/prism-php.min.js
index fcd1b29..36fa499 100644
--- a/components/prism-php.min.js
+++ b/components/prism-php.min.js
@@ -1 +1 @@
-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|extends|private|protected|parent|static|throw|null|echo|print|trait|namespace|use|final|yield|goto)\b/ig,constant:/[A-Z0-9_]{2,}/g}); Prism.languages.insertBefore("php","keyword",{deliminator:/(\?>|\?>|<\?php|<\?php)/ig,"this":/\$this/,variable:/(\$\w+)\b/ig,scope:{pattern:/[a-z0-9_\\]+::/ig,inside:{keyword:/(static|self|parent)/,punctuation:/(::|\\)/}},"package":{pattern:/(\\|namespace\s+|use\s+)[a-z0-9_\\]+/ig,lookbehind:!0,inside:{punctuation:/\\/}}});Prism.languages.insertBefore("php","operator",{property:{pattern:/(->)[a-z0-9_]+/ig,lookbehind:!0}}); Prism.languages.markup&&Prism.languages.insertBefore("php","comment",{markup:{pattern:/(\?>|\?>)[\w\W]*?(?=(<\?php|<\?php))/ig,lookbehind:!0,inside:{markup:{pattern:/<\/?[\w:-]+\s*[\w\W]*?>/gi,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.php}}});
\ No newline at end of file
+Prism.languages.php=Prism.languages.extend("clike",{keyword:/(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|extends|private|protected|parent|static|throw|null|echo|print|trait|namespace|use|final|yield|goto)/ig,constant:/[A-Z0-9_]{2,}/g});Prism.languages.insertBefore("php","keyword",{deliminator:/(\?>|\?>|<\?php|<\?php)/ig,"this":/\$this/,variable:/(\$\w+)\b/ig,scope:{pattern:/[a-z0-9_\\]+::/ig,inside:{keyword:/(static|self|parent)/,punctuation:/(::|\\)/}},"package":{pattern:/(\\|namespace\s+|use\s+)[a-z0-9_\\]+/ig,lookbehind:!0,inside:{punctuation:/\\/}}});Prism.languages.insertBefore("php","operator",{property:{pattern:/(->)[a-z0-9_]+/ig,lookbehind:!0}});Prism.languages.markup&&Prism.languages.insertBefore("php","comment",{markup:{pattern:/(\?>|\?>)[\w\W]*?(?=(<\?php|<\?php))/ig,lookbehind:!0,inside:{markup:{pattern:/<\/?[\w:-]+\s*[\w\W]*?>/gi,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.php}}});
\ No newline at end of file
diff --git a/examples.html b/examples.html
index b1baeff..aadc454 100644
--- a/examples.html
+++ b/examples.html
@@ -314,10 +314,11 @@ use Some\Child\Class;
class Prism extends AbstractClass implements Interface_Class {
const CONSTANT = 12345;
public $foo = true;
- public static $bar = array('foo' => 'bar');
+ public static $bar = array('foo' => 'bar');
final public __construct(array $arg1, $arg2 = false) {
$this->foo = $arg2;
+ $this->bar = new Child\Class();
$int = 123456;
$string = 'Prism.js is the best!';
@@ -338,7 +339,7 @@ class Prism extends AbstractClass implements Interface_Class {
public function doSomething() {
$var = Static\Class::methodCall();
- for ($i = 0; $i <= 10; $i++) {
+ for ($i = 0; $i <= 10; $i++) {
$var = str_replace($i, rand(), $var);
}
diff --git a/prism.js b/prism.js
index 9e3e27e..671adf4 100644
--- a/prism.js
+++ b/prism.js
@@ -443,10 +443,19 @@ Prism.languages.clike = {
'string': /("|')(\\?.)*?\1/g,
'class-name': {
pattern: /((?:class|interface|extends|implements|trait|instanceof|new)\s+)[a-z0-9_\.\\]+/ig,
- lookbehind: true
+ lookbehind: true,
+ inside: {
+ punctuation: /(\.|\\)/
+ }
},
'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|catch|finally|null|break|continue)\b/g,
'boolean': /\b(true|false)\b/g,
+ 'function': {
+ pattern: /[a-z0-9_]+\(/ig,
+ inside: {
+ punctuation: /\(/
+ }
+ },
'number': /\b-?(0x)?\d*\.?[\da-f]+\b/g,
'operator': /[-+]{1,2}|!|=?<|=?>|={1,2}|(&){1,2}|\|?\||\?|\*|\//g,
'ignore': /&(lt|gt|amp);/gi,
@@ -459,7 +468,7 @@ Prism.languages.clike = {
Prism.languages.javascript = Prism.languages.extend('clike', {
'keyword': /\b(var|let|if|else|while|do|for|return|in|instanceof|function|new|with|typeof|try|catch|finally|null|break|continue)\b/g,
- 'number': /\b(-?(0x)?\d*\.?[\da-f]+|NaN|-?Infinity)\b/g,
+ 'number': /\b(-?(0x)?\d*\.?[\da-f]+|NaN|-?Infinity)\b/g
});
Prism.languages.insertBefore('javascript', 'keyword', {
@@ -489,7 +498,7 @@ if (Prism.languages.markup) {
********************************************** */
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|extends|private|protected|parent|static|throw|null|echo|print|trait|namespace|use|final|yield|goto)\b/ig,
+ 'keyword': /(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|extends|private|protected|parent|static|throw|null|echo|print|trait|namespace|use|final|yield|goto)/ig,
'constant': /[A-Z0-9_]{2,}/g
});