]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/html.yaml
Html syntax fixes #1008
[micro.git] / runtime / syntax / html.yaml
1 filetype: html
2
3 detect: 
4     filename: "\\.htm[l]?$"
5
6 rules:
7     # Doctype is case-insensitive
8     - preproc: "<!(?i)(DOCTYPE html.*)>"
9     # Opening tag
10     - symbol.tag:
11         start: "<(a|abbr|acronym|address|applet|area|article|aside|audio|b|base|bdi|bdo|big|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|dir|div|dl|dt|em|embed|fieldset|figcaption|figure|font|footer|form|frame|frameset|h[1-6]|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|s|samp|section|select|small|source|span|strike|strong|sub|summary|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|track|tt|u|ul|var|video|wbr)\\b"
12         end: ">"
13         rules:
14           - identifier: "\\b(placeholder|style|alt|bgcolor|height|href|id|(aria|data)\\-.+|label|longdesc|name|on(click|focus|load|mouseover)|size|span|src|target|type|value|width|class|charset|content|rel|integrity|crossorigin|for|onsubmit|lang|role)\\b"
15           - special: "\\b(required)\\b"
16           # Match double-quote strings
17           - constant.string:
18                 start: "\""
19                 end: "\""
20                 skip: "\\\\."
21                 rules:
22                   - constant.specialChar: "\\\\."
23                   - constant.string.url: "((ftp(s)?|http(s)?|git|chrome)://[^\\s]+)"
24           # Match single-quote strings
25           - constant.string:
26                 start: "'"
27                 end: "'"
28                 skip: "\\\\."
29                 rules:
30                   - constant.specialChar: "\\\\."
31                   - constant.string.url: "((ftp(s)?|http(s)?|git|chrome)://[^\\s]+)"
32           # Highlight the equals and any colon between words
33           - symbol: "\\b(=|:\\b)"
34
35     # Closing tag
36     - symbol.tag:
37         start: "</(a|abbr|acronym|address|applet|area|article|aside|audio|b|base|bdi|bdo|big|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|dir|div|dl|dt|em|embed|fieldset|figcaption|figure|font|footer|form|frame|frameset|h[1-6]|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|s|samp|section|select|small|source|span|strike|strong|sub|summary|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|track|tt|u|ul|var|video|wbr)\\b"
38         end: ">"
39         rules:
40           # Anything in the closing tag is an error
41           - error: "."
42
43     # Reserved entities like a&#12; &nbsp; and &#x12A;
44     - special: "(([a-zA-Z]&#[0-9]+|&[a-zA-Z]+|&#[a-zA-Z0-9]+);)"
45
46     # TODO: Add `limit-rules` to both the `default` rules below once it's implemented into Micro
47     - default:
48         start: "<script.*?>"
49         end: "</script.*?>"
50         limit-group: symbol.tag
51         rules:
52           - include: "javascript"
53
54     - default:
55         start: "<style.*>"
56         end: "</style.*>"
57         limit-group: symbol.tag
58         rules:
59           - include: "css"
60
61     # This weird empty comment thing is technically valid
62     - comment: "<!>"
63
64     - comment.block:
65         start: "<!\\-\\-"
66         end: "\\-\\->"
67         rules:
68           - todo: "(FIXME|NOTE|TODO):?"
69           # While technically not a "true" error, these are recommended to not be used inside a comment
70           - error: "(\\-\\-|>)"