| 1 |
524
|
Ruebenwurz
|
/*
|
| 2 |
|
|
* CodePress regular expressions for PHP syntax highlighting
|
| 3 |
|
|
*/
|
| 4 |
|
|
|
| 5 |
|
|
// PHP
|
| 6 |
|
|
Language.syntax = [
|
| 7 |
|
|
{ input : /(<[^!\?]*?>)/g, output : '<b>$1</b>' }, // all tags
|
| 8 |
|
|
{ input : /(<style.*?>)(.*?)(<\/style>)/g, output : '<em>$1</em><em>$2</em><em>$3</em>' }, // style tags
|
| 9 |
|
|
{ input : /(<script.*?>)(.*?)(<\/script>)/g, output : '<ins>$1</ins><ins>$2</ins><ins>$3</ins>' }, // script tags
|
| 10 |
|
|
{ input : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>' }, // strings double quote
|
| 11 |
|
|
{ input : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<s>\'$1$2</s>'}, // strings single quote
|
| 12 |
|
|
{ input : /(<\?)/g, output : '<strong>$1' }, // <?.*
|
| 13 |
|
|
{ input : /(\?>)/g, output : '$1</strong>' }, // .*?>
|
| 14 |
|
|
{ input : /(<\?php|<\?=|<\?|\?>)/g, output : '<cite>$1</cite>' }, // php tags
|
| 15 |
|
|
{ input : /(\$[\w\.]*)/g, output : '<a>$1</a>' }, // vars
|
| 16 |
|
|
{ input : /\b(false|true|and|or|xor|__FILE__|exception|__LINE__|array|as|break|case|class|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|for|foreach|function|global|if|include|include_once|isset|list|new|print|require|require_once|return|static|switch|unset|use|while|__FUNCTION__|__CLASS__|__METHOD__|final|php_user_filter|interface|implements|extends|public|private|protected|abstract|clone|try|catch|throw|this)\b/g, output : '<u>$1</u>' }, // reserved words
|
| 17 |
|
|
{ input : /([^:])\/\/(.*?)(<br|<\/P)/g, output : '$1<i>//$2</i>$3' }, // php comments //
|
| 18 |
|
|
{ input : /([^:])#(.*?)(<br|<\/P)/g, output : '$1<i>#$2</i>$3' }, // php comments #
|
| 19 |
|
|
{ input : /\/\*(.*?)\*\//g, output : '<i>/*$1*/</i>' }, // php comments /* */
|
| 20 |
|
|
{ input : /(<!--.*?-->.)/g, output : '<big>$1</big>' } // html comments
|
| 21 |
|
|
]
|
| 22 |
|
|
|
| 23 |
|
|
Language.snippets = [
|
| 24 |
|
|
{ input : 'if', output : 'if($0){\n\t\n}' },
|
| 25 |
|
|
{ input : 'ifelse', output : 'if($0){\n\t\n}\nelse{\n\t\n}' },
|
| 26 |
|
|
{ input : 'else', output : '}\nelse {\n\t' },
|
| 27 |
|
|
{ input : 'elseif', output : '}\nelseif($0) {\n\t' },
|
| 28 |
|
|
{ input : 'do', output : 'do{\n\t$0\n}\nwhile();' },
|
| 29 |
|
|
{ input : 'inc', output : 'include_once("$0");' },
|
| 30 |
|
|
{ input : 'fun', output : 'function $0(){\n\t\n}' },
|
| 31 |
|
|
{ input : 'func', output : 'function $0(){\n\t\n}' },
|
| 32 |
|
|
{ input : 'while', output : 'while($0){\n\t\n}' },
|
| 33 |
|
|
{ input : 'for', output : 'for($0,,){\n\t\n}' },
|
| 34 |
|
|
{ input : 'fore', output : 'foreach($0 as ){\n\t\n}' },
|
| 35 |
|
|
{ input : 'foreach', output : 'foreach($0 as ){\n\t\n}' },
|
| 36 |
|
|
{ input : 'echo', output : 'echo \'$0\';' },
|
| 37 |
|
|
{ input : 'switch', output : 'switch($0) {\n\tcase "": break;\n\tdefault: ;\n}' },
|
| 38 |
|
|
{ input : 'case', output : 'case "$0" : break;' },
|
| 39 |
|
|
{ input : 'ret0', output : 'return false;' },
|
| 40 |
|
|
{ input : 'retf', output : 'return false;' },
|
| 41 |
|
|
{ input : 'ret1', output : 'return true;' },
|
| 42 |
|
|
{ input : 'rett', output : 'return true;' },
|
| 43 |
|
|
{ input : 'ret', output : 'return $0;' },
|
| 44 |
|
|
{ input : 'def', output : 'define(\'$0\',\'\');' },
|
| 45 |
|
|
{ input : '<?', output : 'php\n$0\n?>' }
|
| 46 |
|
|
]
|
| 47 |
|
|
|
| 48 |
|
|
Language.complete = [
|
| 49 |
|
|
{ input : '\'', output : '\'$0\'' },
|
| 50 |
|
|
{ input : '"', output : '"$0"' },
|
| 51 |
|
|
{ input : '(', output : '\($0\)' },
|
| 52 |
|
|
{ input : '[', output : '\[$0\]' },
|
| 53 |
|
|
{ input : '{', output : '{\n\t$0\n}' }
|
| 54 |
|
|
]
|
| 55 |
|
|
|
| 56 |
|
|
Language.shortcuts = [
|
| 57 |
|
|
{ input : '[space]', output : ' ' },
|
| 58 |
|
|
{ input : '[enter]', output : '<br />' } ,
|
| 59 |
|
|
{ input : '[j]', output : 'testing' },
|
| 60 |
|
|
{ input : '[7]', output : '&' }
|
| 61 |
|
|
]
|