haml.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. Language: HAML
  3. Requires: ruby.js
  4. Author: Dan Allen <dan.j.allen@gmail.com>
  5. Website: http://haml.info
  6. Category: template
  7. */
  8. // TODO support filter tags like :javascript, support inline HTML
  9. function haml(hljs) {
  10. return {
  11. name: 'HAML',
  12. case_insensitive: true,
  13. contains: [
  14. {
  15. className: 'meta',
  16. begin: '^!!!( (5|1\\.1|Strict|Frameset|Basic|Mobile|RDFa|XML\\b.*))?$',
  17. relevance: 10
  18. },
  19. // FIXME these comments should be allowed to span indented lines
  20. hljs.COMMENT(
  21. '^\\s*(!=#|=#|-#|/).*$',
  22. null,
  23. { relevance: 0 }
  24. ),
  25. {
  26. begin: '^\\s*(-|=|!=)(?!#)',
  27. end: /$/,
  28. subLanguage: 'ruby',
  29. excludeBegin: true,
  30. excludeEnd: true
  31. },
  32. {
  33. className: 'tag',
  34. begin: '^\\s*%',
  35. contains: [
  36. {
  37. className: 'selector-tag',
  38. begin: '\\w+'
  39. },
  40. {
  41. className: 'selector-id',
  42. begin: '#[\\w-]+'
  43. },
  44. {
  45. className: 'selector-class',
  46. begin: '\\.[\\w-]+'
  47. },
  48. {
  49. begin: /\{\s*/,
  50. end: /\s*\}/,
  51. contains: [
  52. {
  53. begin: ':\\w+\\s*=>',
  54. end: ',\\s+',
  55. returnBegin: true,
  56. endsWithParent: true,
  57. contains: [
  58. {
  59. className: 'attr',
  60. begin: ':\\w+'
  61. },
  62. hljs.APOS_STRING_MODE,
  63. hljs.QUOTE_STRING_MODE,
  64. {
  65. begin: '\\w+',
  66. relevance: 0
  67. }
  68. ]
  69. }
  70. ]
  71. },
  72. {
  73. begin: '\\(\\s*',
  74. end: '\\s*\\)',
  75. excludeEnd: true,
  76. contains: [
  77. {
  78. begin: '\\w+\\s*=',
  79. end: '\\s+',
  80. returnBegin: true,
  81. endsWithParent: true,
  82. contains: [
  83. {
  84. className: 'attr',
  85. begin: '\\w+',
  86. relevance: 0
  87. },
  88. hljs.APOS_STRING_MODE,
  89. hljs.QUOTE_STRING_MODE,
  90. {
  91. begin: '\\w+',
  92. relevance: 0
  93. }
  94. ]
  95. }
  96. ]
  97. }
  98. ]
  99. },
  100. { begin: '^\\s*[=~]\\s*' },
  101. {
  102. begin: /#\{/,
  103. end: /\}/,
  104. subLanguage: 'ruby',
  105. excludeBegin: true,
  106. excludeEnd: true
  107. }
  108. ]
  109. };
  110. }
  111. export { haml as default };