js.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. ===============================================================================
  3. Chili is the jQuery code highlighter plugin
  4. ...............................................................................
  5. LICENSE: http://www.opensource.org/licenses/mit-license.php
  6. WEBSITE: http://noteslog.com/chili/
  7. Copyright 2008 / Andrea Ercolino
  8. ===============================================================================
  9. */
  10. {
  11. _name: 'js'
  12. , _case: true
  13. , _main: {
  14. ml_comment: {
  15. _match: /\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\//
  16. , _style: 'color: gray;'
  17. }
  18. , sl_comment: {
  19. _match: /\/\/.*/
  20. , _style: 'color: green;'
  21. }
  22. , string: {
  23. _match: /(?:\'[^\'\\\n]*(?:\\.[^\'\\\n]*)*\')|(?:\"[^\"\\\n]*(?:\\.[^\"\\\n]*)*\")/
  24. , _style: 'color: teal;'
  25. }
  26. , num: {
  27. _match: /\b[+-]?(?:\d*\.?\d+|\d+\.?\d*)(?:[eE][+-]?\d+)?\b/
  28. , _style: 'color: red;'
  29. }
  30. , reg_not: { //this prevents "a / b / c" to be interpreted as a reg_exp
  31. _match: /(?:\w+\s*)\/[^\/\\\n]*(?:\\.[^\/\\\n]*)*\/[gim]*(?:\s*\w+)/
  32. , _replace: function( all ) {
  33. return this.x( all, '//num' );
  34. }
  35. }
  36. , reg_exp: {
  37. _match: /\/[^\/\\\n]*(?:\\.[^\/\\\n]*)*\/[gim]*/
  38. , _style: 'color: maroon;'
  39. }
  40. , brace: {
  41. _match: /[\{\}]/
  42. , _style: 'color: red; font-weight: bold;'
  43. }
  44. , statement: {
  45. _match: /\b(with|while|var|try|throw|switch|return|if|for|finally|else|do|default|continue|const|catch|case|break)\b/
  46. , _style: 'color: navy; font-weight: bold;'
  47. }
  48. , error: {
  49. _match: /\b(URIError|TypeError|SyntaxError|ReferenceError|RangeError|EvalError|Error)\b/
  50. , _style: 'color: Coral;'
  51. }
  52. , object: {
  53. _match: /\b(String|RegExp|Object|Number|Math|Function|Date|Boolean|Array)\b/
  54. , _style: 'color: DeepPink;'
  55. }
  56. , property: {
  57. _match: /\b(undefined|arguments|NaN|Infinity)\b/
  58. , _style: 'color: Purple; font-weight: bold;'
  59. }
  60. , 'function': {
  61. _match: /\b(parseInt|parseFloat|isNaN|isFinite|eval|encodeURIComponent|encodeURI|decodeURIComponent|decodeURI)\b/
  62. , _style: 'color: olive;'
  63. }
  64. , operator: {
  65. _match: /\b(void|typeof|this|new|instanceof|in|function|delete)\b/
  66. , _style: 'color: RoyalBlue; font-weight: bold;'
  67. }
  68. , liveconnect: {
  69. _match: /\b(sun|netscape|java|Packages|JavaPackage|JavaObject|JavaClass|JavaArray|JSObject|JSException)\b/
  70. , _style: 'text-decoration: overline;'
  71. }
  72. }
  73. }