Skip to content

Commit 3f11836

Browse files
committed
Fix grammars running out of broken code
Closes GH-9.
1 parent af6d9c2 commit 3f11836

File tree

5 files changed

+4410
-1343
lines changed

5 files changed

+4410
-1343
lines changed

build.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,22 @@ for (const embedded of embeddedGrammars) {
334334
backtickCopy.begin = backtickCopy.begin
335335
.replace(/var\(char_code_info_tick\)\+/, regex)
336336
.replace(/\)\?\)\?/, ')?)')
337-
backtickCopy.contentName = 'meta.embedded.' + embedded.id
337+
delete backtickCopy.contentName
338338
backtickCopy.name = 'markup.code.' + embedded.id + '.var(suffix)'
339-
backtickCopy.patterns = embedded.scopeNames.map((d) => ({include: d}))
339+
backtickCopy.patterns = structuredClone([
340+
{
341+
begin: '(^|\\G)(\\s*)(.*)',
342+
while: '(^|\\G)(?![\\t ]*([`~]{3,})[\\t ]*$)',
343+
contentName: 'meta.embedded.' + embedded.id,
344+
patterns: embedded.scopeNames.map((d) => ({include: d}))
345+
}
346+
])
340347

341348
assert(tildeCopy.begin, 'expected begin')
342349
tildeCopy.begin = tildeCopy.begin
343350
.replace(/var\(char_code_info_tilde\)\+/, regex)
344351
.replace(/\)\?\)\?/, ')?)')
345-
tildeCopy.contentName = structuredClone(backtickCopy.contentName)
352+
delete tildeCopy.contentName
346353
tildeCopy.name = structuredClone(backtickCopy.name)
347354
tildeCopy.patterns = structuredClone(backtickCopy.patterns)
348355

0 commit comments

Comments
 (0)