shBrushRuby.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. // Contributed by Erik Peterson.
  24. var keywords = 'alias and BEGIN begin break case class def define_method defined do each else elsif ' +
  25. 'END end ensure false for if in module new next nil not or raise redo rescue retry return ' +
  26. 'self super then throw true undef unless until when while yield';
  27. var builtins = 'Array Bignum Binding Class Continuation Dir Exception FalseClass File::Stat File Fixnum Fload ' +
  28. 'Hash Integer IO MatchData Method Module NilClass Numeric Object Proc Range Regexp String Struct::TMS Symbol ' +
  29. 'ThreadGroup Thread Time TrueClass';
  30. this.regexList = [
  31. { regex: SyntaxHighlighter.regexLib.singleLinePerlComments, css: 'comments' }, // one line comments
  32. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
  33. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
  34. { regex: /\b[A-Z0-9_]+\b/g, css: 'constants' }, // constants
  35. { regex: /:[a-z][A-Za-z0-9_]*/g, css: 'color2' }, // symbols
  36. { regex: /(\$|@@|@)\w+/g, css: 'variable bold' }, // $global, @instance, and @@class variables
  37. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keywords
  38. { regex: new RegExp(this.getKeywords(builtins), 'gm'), css: 'color1' } // builtins
  39. ];
  40. this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
  41. };
  42. Brush.prototype = new SyntaxHighlighter.Highlighter();
  43. Brush.aliases = ['ruby', 'rails', 'ror', 'rb'];
  44. SyntaxHighlighter.brushes.Ruby = Brush;
  45. // CommonJS
  46. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  47. })();