UNPKG

2.71 kBJavaScriptView Raw
1/*
2Language: HAML
3Requires: ruby.js
4Author: Dan Allen <dan.j.allen@gmail.com>
5Website: http://haml.info
6Category: template
7*/
8
9// TODO support filter tags like :javascript, support inline HTML
10function 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 null,
24 { relevance: 0 }
25 ),
26 {
27 begin: '^\\s*(-|=|!=)(?!#)',
28 end: /$/,
29 subLanguage: 'ruby',
30 excludeBegin: true,
31 excludeEnd: true
32 },
33 {
34 className: 'tag',
35 begin: '^\\s*%',
36 contains: [
37 {
38 className: 'selector-tag',
39 begin: '\\w+'
40 },
41 {
42 className: 'selector-id',
43 begin: '#[\\w-]+'
44 },
45 {
46 className: 'selector-class',
47 begin: '\\.[\\w-]+'
48 },
49 {
50 begin: /\{\s*/,
51 end: /\s*\}/,
52 contains: [
53 {
54 begin: ':\\w+\\s*=>',
55 end: ',\\s+',
56 returnBegin: true,
57 endsWithParent: true,
58 contains: [
59 {
60 className: 'attr',
61 begin: ':\\w+'
62 },
63 hljs.APOS_STRING_MODE,
64 hljs.QUOTE_STRING_MODE,
65 {
66 begin: '\\w+',
67 relevance: 0
68 }
69 ]
70 }
71 ]
72 },
73 {
74 begin: '\\(\\s*',
75 end: '\\s*\\)',
76 excludeEnd: true,
77 contains: [
78 {
79 begin: '\\w+\\s*=',
80 end: '\\s+',
81 returnBegin: true,
82 endsWithParent: true,
83 contains: [
84 {
85 className: 'attr',
86 begin: '\\w+',
87 relevance: 0
88 },
89 hljs.APOS_STRING_MODE,
90 hljs.QUOTE_STRING_MODE,
91 {
92 begin: '\\w+',
93 relevance: 0
94 }
95 ]
96 }
97 ]
98 }
99 ]
100 },
101 {
102 begin: '^\\s*[=~]\\s*'
103 },
104 {
105 begin: /#\{/,
106 end: /\}/,
107 subLanguage: 'ruby',
108 excludeBegin: true,
109 excludeEnd: true
110 }
111 ]
112 };
113}
114
115export { haml as default };