PageRenderTime 128ms CodeModel.GetById 117ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/samples/scalate-presentation/src/highlight/languages/html-xml.js

http://github.com/scalate/scalate
JavaScript | 140 lines | 131 code | 6 blank | 3 comment | 0 complexity | d4098de5b75de96bc9ead1280aac597d MD5 | raw file
  1/*
  2Language: HTML, XML
  3*/
  4
  5hljs.XML_COMMENT = {
  6  className: 'comment',
  7  begin: '<!--', end: '-->'
  8};
  9hljs.XML_ATTR = {
 10  className: 'attribute',
 11  begin: '\\s[A-Za-z0-9\\._:-]+=', end: '^',
 12  contains: ['value']
 13};
 14hljs.XML_VALUE_QUOT = {
 15  className: 'value',
 16  begin: '"', end: '"'
 17};
 18hljs.XML_VALUE_APOS = {
 19  className: 'value',
 20  begin: '\'', end: '\''
 21};
 22
 23
 24hljs.LANGUAGES.xml = {
 25  defaultMode: {
 26    contains: ['pi', 'comment', 'cdata', 'tag']
 27  },
 28  case_insensitive: true,
 29  modes: [
 30    {
 31      className: 'pi',
 32      begin: '<\\?', end: '\\?>',
 33      relevance: 10
 34    },
 35    hljs.XML_COMMENT,
 36    {
 37      className: 'cdata',
 38      begin: '<\\!\\[CDATA\\[', end: '\\]\\]>'
 39    },
 40    {
 41      className: 'tag',
 42      begin: '</?', end: '>',
 43      contains: ['title', 'tag_internal'],
 44      relevance: 1.5
 45    },
 46    {
 47      className: 'title',
 48      begin: '[A-Za-z0-9\\._:-]+', end: '^',
 49      relevance: 0
 50    },
 51    {
 52      className: 'tag_internal',
 53      begin: '^', endsWithParent: true, noMarkup: true,
 54      contains: ['attribute'],
 55      relevance: 0,
 56      illegal: '[\\+\\.]'
 57    },
 58    hljs.XML_ATTR,
 59    hljs.XML_VALUE_QUOT,
 60    hljs.XML_VALUE_APOS
 61  ]
 62};
 63
 64hljs.HTML_TAGS = {'code': 1, 'kbd': 1, 'font': 1, 'noscript': 1, 'style': 1, 'img': 1, 'title': 1, 'menu': 1, 'tt': 1, 'tr': 1, 'param': 1, 'li': 1, 'tfoot': 1, 'th': 1, 'input': 1, 'td': 1, 'dl': 1, 'blockquote': 1, 'fieldset': 1, 'big': 1, 'dd': 1, 'abbr': 1, 'optgroup': 1, 'dt': 1, 'button': 1, 'isindex': 1, 'p': 1, 'small': 1, 'div': 1, 'dir': 1, 'em': 1, 'frame': 1, 'meta': 1, 'sub': 1, 'bdo': 1, 'label': 1, 'acronym': 1, 'sup': 1, 'body': 1, 'xml': 1, 'basefont': 1, 'base': 1, 'br': 1, 'address': 1, 'strong': 1, 'legend': 1, 'ol': 1, 'script': 1, 'caption': 1, 's': 1, 'col': 1, 'h2': 1, 'h3': 1, 'h1': 1, 'h6': 1, 'h4': 1, 'h5': 1, 'table': 1, 'select': 1, 'noframes': 1, 'span': 1, 'area': 1, 'dfn': 1, 'strike': 1, 'cite': 1, 'thead': 1, 'head': 1, 'option': 1, 'form': 1, 'hr': 1, 'var': 1, 'link': 1, 'b': 1, 'colgroup': 1, 'ul': 1, 'applet': 1, 'del': 1, 'iframe': 1, 'pre': 1, 'frameset': 1, 'ins': 1, 'tbody': 1, 'html': 1, 'samp': 1, 'map': 1, 'object': 1, 'a': 1, 'xmlns': 1, 'center': 1, 'textarea': 1, 'i': 1, 'q': 1, 'u': 1};
 65hljs.HTML_DOCTYPE = {
 66  className: 'doctype',
 67  begin: '<!DOCTYPE', end: '>',
 68  relevance: 10
 69};
 70hljs.HTML_ATTR = {
 71  className: 'attribute',
 72  begin: '\\s[a-zA-Z\\:_-]+=', end: '^',
 73  contains: ['value']
 74};
 75hljs.HTML_SHORT_ATTR = {
 76  className: 'attribute',
 77  begin: ' [a-zA-Z]+', end: '^'
 78};
 79hljs.HTML_VALUE = {
 80  className: 'value',
 81  begin: '[a-zA-Z0-9]+', end: '^'
 82};
 83
 84hljs.LANGUAGES.html = {
 85  defaultMode: {
 86    contains: ['tag', 'comment', 'doctype', 'vbscript']
 87  },
 88  case_insensitive: true,
 89  modes: [
 90    hljs.XML_COMMENT,
 91    hljs.HTML_DOCTYPE,
 92    {
 93      className: 'tag',
 94      lexems: [hljs.IDENT_RE],
 95      keywords: hljs.HTML_TAGS,
 96      begin: '<style', end: '>',
 97      contains: ['attribute'],
 98      illegal: '[\\+\\.]',
 99      starts: 'css'
100    },
101    {
102      className: 'tag',
103      lexems: [hljs.IDENT_RE],
104      keywords: hljs.HTML_TAGS,
105      begin: '<script', end: '>',
106      contains: ['attribute'],
107      illegal: '[\\+\\.]',
108      starts: 'javascript'
109    },
110    {
111      className: 'tag',
112      lexems: [hljs.IDENT_RE],
113      keywords: hljs.HTML_TAGS,
114      begin: '<[A-Za-z/]', end: '>',
115      contains: ['attribute'],
116      illegal: '[\\+\\.]'
117    },
118    {
119      className: 'css',
120      end: '</style>', returnEnd: true,
121      subLanguage: 'css'
122    },
123    {
124      className: 'javascript',
125      end: '</script>', returnEnd: true,
126      subLanguage: 'javascript'
127    },
128    hljs.HTML_ATTR,
129    hljs.HTML_SHORT_ATTR,
130    hljs.XML_VALUE_QUOT,
131    hljs.XML_VALUE_APOS,
132    hljs.HTML_VALUE,
133    {
134      className: 'vbscript',
135      begin: '<%', end: '%>',
136      subLanguage: 'vbscript'
137    }
138  ]
139};
140