/wp-content/plugins/syntaxhighlighter/syntaxhighlighter3/scripts/shBrushHaskell.js

https://github.com/livinglab/openlab · JavaScript · 38 lines · 27 code · 6 blank · 5 comment · 3 complexity · a6268429826ecb1997869938bac9cc11 MD5 · raw file

  1. /**
  2. * Haskell Brushes for SyntaxHighlighter 3.0
  3. */
  4. (function () {
  5. // CommonJS
  6. SyntaxHighlighter = SyntaxHighlighter || (typeof require !== 'undefined'? require('shCore').SyntaxHighlighter : null);
  7. function Brush() {
  8. var keywords = 'as case of class data default deriving do forall foreign hiding ' +
  9. 'if then else import instance let in mdo module newtype qualified type where';
  10. this.regexList = [
  11. { regex: /{-#[\s\S]*?#-}/g, css: 'preprocessor' },
  12. { regex: /--.*/g, css: 'comments' }, // one line comments
  13. { regex: /{-(?!\$)[\s\S]*?-}/gm, css: 'comments' }, // multiline comments
  14. { regex: /'.'/g, css: 'string' }, // chars
  15. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
  16. { regex: /(-|!|#|\$|%|&|\*|\+|\/|<|=|>|\?|@|\^|\||~|:|\.|\\)+/g, css: 'keyword bold' },
  17. { regex: /`[a-z][a-z0-9_']*`/g, css: 'keyword bold' }, // infix operators
  18. { regex: /\b(\d+|0x[0-9a-f]+)\b/gi, css: 'value' }, // integer
  19. { regex: /\b\d+(\.\d*)?([eE][+-]?\d+)?\b/gi, css: 'value' }, // floating number
  20. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword bold' }
  21. ];
  22. this.forHtmlScript({
  23. left : /(&lt;|<)%[@!=]?/g,
  24. right : /%(&gt;|>)/g
  25. });
  26. }
  27. Brush.prototype = new SyntaxHighlighter.Highlighter();
  28. Brush.aliases = ['haskell'];
  29. SyntaxHighlighter.brushes.Haskell = Brush;
  30. // CommonJS
  31. typeof exports != 'undefined' ? (exports.Brush = Brush) : null;
  32. })();