sdocs 0.0.44 → 0.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.0.45] - 2026-07-04
11
+
12
+ ### Fixed
13
+
14
+ - **The sdoc grammar survives multi-block files.** The embedded Svelte
15
+ grammar opens a text region after any line ending in `>` that only closes
16
+ at the next `<` or `{` — it swallowed block closers, leaving everything
17
+ after the first `[preview]` uncolored. Block bodies now embed Svelte
18
+ behind line-guarded regions (the mechanism markdown fences use), so
19
+ closers, sibling blocks, and later entities all highlight correctly.
20
+
10
21
  ## [0.0.44] - 2026-07-04
11
22
 
12
23
  ### Changed
@@ -2,15 +2,31 @@
2
2
  "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
3
3
  "name": "sdoc",
4
4
  "scopeName": "source.sdoc",
5
- "fileTypes": ["sdoc"],
5
+ "fileTypes": [
6
+ "sdoc"
7
+ ],
6
8
  "patterns": [
7
- { "include": "#comment" },
8
- { "include": "#script-ts" },
9
- { "include": "#script-js" },
10
- { "include": "#style" },
11
- { "include": "#docs" },
12
- { "include": "#page" },
13
- { "include": "#layout" }
9
+ {
10
+ "include": "#comment"
11
+ },
12
+ {
13
+ "include": "#script-ts"
14
+ },
15
+ {
16
+ "include": "#script-js"
17
+ },
18
+ {
19
+ "include": "#style"
20
+ },
21
+ {
22
+ "include": "#docs"
23
+ },
24
+ {
25
+ "include": "#page"
26
+ },
27
+ {
28
+ "include": "#layout"
29
+ }
14
30
  ],
