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