/samples/scalate-sample-sitegen/src/highlight/languages/django.js

http://github.com/scalate/scalate · JavaScript · 61 lines · 56 code · 1 blank · 4 comment · 0 complexity · bff5fd21ed4dafb0c37d6388dbeb9315 MD5 · raw file

  1. /*
  2. Language: Django
  3. Requires: html-xml.js
  4. */
  5. hljs.LANGUAGES.django = {
  6. defaultMode: {
  7. contains: ['tag', 'comment', 'doctype', 'template_comment', 'template_tag', 'variable']
  8. },
  9. case_insensitive: true,
  10. modes: [
  11. hljs.XML_COMMENT,
  12. hljs.HTML_DOCTYPE,
  13. {
  14. className: 'tag',
  15. lexems: [hljs.IDENT_RE],
  16. keywords: hljs.HTML_TAGS,
  17. begin: '<[A-Za-z/]', end: '>',
  18. contains: ['attribute', 'template_comment', 'template_tag', 'variable']
  19. },
  20. hljs.HTML_ATTR,
  21. hljs.HTML_SHORT_ATTR,
  22. {
  23. className: 'value',
  24. begin: '"', end: '"',
  25. contains: ['template_comment', 'template_tag', 'variable']
  26. },
  27. hljs.HTML_VALUE,
  28. {
  29. className: 'template_comment',
  30. begin: '\\{\\%\\s*comment\\s*\\%\\}', end: '\\{\\%\\s*endcomment\\s*\\%\\}'
  31. },
  32. {
  33. className: 'template_comment',
  34. begin: '\\{#', end: '#\\}'
  35. },
  36. {
  37. className: 'template_tag',
  38. begin: '\\{\\%', end: '\\%\\}',
  39. lexems: [hljs.IDENT_RE],
  40. keywords: {'comment': 1, 'endcomment': 1, 'load': 1, 'templatetag': 1, 'ifchanged': 1, 'endifchanged': 1, 'if': 1, 'endif': 1, 'firstof': 1, 'for': 1, 'endfor': 1, 'in': 1, 'ifnotequal': 1, 'endifnotequal': 1, 'widthratio': 1, 'extends': 1, 'include': 1, 'spaceless': 1, 'endspaceless': 1, 'regroup': 1, 'by': 1, 'as': 1, 'ifequal': 1, 'endifequal': 1, 'ssi': 1, 'now': 1, 'with': 1, 'cycle': 1, 'url': 1, 'filter': 1, 'endfilter': 1, 'debug': 1, 'block': 1, 'endblock': 1, 'else': 1},
  41. contains: ['filter']
  42. },
  43. {
  44. className: 'variable',
  45. begin: '\\{\\{', end: '\\}\\}',
  46. contains: ['filter']
  47. },
  48. {
  49. className: 'filter',
  50. begin: '\\|[A-Za-z]+\\:?', end: '^', excludeEnd: true,
  51. lexems: [hljs.IDENT_RE],
  52. keywords: {'truncatewords': 1, 'removetags': 1, 'linebreaksbr': 1, 'yesno': 1, 'get_digit': 1, 'timesince': 1, 'random': 1, 'striptags': 1, 'filesizeformat': 1, 'escape': 1, 'linebreaks': 1, 'length_is': 1, 'ljust': 1, 'rjust': 1, 'cut': 1, 'urlize': 1, 'fix_ampersands': 1, 'title': 1, 'floatformat': 1, 'capfirst': 1, 'pprint': 1, 'divisibleby': 1, 'add': 1, 'make_list': 1, 'unordered_list': 1, 'urlencode': 1, 'timeuntil': 1, 'urlizetrunc': 1, 'wordcount': 1, 'stringformat': 1, 'linenumbers': 1, 'slice': 1, 'date': 1, 'dictsort': 1, 'dictsortreversed': 1, 'default_if_none': 1, 'pluralize': 1, 'lower': 1, 'join': 1, 'center': 1, 'default': 1, 'truncatewords_html': 1, 'upper': 1, 'length': 1, 'phone2numeric': 1, 'wordwrap': 1, 'time': 1, 'addslashes': 1, 'slugify': 1, 'first': 1},
  53. contains: ['argument']
  54. },
  55. {
  56. className: 'argument',
  57. begin: '"', end: '"'
  58. }
  59. ]
  60. };