aboutsummaryrefslogtreecommitdiff
path: root/src/lib/languages/svelte.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/languages/svelte.ts')
-rw-r--r--src/lib/languages/svelte.ts50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/lib/languages/svelte.ts b/src/lib/languages/svelte.ts
new file mode 100644
index 0000000..237c7c7
--- /dev/null
+++ b/src/lib/languages/svelte.ts
@@ -0,0 +1,50 @@
+import type { Hljs } from './types'
+
+export function svelte(hljs: Hljs) {
+ return {
+ subLanguage: 'xml',
+ contains: [
+ hljs.COMMENT('<!--', '-->', {
+ relevance: 10,
+ }),
+ {
+ begin: /^(\s*)(<script(\s*context="module")?>)/gm,
+ end: /^(\s*)(<\/script>)/gm,
+ subLanguage: 'javascript',
+ excludeBegin: true,
+ excludeEnd: true,
+ contains: [
+ {
+ begin: /^(\s*)(\$:)/gm,
+ end: /(\s*)/gm,
+ className: 'keyword',
+ },
+ ],
+ },
+ {
+ begin: /^(\s*)(<style.*>)/gm,
+ end: /^(\s*)(<\/style>)/gm,
+ subLanguage: 'css',
+ excludeBegin: true,
+ excludeEnd: true,
+ },
+ {
+ begin: /\{/gm,
+ end: /\}/gm,
+ subLanguage: 'javascript',
+ contains: [
+ {
+ begin: /[\{]/,
+ end: /[\}]/,
+ skip: true,
+ },
+ {
+ begin: /([#:\/@])(if|else|each|await|then|catch|debug|html)/gm,
+ className: 'keyword',
+ relevance: 10,
+ },
+ ],
+ },
+ ],
+ }
+}