summaryrefslogtreecommitdiff
path: root/data/language-specs/html.lang
blob: e069a7cfc70075b976db2480040e123ffecd72c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<?xml version="1.0" encoding="UTF-8"?>
<!--

 This file is part of GtkSourceView

 Copyright (C) 2005-2007 - Marco Barisione <barisione@gmail.com>
 Copyright (C) 2005-2007 - Emanuele Aina
 Copyright (C) 2014 - Sébastien Wilmet <swilmet@gnome.org>
 Copyright (C) 2018 - Jeffery To <jeffery.to@gmail.com>

 GtkSourceView is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 GtkSourceView is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public License
 along with this library; if not, see <http://www.gnu.org/licenses/>.

-->
<language id="html" name="HTML" version="2.0" _section="Markup">
  <metadata>
    <property name="mimetypes">text/html</property>
    <property name="globs">*.html;*.htm</property>
    <property name="block-comment-start">&lt;!--</property>
    <property name="block-comment-end">--&gt;</property>
    <property name="suggested-suffix">.html</property>
  </metadata>

  <styles>
    <style id="comment" name="Comment" map-to="xml:comment"/>
    <style id="tag" name="Tag" map-to="xml:element-name"/>
    <style id="attrib-name" name="Attribute Name" map-to="xml:attribute-name"/>
    <style id="attrib-value" name="Attribute Value" map-to="xml:attribute-value"/>
    <style id="dtd" name="DTD" map-to="xml:doctype"/>
    <style id="error" name="Error" map-to="xml:error"/>
    <style id="title" name="Page title" map-to="def:heading0"/>
    <style id="h1" name="Heading level 1" map-to="def:heading1"/>
    <style id="h2" name="Heading level 2" map-to="def:heading2"/>
    <style id="h3" name="Heading level 3" map-to="def:heading3"/>
    <style id="h4" name="Heading level 4" map-to="def:heading4"/>
    <style id="h5" name="Heading level 5" map-to="def:heading5"/>
    <style id="h6" name="Heading level 6" map-to="def:heading6"/>
  </styles>

  <default-regex-options case-sensitive="false"/>

  <definitions>
    <!-- Html comments are more permissive than xml comments -->
    <context id="comment" style-ref="comment" class="comment">
      <start>&lt;!--</start>
      <end>--&gt;</end>
      <include>
        <context ref="def:in-comment"/>
      </include>
    </context>

    <context id="dtd" style-ref="dtd" class="no-spell-check">
      <start>&lt;!</start>
      <end>&gt;</end>
    </context>

    <!-- This is a placeholder context intended to be <replace>d
         in languages like PHP that need to embed contexts inside
         HTML tags and attributes.
    -->
    <context id="embedded-lang-hook">
      <match>\%{def:never-match}</match>
    </context>

    <!-- This one is for languages such as Markdown and MediaWiki
         in which HTML tags can be included. Their syntax will be
         recognized in text nodes, but not in attribute values.
    -->
    <context id="embedded-lang-hook-content">
      <match>\%{def:never-match}</match>
    </context>

    <context id="heading-element-content" style-inside="true" end-parent="true" class-disabled="no-spell-check">
      <start>&gt;</start>
      <end>&lt;/h[1-6]\s*&gt;</end>
      <include>
        <context sub-pattern="0" where="start" style-ref="tag"/>
        <context sub-pattern="0" where="end" style-ref="tag"/>
        <context ref="embedded-lang-hook"/>
        <context ref="embedded-lang-hook-content"/>
        <context extend-parent="false">
          <start>\%{def:always-match}</start>
          <include>
            <context ref="html"/>
          </include>
        </context>
      </include>
    </context>

    <context id="headings">
      <include>
        <!-- Inside <title> tags, no other tags are recognized. -->
        <context id="title" class="no-spell-check">
          <start>&lt;title\%]</start>
          <include>
            <context sub-pattern="0" where="start" style-ref="tag"/>
            <context ref="generic-tag"/>

            <context style-inside="true" style-ref="title" end-parent="true" class-disabled="no-spell-check">
              <start>&gt;</start>
              <end>&lt;/title\s*&gt;</end>
              <include>
                <context sub-pattern="0" where="start" style-ref="tag"/>
                <context sub-pattern="0" where="end" style-ref="tag"/>
                <context ref="xml:entity"/>
                <context ref="embedded-lang-hook"/>
                <context ref="embedded-lang-hook-content"/>
              </include>
            </context>
          </include>
        </context>

        <context id="h1" class="no-spell-check">
          <start>&lt;h1\%]</start>
          <include>
            <context sub-pattern="0" where="start" style-ref="tag"/>
            <context ref="generic-tag"/>
            <context ref="heading-element-content" style-ref="h1"/>
          </include>
        </context>

        <context id="h2" class="no-spell-check">
          <start>&lt;h2\%]</start>
          <include>
            <context sub-pattern="0" where="start" style-ref="tag"/>
            <context ref="generic-tag"/>
            <context ref="heading-element-content" style-ref="h2"/>
          </include>
        </context>

        <context id="h3" class="no-spell-check">
          <start>&lt;h3\%]</start>
          <include>
            <context sub-pattern="0" where="start" style-ref="tag"/>
            <context ref="generic-tag"/>
            <context ref="heading-element-content" style-ref="h3"/>
          </include>
        </context>

        <context id="h4" class="no-spell-check">
          <start>&lt;h4\%]</start>
          <include>
            <context sub-pattern="0" where="start" style-ref="tag"/>
            <context ref="generic-tag"/>
            <context ref="heading-element-content" style-ref="h4"/>
          </include>
        </context>

        <context id="h5" class="no-spell-check">
          <start>&lt;h5\%]</start>
          <include>
            <context sub-pattern="0" where="start" style-ref="tag"/>
            <context ref="generic-tag"/>
            <context ref="heading-element-content" style-ref="h5"/>
          </include>
        </context>

        <context id="h6" class="no-spell-check">
          <start>&lt;h6\%]</start>
          <include>
            <context sub-pattern="0" where="start" style-ref="tag"/>
            <context ref="generic-tag"/>
            <context ref="heading-element-content" style-ref="h6"/>
          </include>
        </context>
      </include>
    </context>

    <!-- See https://gitlab.gnome.org/GNOME/gtksourceview/commit/5385eb27720875bc144d54ccbd00d1613c41f7e0 -->
    <define-regex id="attribute-name">[^\N{U+00}\t\n\f\r "'/&lt;=&gt;\N{U+007F}-\N{U+009F}\N{U+FDD0}-\N{U+FDEF}\N{U+FFFE}\N{U+FFFF}\N{U+1FFFE}\N{U+1FFFF}\N{U+2FFFE}\N{U+2FFFF}\N{U+3FFFE}\N{U+3FFFF}\N{U+4FFFE}\N{U+4FFFF}\N{U+5FFFE}\N{U+5FFFF}\N{U+6FFFE}\N{U+6FFFF}\N{U+7FFFE}\N{U+7FFFF}\N{U+8FFFE}\N{U+8FFFF}\N{U+9FFFE}\N{U+9FFFF}\N{U+AFFFE}\N{U+AFFFF}\N{U+BFFFE}\N{U+BFFFF}\N{U+CFFFE}\N{U+CFFFF}\N{U+DFFFE}\N{U+DFFFF}\N{U+EFFFE}\N{U+EFFFF}\N{U+FFFFE}\N{U+FFFFF}\N{U+10FFFE}\N{U+10FFFF}]+</define-regex>

    <context id="generic-tag">
      <include>
        <!-- Attribute in the form: name="value" -->
        <context id="attrib-quoted" class="no-spell-check">
          <start>(\%{attribute-name}\s*=\s*)(\")</start>
          <include>
            <context sub-pattern="1" where="start" style-ref="attrib-name"/>
            <context sub-pattern="2" where="start" style-ref="attrib-value"/>
            <context id="string" end-parent="true" end-at-line-end="true" style-ref="attrib-value" class="string" class-disabled="no-spell-check">
              <start>\%{def:always-match}</start>
              <end>\"</end>
              <include>
                <context ref="xml:entity"/>
                <context ref="xml:character-reference"/>
                <context ref="embedded-lang-hook"/>
              </include>
            </context>
          </include>
        </context>

        <!-- Attribute in the form: name=value -->
        <context id="attrib-unquoted" style-ref="attrib-value" class="no-spell-check">
          <start>\%{attribute-name}\s*=\s*</start>
          <end>(?=&gt;|\s)</end>
          <include>
            <context sub-pattern="0" where="start" style-ref="attrib-name"/>
            <context ref="xml:entity"/>
            <context ref="xml:character-reference"/>
            <context ref="embedded-lang-hook"/>
          </include>
        </context>

        <!-- Attribute in the form: name -->
        <context id="attrib-no-value" style-ref="attrib-name" class="no-spell-check">
          <match>\%{attribute-name}</match>
        </context>

        <context ref="embedded-lang-hook"/>
      </include>
    </context>

    <context id="style" class="no-spell-check">
      <start>&lt;style\%]</start>
      <include>
        <context sub-pattern="0" where="start" style-ref="tag"/>
        <context ref="generic-tag"/>

        <context end-parent="true" style-ref="tag">
          <match>/&gt;</match>
        </context>

        <context id="style-code" end-parent="true">
          <start>&gt;</start>
          <end>&lt;/style\s*&gt;</end>
          <include>
            <context sub-pattern="0" where="start" style-ref="tag"/>
            <context sub-pattern="0" where="end" style-ref="tag"/>
            <context ref="css:css"/>
          </include>
        </context>
      </include>
    </context>

    <context id="css-embedded-lang-hook">
      <include>
        <context end-parent="true">
          <start>(?=&lt;/style(?:&gt;|\s|$))</start>
          <end>\%{def:always-match}</end>
        </context>
        <context ref="embedded-lang-hook"/>
        <context ref="css:embedded-lang-hook" original="true"/>
      </include>
    </context>

    <replace id="css:embedded-lang-hook" ref="css-embedded-lang-hook"/>

    <context id="script" class="no-spell-check">
      <start>&lt;script\%]</start>
      <include>
        <context sub-pattern="0" where="start" style-ref="tag"/>
        <context ref="generic-tag"/>

        <context end-parent="true" style-ref="tag">
          <match>/&gt;</match>
        </context>

        <context id="js-code" end-parent="true">
          <start>&gt;</start>
          <end>&lt;/script\s*&gt;</end>
          <include>
            <context sub-pattern="0" where="start" style-ref="tag"/>
            <context sub-pattern="0" where="end" style-ref="tag"/>
            <context ref="js:js"/>
          </include>
        </context>
      </include>
    </context>

    <context id="js-embedded-lang-hooks">
      <include>
        <context end-parent="true">
          <start>(?=&lt;/script(?:&gt;|\s|$))</start>
          <end>\%{def:always-match}</end>
        </context>
        <context ref="embedded-lang-hook"/>
        <context ref="js:embedded-lang-hooks" original="true"/>
      </include>
    </context>

    <replace id="js:embedded-lang-hooks" ref="js-embedded-lang-hooks"/>

    <context id="tag" class="no-spell-check">
      <!-- See https://gitlab.gnome.org/GNOME/gtksourceview/commit/5385eb27720875bc144d54ccbd00d1613c41f7e0 -->
      <start>&lt;/?[a-z][^\N{U+00}\t\n\f\r /&gt;\N{U+007F}-\N{U+009F}\N{U+FDD0}-\N{U+FDEF}\N{U+FFFE}\N{U+FFFF}\N{U+1FFFE}\N{U+1FFFF}\N{U+2FFFE}\N{U+2FFFF}\N{U+3FFFE}\N{U+3FFFF}\N{U+4FFFE}\N{U+4FFFF}\N{U+5FFFE}\N{U+5FFFF}\N{U+6FFFE}\N{U+6FFFF}\N{U+7FFFE}\N{U+7FFFF}\N{U+8FFFE}\N{U+8FFFF}\N{U+9FFFE}\N{U+9FFFF}\N{U+AFFFE}\N{U+AFFFF}\N{U+BFFFE}\N{U+BFFFF}\N{U+CFFFE}\N{U+CFFFF}\N{U+DFFFE}\N{U+DFFFF}\N{U+EFFFE}\N{U+EFFFF}\N{U+FFFFE}\N{U+FFFFF}\N{U+10FFFE}\N{U+10FFFF}]*</start>
      <end>/?&gt;</end>
      <include>
        <context sub-pattern="0" where="start" style-ref="tag"/>
        <context sub-pattern="0" where="end" style-ref="tag"/>
        <context ref="generic-tag"/>
      </include>
    </context>

    <context id="html">
      <include>
        <context ref="xml:doctype"/>
        <context ref="xml:entity"/>
        <context ref="xml:character-reference"/>
        <context ref="xml:cdata"/>
        <context ref="comment"/>
        <context ref="dtd"/>
        <context ref="headings"/>
        <context ref="style"/>
        <context ref="script"/>
        <context ref="tag"/>
      </include>
    </context>
  </definitions>
</language>