[PHP] 在线文本编辑器 自动根据编程语言高亮 ajax版 →→→→→进入此内容的聊天室

来自 , 2019-10-02, 写在 PHP, 查看 127 次.
URL http://www.code666.cn/view/12a1d073
  1. 在线编辑服务器
  2.  
  3.  
  4.  
  5. /*
  6.  * CodePress regular expressions for Perl syntax highlighting
  7.  * By J. Nick Koston
  8.  */
  9.  
  10. // Perl
  11. Language.syntax = [
  12.         { input  : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>' }, // strings double quote
  13.         { input  : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<s>\'$1$2</s>' }, // strings single quote
  14.         { input  : /([\$\@\%][\w\.]*)/g, output : '<a>$1</a>' }, // vars
  15.         { input  : /(sub\s+)([\w\.]*)/g, output : '$1<em>$2</em>' }, // functions
  16.         { input  : /\b(abs|accept|alarm|atan2|bind|binmode|bless|caller|chdir|chmod|chomp|chop|chown|chr|chroot|close|closedir|connect|continue|cos|crypt|dbmclose|dbmopen|defined|delete|die|do|dump|each|else|elsif|endgrent|endhostent|endnetent|endprotoent|endpwent|eof|eval|exec|exists|exit|fcntl|fileno|find|flock|for|foreach|fork|format|formlinegetc|getgrent|getgrgid|getgrnam|gethostbyaddr|gethostbyname|gethostent|getlogin|getnetbyaddr|getnetbyname|getnetent|getpeername|getpgrp|getppid|getpriority|getprotobyname|getprotobynumber|getprotoent|getpwent|getpwnam|getpwuid|getservbyaddr|getservbyname|getservbyport|getservent|getsockname|getsockopt|glob|gmtime|goto|grep|hex|hostname|if|import|index|int|ioctl|join|keys|kill|last|lc|lcfirst|length|link|listen|LoadExternals|local|localtime|log|lstat|map|mkdir|msgctl|msgget|msgrcv|msgsnd|my|next|no|oct|open|opendir|ordpack|package|pipe|pop|pos|print|printf|push|pwd|qq|quotemeta|qw|rand|read|readdir|readlink|recv|redo|ref|rename|require|reset|return|reverse|rewinddir|rindex|rmdir|scalar|seek|seekdir|select|semctl|semget|semop|send|setgrent|sethostent|setnetent|setpgrp|setpriority|setprotoent|setpwent|setservent|setsockopt|shift|shmctl|shmget|shmread|shmwrite|shutdown|sin|sleep|socket|socketpair|sort|splice|split|sprintf|sqrt|srand|stat|stty|study|sub|substr|symlink|syscall|sysopen|sysread|system|syswritetell|telldir|tie|tied|time|times|tr|truncate|uc|ucfirst|umask|undef|unless|unlink|until|unpack|unshift|untie|use|utime|values|vec|waitpid|wantarray|warn|while|write)\b/g, output : '<b>$1</b>' }, // reserved words
  17.         { input  : /([\(\){}])/g, output : '<u>$1</u>' }, // special chars
  18.         { input  : /#(.*?)(<br>|<\/P>)/g, output : '<i>#$1</i>$2' } // comments
  19. ]
  20.  
  21. Language.snippets = []
  22.  
  23. Language.complete = [
  24.         { input : '\'',output : '\'$0\'' },
  25.         { input : '"', output : '"$0"' },
  26.         { input : '(', output : '\($0\)' },
  27.         { input : '[', output : '\[$0\]' },
  28.         { input : '{', output : '{\n\t$0\n}' }         
  29. ]
  30.  
  31. Language.shortcuts = []
  32.  
  33.  
  34.  
  35. /*
  36.  * CodePress regular expressions for Java syntax highlighting
  37.  */
  38.  
  39. // Java
  40. Language.syntax = [
  41.         { input : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>'}, // strings double quote
  42.         { input : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<s>\'$1$2</s>'}, // strings single quote
  43.         { input : /\b(abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/g, output : '<b>$1</b>'}, // reserved words
  44.         { input : /([^:]|^)\/\/(.*?)(<br|<\/P)/g, output : '$1<i>//$2</i>$3'}, // comments //  
  45.         { input : /\/\*(.*?)\*\//g, output : '<i>/*$1*/</i>' }// comments /* */
  46. ]
  47.  
  48. Language.snippets = []
  49.  
  50. Language.complete = [
  51.         { input : '\'',output : '\'$0\'' },
  52.         { input : '"', output : '"$0"' },
  53.         { input : '(', output : '\($0\)' },
  54.         { input : '[', output : '\[$0\]' },
  55.         { input : '{', output : '{\n\t$0\n}' }         
  56. ]
  57.  
  58. Language.shortcuts = []
  59.  
  60.  
  61.  
  62. /*
  63.  * CodePress color styles for PHP syntax highlighting
  64.  */
  65.  
  66. b {color:#000080;} /* tags */
  67. big, big b, big em, big ins, big s, strong i, strong i b, strong i s, strong i u, strong i a, strong i a u, strong i s u {color:gray;font-weight:normal;} /* comments */
  68. s, s b, strong s u, strong s cite {color:#5656fa;font-weight:normal;} /* attributes and strings */
  69. strong a, strong a u {color:#006700;font-weight:bold;} /* variables */
  70. em {color:#800080;font-style:normal;} /* style */
  71. ins {color:#800000;} /* script */
  72. strong u {color:#7F0055;font-weight:bold;} /* reserved words */
  73. cite, s cite {color:red;font-weight:bold;} /* <?php and ?> */
  74.  
  75.  

回复 "在线文本编辑器 自动根据编程语言高亮 ajax版"

这儿你可以回复上面这条便签

captcha