haml.js 2.5 KB

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