shBrushCSharp.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 as base bool break byte case catch char checked class const ' +
  24. 'continue decimal default delegate do double else enum event explicit ' +
  25. 'extern false finally fixed float for foreach get goto if implicit in int ' +
  26. 'interface internal is lock long namespace new null object operator out ' +
  27. 'override params private protected public readonly ref return sbyte sealed set ' +
  28. 'short sizeof stackalloc static string struct switch this throw true try ' +
  29. 'typeof uint ulong unchecked unsafe ushort using virtual void while';
  30. function fixComments(match, regexInfo)
  31. {
  32. var css = (match[0].indexOf("///") == 0)
  33. ? 'color1'
  34. : 'comments'
  35. ;
  36. return [new SyntaxHighlighter.Match(match[0], match.index, css)];
  37. }
  38. this.regexList = [
  39. { regex: SyntaxHighlighter.regexLib.singleLineCComments, func : fixComments }, // one line comments
  40. { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
  41. { regex: /@"(?:[^"]|"")*"/g, css: 'string' }, // @-quoted strings
  42. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
  43. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
  44. { regex: /^\s*#.*/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion
  45. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // c# keyword
  46. { regex: /\bpartial(?=\s+(?:class|interface|struct)\b)/g, css: 'keyword' }, // contextual keyword: 'partial'
  47. { regex: /\byield(?=\s+(?:return|break)\b)/g, css: 'keyword' } // contextual keyword: 'yield'
  48. ];
  49. this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
  50. };
  51. Brush.prototype = new SyntaxHighlighter.Highlighter();
  52. Brush.aliases = ['c#', 'c-sharp', 'csharp'];
  53. SyntaxHighlighter.brushes.CSharp = Brush;
  54. // CommonJS
  55. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  56. })();