diff --git a/src/grammars/sema.tmLanguage.json b/src/grammars/sema.tmLanguage.json
index 8f03646..c4b2d25 100644
--- a/src/grammars/sema.tmLanguage.json
+++ b/src/grammars/sema.tmLanguage.json
@@ -9,6 +9,9 @@
{
"include": "#comment"
},
+ {
+ "include": "#regex"
+ },
{
"include": "#string"
},
@@ -50,6 +53,17 @@
}
],
"repository": {
+ "regex": {
+ "name": "string.regexp.sema",
+ "begin": "#\"",
+ "end": "\"",
+ "patterns": [
+ {
+ "name": "string.regexp.sema",
+ "match": "\\\\."
+ }
+ ]
+ },
"block-comment": {
"name": "comment.block.sema",
"begin": "#\\|",
diff --git a/tests/syntax-highlight-sync.test.ts b/tests/syntax-highlight-sync.test.ts
index f911dd2..a3825a4 100644
--- a/tests/syntax-highlight-sync.test.ts
+++ b/tests/syntax-highlight-sync.test.ts
@@ -30,6 +30,19 @@ describe('highlightToHtmlSync', () => {
expect(out).toContain('tool/policy-subjects')
})
+ it('classifies complete raw regex literals and regex builtins', async () => {
+ await preloadLanguage('sema')
+ const out = highlightToHtmlSync(
+ '(regex/match? #"\\d+" text)\n(regex/match #"\\\"[^\\\"]+\\\"" text)',
+ 'sema',
+ )
+ const normalized = out.replaceAll('', '')
+ expect(out).toContain('regex/match?')
+ expect(out).toContain('regex/match')
+ expect(normalized).toContain('#"\\d+"')
+ expect(normalized).toContain('#"\\"[^\\"]+\\""')
+ })
+
it('supports non-sema languages too (json), unlike the old sema-only tokenizer', async () => {
await preloadLanguage('json')
const out = highlightToHtmlSync('{"a": 1}', 'json')