haml.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. false,
  23. {
  24. relevance: 0
  25. }
  26. ),
  27. {
  28. begin: '^\\s*(-|=|!=)(?!#)',
  29. starts: {
  30. end: '\\n',
  31. subLanguage: 'ruby'
  32. }
  33. },
  34. {
  35. className: 'tag',
  36. begin: '^\\s*%',
  37. contains: [
  38. {
  39. className: 'selector-tag',
  40. begin: '\\w+'
  41. },
  42. {
  43. className: 'selector-id',
  44. begin: '#[\\w-]+'
  45. },
  46. {
  47. className: 'selector-class',
  48. begin: '\\.[\\w-]+'
  49. },
  50. {
  51. begin: /\{\s*/,
  52. end: /\s*\}/,
  53. contains: [
  54. {
  55. begin: ':\\w+\\s*=>',
  56. end: ',\\s+',
  57. returnBegin: true,
  58. endsWithParent: true,
  59. contains: [
  60. {
  61. className: 'attr',
  62. begin: ':\\w+'
  63. },
  64. hljs.APOS_STRING_MODE,
  65. hljs.QUOTE_STRING_MODE,
  66. {
  67. begin: '\\w+',
  68. relevance: 0
  69. }
  70. ]
  71. }
  72. ]
  73. },
  74. {
  75. begin: '\\(\\s*',
  76. end: '\\s*\\)',
  77. excludeEnd: true,
  78. contains: [
  79. {
  80. begin: '\\w+\\s*=',
  81. end: '\\s+',
  82. returnBegin: true,
  83. endsWithParent: true,
  84. contains: [
  85. {
  86. className: 'attr',
  87. begin: '\\w+',
  88. relevance: 0
  89. },
  90. hljs.APOS_STRING_MODE,
  91. hljs.QUOTE_STRING_MODE,
  92. {
  93. begin: '\\w+',
  94. relevance: 0
  95. }
  96. ]
  97. }
  98. ]
  99. }
  100. ]
  101. },
  102. {
  103. begin: '^\\s*[=~]\\s*'
  104. },
  105. {
  106. begin: /#\{/,
  107. starts: {
  108. end: /\}/,
  109. subLanguage: 'ruby'
  110. }
  111. }
  112. ]
  113. };
  114. }
  115. module.exports = haml;