15
31
  "repository": {
16
32
  "comment": {
@@ -19,204 +35,415 @@
19
35
  "end": "-->"
20
36
  },
21
37
  "script-ts": {
22
- "begin": "^\\s*(<)(script)(?=[^>]*lang=([\"'])ts\\3)",
38
+ "begin": "^\\s*(<)(script)((?=[^>]*lang=([\"'])ts\\4)[^>]*)(>)",
23
39
  "beginCaptures": {
24
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
25
- "2": { "name": "entity.name.tag.script.sdoc" }
40
+ "1": {
41
+ "name": "punctuation.definition.tag.begin.sdoc"
42
+ },
43
+ "2": {
44
+ "name": "entity.name.tag.script.sdoc"
45
+ },
46
+ "3": {
47
+ "patterns": [
48
+ {
49
+ "include": "#tag-attributes"
50
+ }
51
+ ]
52
+ },
53
+ "5": {
54
+ "name": "punctuation.definition.tag.end.sdoc"
55
+ }
26
56
  },
27
57
  "end": "(</)(script)\\s*(>)",
28
58
  "endCaptures": {
29
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
30
- "2": { "name": "entity.name.tag.script.sdoc" },
31
- "3": { "name": "punctuation.definition.tag.end.sdoc" }
59
+ "1": {
60
+ "name": "punctuation.definition.tag.begin.sdoc"
61
+ },
62
+ "2": {
63
+ "name": "entity.name.tag.script.sdoc"
64
+ },
65
+ "3": {
66
+ "name": "punctuation.definition.tag.end.sdoc"
67
+ }
32
68
  },
69
+ "contentName": "source.ts",
33
70
  "patterns": [
34
- { "include": "#tag-rest" },
35
71
  {
36
- "begin": "(?<=>)",
37
- "end": "(?=</script)",
38
- "contentName": "source.ts",
39
- "patterns": [{ "include": "source.ts" }]
72
+ "include": "source.ts"
40
73
  }
41
74
  ]
42
75
  },
43
76
  "script-js": {
44
- "begin": "^\\s*(<)(script)(?![^>]*lang=([\"'])ts\\3)(?=[\\s>])",
77
+ "begin": "^\\s*(<)(script)((?![^>]*lang=([\"'])ts\\4)[^>]*)(>)",
45
78
  "beginCaptures": {
46
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
47
- "2": { "name": "entity.name.tag.script.sdoc" }
79
+ "1": {
80
+ "name": "punctuation.definition.tag.begin.sdoc"
81
+ },
82
+ "2": {
83
+ "name": "entity.name.tag.script.sdoc"
84
+ },
85
+ "3": {
86
+ "patterns": [
87
+ {
88
+ "include": "#tag-attributes"
89
+ }
90
+ ]
91
+ },
92
+ "5": {
93
+ "name": "punctuation.definition.tag.end.sdoc"
94
+ }
48
95
  },
49
96
  "end": "(</)(script)\\s*(>)",
50
97
  "endCaptures": {
51
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
52
- "2": { "name": "entity.name.tag.script.sdoc" },
53
- "3": { "name": "punctuation.definition.tag.end.sdoc" }
98
+ "1": {
99
+ "name": "punctuation.definition.tag.begin.sdoc"
100
+ },
101
+ "2": {
102
+ "name": "entity.name.tag.script.sdoc"
103
+ },
104
+ "3": {
105
+ "name": "punctuation.definition.tag.end.sdoc"
106
+ }
54
107
  },
108
+ "contentName": "source.js",
55
109
  "patterns": [
56
- { "include": "#tag-rest" },
57
110
  {
58
- "begin": "(?<=>)",
59
- "end": "(?=</script)",
60
- "contentName": "source.js",
61
- "patterns": [{ "include": "source.js" }]
111
+ "include": "source.js"
62
112
  }
63
113
  ]
64
114
  },
65
115
  "style": {
66
- "begin": "^\\s*(<)(style)(?=[\\s>])",
116
+ "begin": "^\\s*(<)(style)([^>]*)(>)",
67
117
  "beginCaptures": {
68
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
69
- "2": { "name": "entity.name.tag.style.sdoc" }
118
+ "1": {
119
+ "name": "punctuation.definition.tag.begin.sdoc"
120
+ },
121
+ "2": {
122
+ "name": "entity.name.tag.style.sdoc"
123
+ },
124
+ "3": {
125
+ "patterns": [
126
+ {
127
+ "include": "#tag-attributes"
128
+ }
129
+ ]
130
+ },
131
+ "4": {
132
+ "name": "punctuation.definition.tag.end.sdoc"
133
+ }
70
134
  },
71
135
  "end": "(</)(style)\\s*(>)",
72
136
  "endCaptures": {
73
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
74
- "2": { "name": "entity.name.tag.style.sdoc" },
75
- "3": { "name": "punctuation.definition.tag.end.sdoc" }
137
+ "1": {
138
+ "name": "punctuation.definition.tag.begin.sdoc"
139
+ },
140
+ "2": {
141
+ "name": "entity.name.tag.style.sdoc"
142
+ },
143
+ "3": {
144
+ "name": "punctuation.definition.tag.end.sdoc"
145
+ }
76
146
  },
147
+ "contentName": "source.css",
77
148
  "patterns": [
78
- { "include": "#tag-rest" },
79
149
  {
80
- "begin": "(?<=>)",
81
- "end": "(?=</style)",
82
- "contentName": "source.css",
83
- "patterns": [{ "include": "source.css" }]
150
+ "include": "source.css"
84
151
  }
85
152
  ]
86
153
  },
87
- "tag-rest": {
88
- "begin": "\\G",
89
- "end": "(>)",
90
- "endCaptures": {
91
- "1": { "name": "punctuation.definition.tag.end.sdoc" }
92
- },
93
- "patterns": [{ "include": "#attributes" }]
94
- },
95
154
  "docs": {
96
155
  "name": "meta.block.docs.sdoc",
97
- "begin": "^\\s*(\\[)(DOCS)\\b",
156
+ "begin": "^\\s*(\\[)(DOCS)\\b(.*)$",
98
157
  "beginCaptures": {
99
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
100
- "2": { "name": "keyword.control.entity.sdoc" }
158
+ "1": {
159
+ "name": "punctuation.definition.tag.begin.sdoc"
160
+ },
161
+ "2": {
162
+ "name": "keyword.control.entity.sdoc"
163
+ },
164
+ "3": {
165
+ "patterns": [
166
+ {
167
+ "include": "#attributes"
168
+ }
169
+ ]
170
+ }
101
171
  },
102
172
  "end": "^\\s*(\\[/)(DOCS)(\\])\\s*$",
103
173
  "endCaptures": {
104
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
105
- "2": { "name": "keyword.control.entity.sdoc" },
106
- "3": { "name": "punctuation.definition.tag.end.sdoc" }
174
+ "1": {
175
+ "name": "punctuation.definition.tag.begin.sdoc"
176
+ },
177
+ "2": {
178
+ "name": "keyword.control.entity.sdoc"
179
+ },
180
+ "3": {
181
+ "name": "punctuation.definition.tag.end.sdoc"
182
+ }
107
183
  },
108
184
  "patterns": [
109
- { "include": "#opener-attrs" },
110
- { "include": "#comment" },
111
- { "include": "#preview" },
112
- { "include": "#example" }
185
+ {
186
+ "include": "#comment"
187
+ },
188
+ {
189
+ "include": "#opener-continuation"
190
+ },
191
+ {
192
+ "include": "#preview"
193
+ },
194
+ {
195
+ "include": "#example"
196
+ }
113
197
  ]
114
198
  },
115
199
  "page": {
116
200
  "name": "meta.block.page.sdoc",
117
- "begin": "^\\s*(\\[)(PAGE)\\b",
201
+ "begin": "^\\s*(\\[)(PAGE)\\b(.*)$",
118
202
  "beginCaptures": {
119
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
120
- "2": { "name": "keyword.control.entity.sdoc" }
203
+ "1": {
204
+ "name": "punctuation.definition.tag.begin.sdoc"
205
+ },
206
+ "2": {
207
+ "name": "keyword.control.entity.sdoc"
208
+ },
209
+ "3": {
210
+ "patterns": [
211
+ {
212
+ "include": "#attributes"
213
+ }
214
+ ]
215
+ }
121
216
  },
122
217
  "end": "^\\s*(\\[/)(PAGE)(\\])\\s*$",
123
218
  "endCaptures": {
124
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
125
- "2": { "name": "keyword.control.entity.sdoc" },
126
- "3": { "name": "punctuation.definition.tag.end.sdoc" }
219
+ "1": {
220
+ "name": "punctuation.definition.tag.begin.sdoc"
221
+ },
222
+ "2": {
223
+ "name": "keyword.control.entity.sdoc"
224
+ },
225
+ "3": {
226
+ "name": "punctuation.definition.tag.end.sdoc"
227
+ }
127
228
  },
128
229
  "patterns": [
129
- { "include": "#opener-attrs" },
130
- { "include": "source.svelte" }
230
+ {
231
+ "begin": "(^|\\G)",
232
+ "while": "(^|\\G)(?!\\s*\\[/PAGE\\]\\s*$)",
233
+ "patterns": [
234
+ {
235
+ "include": "source.svelte"
236
+ }
237
+ ]
238
+ }
131
239
  ]
132
240
  },
133
241
  "layout": {
134
242
  "name": "meta.block.layout.sdoc",
135
- "begin": "^\\s*(\\[)(LAYOUT)\\b",
243
+ "begin": "^\\s*(\\[)(LAYOUT)\\b(.*)$",
136
244
  "beginCaptures": {
137
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
138
- "2": { "name": "keyword.control.entity.sdoc" }
245
+ "1": {
246
+ "name": "punctuation.definition.tag.begin.sdoc"
247
+ },
248
+ "2": {
249
+ "name": "keyword.control.entity.sdoc"
250
+ },
251
+ "3": {
252
+ "patterns": [
253
+ {
254
+ "include": "#attributes"
255
+ }
256
+ ]
257
+ }
139
258
  },
140
259
  "end": "^\\s*(\\[/)(LAYOUT)(\\])\\s*$",
141
260
  "endCaptures": {
142
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
143
- "2": { "name": "keyword.control.entity.sdoc" },
144
- "3": { "name": "punctuation.definition.tag.end.sdoc" }
261
+ "1": {
262
+ "name": "punctuation.definition.tag.begin.sdoc"
263
+ },
264
+ "2": {
265
+ "name": "keyword.control.entity.sdoc"
266
+ },
267
+ "3": {
268
+ "name": "punctuation.definition.tag.end.sdoc"
269
+ }
145
270
  },
146
271
  "patterns": [
147
- { "include": "#opener-attrs" },
148
- { "include": "source.svelte" }
272
+ {
273
+ "begin": "(^|\\G)",
274
+ "while": "(^|\\G)(?!\\s*\\[/LAYOUT\\]\\s*$)",
275
+ "patterns": [
276
+ {
277
+ "include": "source.svelte"
278
+ }
279
+ ]
280
+ }
149
281
  ]
150
282
  },
151
283
  "preview": {
152
284
  "name": "meta.block.preview.sdoc",
153
- "begin": "^\\s*(\\[)(preview)\\b",
285
+ "begin": "^\\s*(\\[)(preview)\\b(.*)$",
154
286
  "beginCaptures": {
155
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
156
- "2": { "name": "entity.name.tag.sdoc" }
287
+ "1": {
288
+ "name": "punctuation.definition.tag.begin.sdoc"
289
+ },
290
+ "2": {
291
+ "name": "entity.name.tag.sdoc"
292
+ },
293
+ "3": {
294
+ "patterns": [
295
+ {
296
+ "include": "#attributes"
297
+ }
298
+ ]
299
+ }
157
300
  },
158
301
  "end": "^\\s*(\\[/)(preview)(\\])\\s*$",
159
302
  "endCaptures": {
160
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
161
- "2": { "name": "entity.name.tag.sdoc" },
162
- "3": { "name": "punctuation.definition.tag.end.sdoc" }
303
+ "1": {
304
+ "name": "punctuation.definition.tag.begin.sdoc"
305
+ },
306
+ "2": {
307
+ "name": "entity.name.tag.sdoc"
308
+ },
309
+ "3": {
310
+ "name": "punctuation.definition.tag.end.sdoc"
311
+ }
163
312
  },
164
313
  "patterns": [
165
- { "include": "#opener-attrs" },
166
- { "include": "source.svelte" }
314
+ {
315
+ "begin": "(^|\\G)",
316
+ "while": "(^|\\G)(?!\\s*\\[/preview\\]\\s*$)",
317
+ "patterns": [
318
+ {
319
+ "include": "source.svelte"
320
+ }
321
+ ]
322
+ }
167
323
  ]
168
324
  },
169
325
  "example": {
170
326
  "name": "meta.block.example.sdoc",
171
- "begin": "^\\s*(\\[)(example)\\b",
327
+ "begin": "^\\s*(\\[)(example)\\b(.*)$",
172
328
  "beginCaptures": {
173
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
174
- "2": { "name": "entity.name.tag.sdoc" }
329
+ "1": {
330
+ "name": "punctuation.definition.tag.begin.sdoc"
331
+ },
332
+ "2": {
333
+ "name": "entity.name.tag.sdoc"
334
+ },
335
+ "3": {
336
+ "patterns": [
337
+ {
338
+ "include": "#attributes"
339
+ }
340
+ ]
341
+ }
175
342
  },
176
343
  "end": "^\\s*(\\[/)(example)(\\])\\s*$",
177
344
  "endCaptures": {
178
- "1": { "name": "punctuation.definition.tag.begin.sdoc" },
179
- "2": { "name": "entity.name.tag.sdoc" },
180
- "3": { "name": "punctuation.definition.tag.end.sdoc" }
345
+ "1": {
346
+ "name": "punctuation.definition.tag.begin.sdoc"
347
+ },
348
+ "2": {
349
+ "name": "entity.name.tag.sdoc"
350
+ },
351
+ "3": {
352
+ "name": "punctuation.definition.tag.end.sdoc"
353
+ }
181
354
  },
182
355
  "patterns": [
183
- { "include": "#opener-attrs" },
184
- { "include": "source.svelte" }
356
+ {
357
+ "begin": "(^|\\G)",
358
+ "while": "(^|\\G)(?!\\s*\\[/example\\]\\s*$)",
359
+ "patterns": [
360
+ {
361
+ "include": "source.svelte"
362
+ }
363
+ ]
364
+ }
185
365
  ]
186
366
  },
187
- "opener-attrs": {
188
- "begin": "\\G",
189
- "end": "(\\])",
190
- "endCaptures": {
191
- "1": { "name": "punctuation.definition.tag.end.sdoc" }
192
- },
193
- "patterns": [{ "include": "#attributes" }]
367
+ "opener-continuation": {
368
+ "comment": "Attribute lines of a multi-line opener: lines before the block body that end the opener or continue it.",
369
+ "match": "^\\s*((?:[A-Za-z_][\\w-]*\\s*=.*)?)(\\])\\s*$",
370
+ "captures": {
371
+ "1": {
372
+ "patterns": [
373
+ {
374
+ "include": "#attributes"
375
+ }
376
+ ]
377
+ },
378
+ "2": {
379
+ "name": "punctuation.definition.tag.end.sdoc"
380
+ }
381
+ }
382
+ },
383
+ "tag-attributes": {
384
+ "patterns": [
385
+ {
386
+ "match": "([A-Za-z_][\\w:-]*)(=)?",
387
+ "captures": {
388
+ "1": {
389
+ "name": "entity.other.attribute-name.sdoc"
390
+ },
391
+ "2": {
392
+ "name": "punctuation.separator.key-value.sdoc"
393
+ }
394
+ }
395
+ },
396
+ {
397
+ "name": "string.quoted.double.sdoc",
398
+ "begin": "\"",
399
+ "end": "\""
400
+ },
401
+ {
402
+ "name": "string.quoted.single.sdoc",
403
+ "begin": "'",
404
+ "end": "'"
405
+ }
406
+ ]
194
407
  },
195
408
  "attributes": {
196
409
  "patterns": [
197
410
  {
198
411
  "match": "([A-Za-z_][\\w-]*)\\s*(=)",
199
412
  "captures": {
200
- "1": { "name": "entity.other.attribute-name.sdoc" },
201
- "2": { "name": "punctuation.separator.key-value.sdoc" }
413
+ "1": {
414
+ "name": "entity.other.attribute-name.sdoc"
415
+ },
416
+ "2": {
417
+ "name": "punctuation.separator.key-value.sdoc"
418
+ }
202
419
  }
203
420
  },
204
421
  {
205
- "match": "([A-Za-z_][\\w-]*)",
206
- "name": "entity.other.attribute-name.sdoc"
422
+ "match": "\\]\\s*$",
423
+ "name": "punctuation.definition.tag.end.sdoc"
207
424
  },
208
425
  {
209
426
  "name": "string.quoted.double.sdoc",
210
427
  "begin": "\"",
211
428
  "end": "\"",
212
429
  "beginCaptures": {
213
- "0": { "name": "punctuation.definition.string.begin.sdoc" }
430
+ "0": {
431
+ "name": "punctuation.definition.string.begin.sdoc"
432
+ }
214
433
  },
215
434
  "endCaptures": {
216
- "0": { "name": "punctuation.definition.string.end.sdoc" }
435
+ "0": {
436
+ "name": "punctuation.definition.string.end.sdoc"
437
+ }
217
438
  }
218
439
  },
219
- { "include": "#expression" }
440
+ {
441
+ "include": "#expression"
442
+ },
443
+ {
444
+ "match": "([A-Za-z_][\\w-]*)",
445
+ "name": "entity.other.attribute-name.sdoc"
446
+ }
220
447
  ]
221
448
  },
222
449
  "expression": {
@@ -224,21 +451,35 @@
224
451
  "begin": "\\{",
225
452
  "end": "\\}",
226
453
  "beginCaptures": {
227
- "0": { "name": "punctuation.section.embedded.begin.sdoc" }
454
+ "0": {
455
+ "name": "punctuation.section.embedded.begin.sdoc"
456
+ }
228
457
  },
229
458
  "endCaptures": {
230
- "0": { "name": "punctuation.section.embedded.end.sdoc" }
459
+ "0": {
460
+ "name": "punctuation.section.embedded.end.sdoc"
461
+ }
231
462
  },
232
- "patterns": [{ "include": "#expression-inner" }]
463
+ "patterns": [
464
+ {
465
+ "include": "#expression-inner"
466
+ }
467
+ ]
233
468
  },
234
469
  "expression-inner": {
235
470
  "patterns": [
236
471
  {
237
472
  "begin": "\\{",
238
473
  "end": "\\}",
239
- "patterns": [{ "include": "#expression-inner" }]
474
+ "patterns": [
475
+ {
476
+ "include": "#expression-inner"
477
+ }
478
+ ]
240
479
  },
241
- { "include": "source.ts" }
480
+ {
481
+ "include": "source.ts"
482
+ }
242
483
  ]
243
484
  }
244
485
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdocs",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "description": "A lightweight documentation tool for Svelte 5 components",
5
5
  "type": "module",
6
6
  "license": "MIT",