shBrushXml.js 1.8 KB

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