PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/syntaxhighlighter_3.0.83/scripts/shBrushXml.js

#
JavaScript | 69 lines | 42 code | 9 blank | 18 comment | 8 complexity | ba290ac0111d2c3f8e1ce36fbaf6a239 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, BSD-3-Clause
  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. function process(match, regexInfo)
  24. {
  25. var constructor = SyntaxHighlighter.Match,
  26. code = match[0],
  27. tag = new XRegExp('(&lt;|<)[\\s\\/\\?]*(?<name>[:\\w-\\.]+)', 'xg').exec(code),
  28. result = []
  29. ;
  30. if (match.attributes != null)
  31. {
  32. var attributes,
  33. regex = new XRegExp('(?<name> [\\w:\\-\\.]+)' +
  34. '\\s*=\\s*' +
  35. '(?<value> ".*?"|\'.*?\'|\\w+)',
  36. 'xg');
  37. while ((attributes = regex.exec(code)) != null)
  38. {
  39. result.push(new constructor(attributes.name, match.index + attributes.index, 'color1'));
  40. result.push(new constructor(attributes.value, match.index + attributes.index + attributes[0].indexOf(attributes.value), 'string'));
  41. }
  42. }
  43. if (tag != null)
  44. result.push(
  45. new constructor(tag.name, match.index + tag[0].indexOf(tag.name), 'keyword')
  46. );
  47. return result;
  48. }
  49. this.regexList = [
  50. { regex: new XRegExp('(\\&lt;|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\\&gt;|>)', 'gm'), css: 'color2' }, // <![ ... [ ... ]]>
  51. { regex: SyntaxHighlighter.regexLib.xmlComments, css: 'comments' }, // <!-- ... -->
  52. { regex: new XRegExp('(&lt;|<)[\\s\\/\\?]*(\\w+)(?<attributes>.*?)[\\s\\/\\?]*(&gt;|>)', 'sg'), func: process }
  53. ];
  54. };
  55. Brush.prototype = new SyntaxHighlighter.Highlighter();
  56. Brush.aliases = ['xml', 'xhtml', 'xslt', 'html'];
  57. SyntaxHighlighter.brushes.Xml = Brush;
  58. // CommonJS
  59. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  60. })();