|
4 | 4 | (embedded_html |
5 | 5 | (angled_bracket_fenced_text) @injection.content |
6 | 6 | (#set! injection.language "html") |
| 7 | + (#set! injection.include-children "false") |
| 8 | + (#set! injection.combined "true") |
7 | 9 | ) |
8 | 10 |
|
9 | 11 | (embedded_sql |
10 | 12 | (_ |
11 | 13 | (paren_fenced_text) @injection.content |
12 | 14 | ) |
13 | 15 | (#set! injection.language "sql") |
| 16 | + (#set! injection.include-children "false") |
| 17 | + (#set! injection.combined "true") |
14 | 18 | ) |
15 | 19 |
|
16 | 20 | (embedded_js |
17 | 21 | (angled_bracket_fenced_text) @injection.content |
18 | 22 | (#set! injection.language "javascript") |
| 23 | + (#set! injection.include-children "false") |
| 24 | + (#set! injection.combined "true") |
19 | 25 | ) |
20 | 26 |
|
21 | 27 | (embedded_xml |
22 | 28 | (angled_bracket_fenced_text) @injection.content |
23 | 29 | (#set! injection.language "xml") |
| 30 | + (#set! injection.include-children "false") |
| 31 | + (#set! injection.combined "true") |
24 | 32 | ) |
25 | 33 |
|
26 | 34 | ([ |
|
61 | 69 | ) |
62 | 70 |
|
63 | 71 | ; XDATA blocks. There's a MimeType keyword that defines the content-type |
64 | | -; but we need to individually match each one so that we can specify the |
65 | | -; name of the tree-sitter grammar to inject. |
| 72 | +; To prevent overlapping matches, we use a different body for the case where |
| 73 | +; no MimeType is given and default to XML, otherwise we extract the language |
| 74 | +; from the mimetype. |
| 75 | + |
66 | 76 | (xdata |
67 | 77 | keywords: |
68 | 78 | (_ |
69 | 79 | (kw_MimeType rhs: _ @_mimetype (#eq? @_mimetype "\"text/markdown\"")) |
70 | 80 | ) |
71 | | - body: (_) @injection.content |
| 81 | + body: (xdata_body_content_any) @injection.content |
72 | 82 | (#set! injection.language "markdown") |
73 | 83 | (#set! injection.include-children "true") |
74 | 84 | ) |
|
78 | 88 | (_ |
79 | 89 | (kw_MimeType rhs: _ @_mimetype (#eq? @_mimetype "\"text/xml\"")) |
80 | 90 | ) |
81 | | - body: (_) @injection.content |
| 91 | + ; NOTE: Since MimeType is given, we match xdata_body_content_any not xml |
| 92 | + body: (xdata_body_content_any) @injection.content |
82 | 93 | (#set! injection.language "xml") |
83 | 94 | (#set! injection.include-children "true") |
84 | 95 | ) |
|
88 | 99 | (_ |
89 | 100 | (kw_MimeType rhs: _ @_mimetype (#eq? @_mimetype "\"text/html\"")) |
90 | 101 | ) |
91 | | - body: (_) @injection.content |
| 102 | + body: (xdata_body_content_any) @injection.content |
92 | 103 | (#set! injection.language "html") |
93 | 104 | (#set! injection.include-children "true") |
94 | 105 | ) |
|
98 | 109 | (_ |
99 | 110 | (kw_MimeType rhs: _ @_mimetype (#eq? @_mimetype "\"application/json\"")) |
100 | 111 | ) |
101 | | - body: (_) @injection.content |
| 112 | + body: (xdata_body_content_any) @injection.content |
102 | 113 | (#set! injection.language "json") |
103 | 114 | (#set! injection.include-children "true") |
104 | 115 | ) |
|
108 | 119 | (_ |
109 | 120 | (kw_MimeType rhs: _ @_mimetype (#eq? @_mimetype "\"text/css\"")) |
110 | 121 | ) |
111 | | - body: (_) @injection.content |
| 122 | + body: (xdata_body_content_any) @injection.content |
112 | 123 | (#set! injection.language "css") |
113 | 124 | (#set! injection.include-children "true") |
114 | 125 | ) |
115 | 126 |
|
116 | | -; Match other less specific XDATAs |
| 127 | +; Match an unspecified XDATA -- defaults to XML |
117 | 128 | (xdata |
118 | | - body: (_) @injection.content |
| 129 | + body: (xdata_body_content_xml) @injection.content |
119 | 130 | (#set! injection.language "xml") |
120 | 131 | (#set! injection.include-children "true") |
121 | 132 | ) |
|
0 commit comments