shBrushJava.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * SyntaxHighlighter
  3. * http://alexgorbatchev.com/SyntaxHighlighter
  4. *
  5. * SyntaxHighlighter is donationware. If you are using it, please donate.
  6. * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
  7. *
  8. * @version
  9. * 3.0.83 (July 02 2010)
  10. *
  11. * @copyright
  12. * Copyright (C) 2004-2010 Alex Gorbatchev.
  13. *
  14. * @license
  15. * Dual licensed under the MIT and GPL licenses.
  16. */
  17. ;(function()
  18. {
  19. // CommonJS
  20. typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;
  21. function Brush()
  22. {
  23. var keywords = 'abstract assert boolean break byte case catch char class const ' +
  24. 'continue default do double else enum extends ' +
  25. 'false final finally float for goto if implements import ' +
  26. 'instanceof int interface long native new null ' +
  27. 'package private protected public return ' +
  28. 'short static strictfp super switch synchronized this throw throws true ' +
  29. 'transient try void volatile while';
  30. this.regexList = [
  31. { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
  32. { regex: /\/\*([^\*][\s\S]*)?\*\//gm, css: 'comments' }, // multiline comments
  33. { regex: /\/\*(?!\*\/)\*[\s\S]*?\*\//gm, css: 'preprocessor' }, // documentation comments
  34. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
  35. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
  36. { regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi, css: 'value' }, // numbers
  37. { regex: /(?!\@interface\b)\@[\$\w]+\b/g, css: 'color1' }, // annotation @anno
  38. { regex: /\@interface\b/g, css: 'color2' }, // @interface keyword
  39. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // java keyword
  40. ];
  41. this.forHtmlScript({
  42. left : /(&lt;|<)%[@!=]?/g,
  43. right : /%(&gt;|>)/g
  44. });
  45. };
  46. Brush.prototype = new SyntaxHighlighter.Highlighter();
  47. Brush.aliases = ['java'];
  48. SyntaxHighlighter.brushes.Java = Brush;
  49. // CommonJS
  50. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  51. })();