ultimix
shBrushXml.js
Go to the documentation of this file.
1 
30 SyntaxHighlighter.brushes.Xml = function()
31 {
32  function process(match, regexInfo)
33  {
34  var constructor = SyntaxHighlighter.Match,
35  code = match[0],
36  tag = new XRegExp('(&lt;|<)[\\s\\/\\?]*(?<name>[:\\w-\\.]+)', 'xg').exec(code),
37  result = []
38  ;
39 
40  if (match.attributes != null)
41  {
42  var attributes,
43  regex = new XRegExp('(?<name> [\\w:\\-\\.]+)' +
44  '\\s*=\\s*' +
45  '(?<value> ".*?"|\'.*?\'|\\w+)',
46  'xg');
47 
48  while ((attributes = regex.exec(code)) != null)
49  {
50  result.push(new constructor(attributes.name, match.index + attributes.index, 'color1'));
51  result.push(new constructor(attributes.value, match.index + attributes.index + attributes[0].indexOf(attributes.value), 'string'));
52  }
53  }
54 
55  if (tag != null)
56  result.push(
57  new constructor(tag.name, match.index + tag[0].indexOf(tag.name), 'keyword')
58  );
59 
60  return result;
61  }
62 
63  this.regexList = [
64  { regex: new XRegExp('(\\&lt;|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\\&gt;|>)', 'gm'), css: 'color2' }, // <![ ... [ ... ]]>
65  { regex: new XRegExp('(\\&lt;|<)!--\\s*.*?\\s*--(\\&gt;|>)', 'gm'), css: 'comments' }, // <!-- ... -->
66  { regex: new XRegExp('(&lt;|<)[\\s\\/\\?]*(\\w+)(?<attributes>.*?)[\\s\\/\\?]*(&gt;|>)', 'sg'), func: process }
67  ];
68 };
69 
70 SyntaxHighlighter.brushes.Xml.prototype = new SyntaxHighlighter.Highlighter();
71 SyntaxHighlighter.brushes.Xml.aliases = ['xml', 'xhtml', 'xslt', 'html', 'xhtml'];