svelte-highlight 7.19.0 → 7.20.1

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.
@@ -106,6 +106,17 @@
106
106
  border-spacing: 0;
107
107
  }
108
108
 
109
+ td {
110
+ padding-left: var(--padding-left, var(--padding, 1em));
111
+ padding-right: var(--padding-right, var(--padding, 1em));
112
+ }
113
+
114
+ td,
115
+ td > code,
116
+ pre {
117
+ position: relative;
118
+ }
119
+
109
120
  tr:first-of-type td {
110
121
  padding-top: 1em;
111
122
  }
@@ -118,11 +129,6 @@
118
129
  z-index: 2;
119
130
  }
120
131
 
121
- td {
122
- padding-left: var(--padding-left, var(--padding, 1em));
123
- padding-right: var(--padding-right, var(--padding, 1em));
124
- }
125
-
126
132
  td.hljs:not(.hideBorder):after {
127
133
  content: "";
128
134
  position: absolute;
@@ -137,12 +143,6 @@
137
143
  white-space: pre-wrap;
138
144
  }
139
145
 
140
- td,
141
- td > code,
142
- pre {
143
- position: relative;
144
- }
145
-
146
146
  td > code,
147
147
  pre {
148
148
  z-index: 1;
package/Typewriter.svelte CHANGED
@@ -109,16 +109,12 @@
109
109
  revealedInDom++;
110
110
  }
111
111
 
112
- if (caretMark) {
113
- caretMark.classList.remove("typewriter-caret");
114
- caretMark = undefined;
115
- }
116
- if (revealed < total) {
117
- const next = unitEls[revealed];
118
- if (next) {
119
- next.classList.add("typewriter-caret");
120
- caretMark = next;
121
- }
112
+ // Skip the class churn on frames where `revealed` didn't advance.
113
+ const next = revealed < total ? unitEls[revealed] : undefined;
114
+ if (next !== caretMark) {
115
+ caretMark?.classList.remove("typewriter-caret");
116
+ next?.classList.add("typewriter-caret");
117
+ caretMark = next;
122
118
  }
123
119
  }
124
120
 
package/css-walk.js ADDED
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Low-level CSS text walking shared by `scoped.js` (selector scoping) and
3
+ * `highlight-theme.js` (`::highlight()` conversion): string/comment/block
4
+ * boundary scanning that both need before they can interpret a rule.
5
+ */
6
+
7
+ export const STYLE_TAG = /^(\s*<style>)([\s\S]*?)(<\/style>\s*)$/;
8
+
9
+ /**
10
+ * Index after the closing quote of the string starting at `start`.
11
+ * @param {string} css
12
+ * @param {number} start
13
+ */
14
+ export function findStringEnd(css, start) {
15
+ const quote = css[start];
16
+ let i = start + 1;
17
+ while (i < css.length) {
18
+ const ch = css[i];
19
+ if (ch === "\\") {
20
+ i += 2;
21
+ continue;
22
+ }
23
+ if (ch === quote) return i + 1;
24
+ i += 1;
25
+ }
26
+ return css.length;
27
+ }
28
+
29
+ /**
30
+ * Index after the `}` that closes the block starting at `start`.
31
+ * @param {string} css
32
+ * @param {number} start
33
+ */
34
+ export function findBlockEnd(css, start) {
35
+ let depth = 1;
36
+ let i = start;
37
+ while (i < css.length) {
38
+ const ch = css[i];
39
+ if (ch === "/" && css[i + 1] === "*") {
40
+ const end = css.indexOf("*/", i + 2);
41
+ i = end === -1 ? css.length : end + 2;
42
+ continue;
43
+ }
44
+ if (ch === '"' || ch === "'") {
45
+ i = findStringEnd(css, i);
46
+ continue;
47
+ }
48
+ if (ch === "{") {
49
+ depth += 1;
50
+ } else if (ch === "}") {
51
+ depth -= 1;
52
+ if (depth === 0) return i;
53
+ }
54
+ i += 1;
55
+ }
56
+ return css.length;
57
+ }
58
+
59
+ /**
60
+ * Split on `delim`, skipping nested `()`, `[]`, strings, and comments.
61
+ * @param {string} str
62
+ * @param {string} delim
63
+ */
64
+ export function splitTopLevel(str, delim) {
65
+ const parts = [];
66
+ let depth = 0;
67
+ let current = "";
68
+ let i = 0;
69
+ while (i < str.length) {
70
+ const ch = str[i];
71
+ if (ch === "/" && str[i + 1] === "*") {
72
+ const end = str.indexOf("*/", i + 2);
73
+ const stop = end === -1 ? str.length : end + 2;
74
+ current += str.slice(i, stop);
75
+ i = stop;
76
+ continue;
77
+ }
78
+ if (ch === '"' || ch === "'") {
79
+ const stop = findStringEnd(str, i);
80
+ current += str.slice(i, stop);
81
+ i = stop;
82
+ continue;
83
+ }
84
+ if (ch === "(" || ch === "[") depth += 1;
85
+ else if (ch === ")" || ch === "]") depth -= 1;
86
+
87
+ if (ch === delim && depth === 0) {
88
+ parts.push(current);
89
+ current = "";
90
+ } else {
91
+ current += ch;
92
+ }
93
+ i += 1;
94
+ }
95
+ parts.push(current);
96
+ return parts;
97
+ }
package/engine.d.ts CHANGED
@@ -168,6 +168,9 @@ export interface Snapshot {
168
168
 
169
169
  export interface StreamSession {
170
170
  append(text: string): void;
171
+ /** Tokenizes text loaded via `createSession`'s `from.code` up to (not
172
+ * including) the first lexeme starting at or past `stopAt`. */
173
+ advance(stopAt: number): void;
171
174
  finish(options?: { canonicalize?: boolean }): HighlightResult;
172
175
  snapshot(): Snapshot;
173
176
  events(): ScopeEvent[];
@@ -200,7 +203,7 @@ export interface Registry {
200
203
  tokenizeRanges(code: string, options: { language: string }): TokenRange[];
201
204
  createSession(
202
205
  language: string,
203
- options?: { from?: { code: string; snapshot: Snapshot } },
206
+ options?: { from?: { code: string; snapshot?: Snapshot } },
204
207
  ): StreamSession;
205
208
  resume(
206
209
  code: string,
package/engine.js CHANGED
@@ -125,6 +125,9 @@ export const TEXT = 0;
125
125
  export const OPEN = 1;
126
126
  export const CLOSE = 2;
127
127
 
128
+ /** Scope name prefix marking a sub-language boundary (`language:css`). */
129
+ const LANGUAGE_SCOPE_PREFIX = "language:";
130
+
128
131
  const HTML_ESCAPE_RE = /[&<>"']/g;
129
132
  /** @type {Record<string, string>} */
130
133
  const HTML_ESCAPE_MAP = {
@@ -399,7 +402,7 @@ class Tokenizer {
399
402
  }
400
403
  if (state.relevance > 0) this.relevance += result.relevance;
401
404
  if (result.language) {
402
- this.open(`language:${result.language}`);
405
+ this.open(`${LANGUAGE_SCOPE_PREFIX}${result.language}`);
403
406
  for (const event of result.events) this.events.push(event);
404
407
  this.close();
405
408
  } else {
@@ -727,8 +730,18 @@ class Tokenizer {
727
730
 
728
731
  // --- main loop ---
729
732
 
730
- /** Consumes as much of `this.code` as possible; resumable after append. */
731
- run() {
733
+ /**
734
+ * Consumes as much of `this.code` as possible; resumable after append.
735
+ *
736
+ * `stopAt` halts *before* the first lexeme starting at or past that
737
+ * offset, leaving `pos`/`buffer` exactly as they were after the previous
738
+ * lexeme. That makes the state at a line boundary identical whether the
739
+ * text after it was visible (this call) or not yet appended (streaming),
740
+ * so checkpoints taken either way line up - but with the whole document
741
+ * visible, match caches stay valid across stops and nothing is rescanned.
742
+ * @param {number} [stopAt]
743
+ */
744
+ run(stopAt = Number.POSITIVE_INFINITY) {
732
745
  if (this.aborted) return;
733
746
  for (;;) {
734
747
  this.iterations++;
@@ -737,6 +750,7 @@ class Tokenizer {
737
750
  }
738
751
  const found = this.nextMatch();
739
752
  if (!found) break;
753
+ if (found.match.index >= stopAt) return;
740
754
 
741
755
  const framesBefore = this.frames.length;
742
756
  const topBefore = this.top;
@@ -856,8 +870,8 @@ class Tokenizer {
856
870
  * @param {string} prefix
857
871
  */
858
872
  function scopeToCssClass(name, prefix) {
859
- if (name.startsWith("language:")) {
860
- return name.replace("language:", "language-");
873
+ if (name.startsWith(LANGUAGE_SCOPE_PREFIX)) {
874
+ return name.replace(LANGUAGE_SCOPE_PREFIX, "language-");
861
875
  }
862
876
  if (name.includes(".")) {
863
877
  const pieces = name.split(".");
@@ -962,7 +976,7 @@ export function toRanges(events) {
962
976
  let pos = 0;
963
977
  for (const event of events) {
964
978
  if (event.t === OPEN) {
965
- stack.push(event.s.startsWith("language:") ? null : event.s);
979
+ stack.push(event.s.startsWith(LANGUAGE_SCOPE_PREFIX) ? null : event.s);
966
980
  } else if (event.t === CLOSE) {
967
981
  stack.pop();
968
982
  } else {
@@ -1286,11 +1300,12 @@ export function createRegistry() {
1286
1300
  * will in the final document. `snapshot()`/`resume()` expose the
1287
1301
  * serializable checkpoint state.
1288
1302
  *
1289
- * `options.from` resumes a parse at `snapshot` instead of from scratch.
1290
- * Used by incremental-tokenize.js: `code` is text already scanned as of
1291
- * `snapshot.pos`, and further `append()` calls extend it.
1303
+ * `options.from` loads `code` up front instead of via `append()`, and
1304
+ * resumes at `snapshot` when given (otherwise from the start). Used by
1305
+ * incremental-tokenize.js, which knows the whole document and steps
1306
+ * through it with `advance()`; further `append()` calls still extend it.
1292
1307
  * @param {string} language
1293
- * @param {{ from?: { code: string, snapshot: Snapshot } }} [options]
1308
+ * @param {{ from?: { code: string, snapshot?: Snapshot } }} [options]
1294
1309
  * @returns {StreamSession}
1295
1310
  */
1296
1311
  createSession(language, { from } = {}) {
@@ -1302,7 +1317,7 @@ export function createRegistry() {
1302
1317
  let fed = from ? from.code : "";
1303
1318
  if (from) {
1304
1319
  tokenizer.code = from.code;
1305
- tokenizer.restore(from.snapshot);
1320
+ if (from.snapshot) tokenizer.restore(from.snapshot);
1306
1321
  }
1307
1322
  return {
1308
1323
  /** @param {string} text */
@@ -1316,6 +1331,16 @@ export function createRegistry() {
1316
1331
  tokenizer.run();
1317
1332
  }
1318
1333
  },
1334
+ /**
1335
+ * Tokenizes already-loaded text up to (not including) the first
1336
+ * lexeme starting at or past `stopAt`. A snapshot taken right after
1337
+ * matches one taken by `append()`-ing the same text line by line -
1338
+ * see `Tokenizer#run` - without the per-append rescans.
1339
+ * @param {number} stopAt
1340
+ */
1341
+ advance(stopAt) {
1342
+ tokenizer.run(stopAt);
1343
+ },
1319
1344
  /**
1320
1345
  * Multi-line lookahead (e.g. ruby heredocs) may need the full text
1321
1346
  * before it can match. `canonicalize` re-tokenizes in one O(n) pass.
@@ -10,9 +10,14 @@
10
10
  * and are dropped too; only single-class `.hljs-<scope>` selectors convert.
11
11
  */
12
12
 
13
+ import {
14
+ findBlockEnd,
15
+ findStringEnd,
16
+ STYLE_TAG,
17
+ splitTopLevel,
18
+ } from "./css-walk.js";
13
19
  import { SHL_FALLBACKS } from "./themes/_shl-fallbacks.js";
14
20
 
15
- const STYLE_TAG = /^(\s*<style>)([\s\S]*?)(<\/style>\s*)$/;
16
21
  const SIMPLE_SCOPE_SELECTOR = /^\.hljs-([\w-]+)$/;
17
22
  const SUPPORTED_PROPERTIES = new Set(["color", "background-color"]);
18
23
 
@@ -52,91 +57,6 @@ function decomposeSingleScopeVar(shlVarName) {
52
57
  return { scope: shlVarName.slice(VAR_PREFIX_LENGTH), property: "color" };
53
58
  }
54
59
 
55
- /**
56
- * @param {string} css
57
- * @param {number} start
58
- */
59
- function findStringEnd(css, start) {
60
- const quote = css[start];
61
- let i = start + 1;
62
- while (i < css.length) {
63
- const ch = css[i];
64
- if (ch === "\\") {
65
- i += 2;
66
- continue;
67
- }
68
- if (ch === quote) return i + 1;
69
- i += 1;
70
- }
71
- return css.length;
72
- }
73
-
74
- /**
75
- * Index after the `}` that closes the block starting at `start`.
76
- * @param {string} css
77
- * @param {number} start
78
- */
79
- function findBlockEnd(css, start) {
80
- let depth = 1;
81
- let i = start;
82
- while (i < css.length) {
83
- const ch = css[i];
84
- if (ch === "/" && css[i + 1] === "*") {
85
- const end = css.indexOf("*/", i + 2);
86
- i = end === -1 ? css.length : end + 2;
87
- continue;
88
- }
89
- if (ch === '"' || ch === "'") {
90
- i = findStringEnd(css, i);
91
- continue;
92
- }
93
- if (ch === "{") {
94
- depth += 1;
95
- } else if (ch === "}") {
96
- depth -= 1;
97
- if (depth === 0) return i;
98
- }
99
- i += 1;
100
- }
101
- return css.length;
102
- }
103
-
104
- /**
105
- * Split on `delim`, skipping nested strings and comments.
106
- * @param {string} str
107
- * @param {string} delim
108
- */
109
- function splitTopLevel(str, delim) {
110
- const parts = [];
111
- let current = "";
112
- let i = 0;
113
- while (i < str.length) {
114
- const ch = str[i];
115
- if (ch === "/" && str[i + 1] === "*") {
116
- const end = str.indexOf("*/", i + 2);
117
- const stop = end === -1 ? str.length : end + 2;
118
- current += str.slice(i, stop);
119
- i = stop;
120
- continue;
121
- }
122
- if (ch === '"' || ch === "'") {
123
- const stop = findStringEnd(str, i);
124
- current += str.slice(i, stop);
125
- i = stop;
126
- continue;
127
- }
128
- if (ch === delim) {
129
- parts.push(current);
130
- current = "";
131
- } else {
132
- current += ch;
133
- }
134
- i += 1;
135
- }
136
- parts.push(current);
137
- return parts;
138
- }
139
-
140
60
  /** @param {string} body */
141
61
  function colorDeclarations(body) {
142
62
  return splitTopLevel(body, ";")
@@ -24,26 +24,6 @@ import { diffText } from "./text-diff.js";
24
24
  * }} IncrementalParse
25
25
  */
26
26
 
27
- /**
28
- * Splits `code` into chunks ending right after each "\n". Matches how
29
- * `Registry#createSession#append` consumes input.
30
- * @param {string} code
31
- * @returns {string[]}
32
- */
33
- function splitKeepEnds(code) {
34
- /** @type {string[]} */
35
- const lines = [];
36
- let start = 0;
37
- for (let i = 0; i < code.length; i++) {
38
- if (code.charCodeAt(i) === 10) {
39
- lines.push(code.slice(start, i + 1));
40
- start = i + 1;
41
- }
42
- }
43
- if (start < code.length) lines.push(code.slice(start));
44
- return lines;
45
- }
46
-
47
27
  /**
48
28
  * Whether two checkpoints will emit the same events from here on.
49
29
  * `relevance`/`kwHits` are excluded; they only affect detection scoring.
@@ -52,16 +32,7 @@ function splitKeepEnds(code) {
52
32
  */
53
33
  function stateConverges(a, b) {
54
34
  if (a.buffer !== b.buffer || a.openScopes !== b.openScopes) return false;
55
- if (a.frames.length !== b.frames.length) return false;
56
- for (let i = 0; i < a.frames.length; i++) {
57
- const af = /** @type {{ idx: number, beginMatch: string | undefined }} */ (
58
- a.frames[i]
59
- );
60
- const bf = /** @type {{ idx: number, beginMatch: string | undefined }} */ (
61
- b.frames[i]
62
- );
63
- if (af.idx !== bf.idx || af.beginMatch !== bf.beginMatch) return false;
64
- }
35
+ if (!framesEqual(a.frames, b.frames)) return false;
65
36
  const aSubs = Object.keys(a.subContinuations);
66
37
  const bSubs = Object.keys(b.subContinuations);
67
38
  if (aSubs.length !== bSubs.length) return false;
@@ -75,20 +46,25 @@ function stateConverges(a, b) {
75
46
  // identical (the carry decision it gates is relative to whichever
76
47
  // parse is asking, and stays consistent once frames/buffer/openScopes
77
48
  // - already compared above and below - agree).
78
- const aFrames = aRecord.frames;
79
- const bFrames = bRecord.frames;
80
- if (aFrames.length !== bFrames.length) return false;
81
- for (let i = 0; i < aFrames.length; i++) {
82
- const af =
83
- /** @type {{ idx: number, beginMatch: string | undefined }} */ (
84
- aFrames[i]
85
- );
86
- const bf =
87
- /** @type {{ idx: number, beginMatch: string | undefined }} */ (
88
- bFrames[i]
89
- );
90
- if (af.idx !== bf.idx || af.beginMatch !== bf.beginMatch) return false;
91
- }
49
+ if (!framesEqual(aRecord.frames, bRecord.frames)) return false;
50
+ }
51
+ return true;
52
+ }
53
+
54
+ /**
55
+ * @param {{ idx: number, beginMatch: string | undefined }[]} a
56
+ * @param {{ idx: number, beginMatch: string | undefined }[]} b
57
+ */
58
+ function framesEqual(a, b) {
59
+ if (a.length !== b.length) return false;
60
+ for (let i = 0; i < a.length; i++) {
61
+ const af = /** @type {{ idx: number, beginMatch: string | undefined }} */ (
62
+ a[i]
63
+ );
64
+ const bf = /** @type {{ idx: number, beginMatch: string | undefined }} */ (
65
+ b[i]
66
+ );
67
+ if (af.idx !== bf.idx || af.beginMatch !== bf.beginMatch) return false;
92
68
  }
93
69
  return true;
94
70
  }
@@ -104,23 +80,36 @@ export const CHECKPOINT_INTERVAL = 32;
104
80
  /**
105
81
  * Full parse with a line checkpoint every `CHECKPOINT_INTERVAL` lines (and
106
82
  * always at the document end). First paint or language change.
83
+ *
84
+ * The whole document is loaded up front and stepped through with
85
+ * `advance()` rather than `append()`-ed line by line: each append forces
86
+ * the engine to re-flatten the grown string and rescan every rule whose
87
+ * cached miss it invalidated, which made this O(lines x length).
107
88
  * @param {Registry} registry
108
89
  * @param {string} language
109
90
  * @param {string} code
110
91
  * @returns {IncrementalParse}
111
92
  */
112
93
  export function parseIncremental(registry, language, code) {
113
- const session = registry.createSession(language);
94
+ const session = registry.createSession(language, { from: { code } });
114
95
  const checkpoints = [session.snapshot()];
115
96
  let linesSinceCheckpoint = 0;
116
- for (const line of splitKeepEnds(code)) {
117
- session.append(line);
97
+ // Only newline-terminated lines are tokenized before finish(): a lexeme
98
+ // ending at an unterminated tail may grow with the next keystroke, so no
99
+ // checkpoint can be taken past it (`append()` stages such text likewise).
100
+ let fedEnd = 0;
101
+ for (let lineStart = 0; lineStart < code.length; ) {
102
+ const newline = code.indexOf("\n", lineStart);
118
103
  linesSinceCheckpoint++;
104
+ if (newline === -1) break;
105
+ lineStart = fedEnd = newline + 1;
119
106
  if (linesSinceCheckpoint >= CHECKPOINT_INTERVAL) {
107
+ session.advance(fedEnd);
120
108
  checkpoints.push(session.snapshot());
121
109
  linesSinceCheckpoint = 0;
122
110
  }
123
111
  }
112
+ session.advance(fedEnd);
124
113
  // Always retain an end checkpoint so resume can land on the final state
125
114
  // even when the last interval is incomplete.
126
115
  if (linesSinceCheckpoint > 0 || checkpoints.length === 1) {
@@ -177,10 +166,11 @@ export function reparseIncremental(registry, language, previous, code) {
177
166
  // Prefix up to the resume checkpoint is unchanged (within diffText's common
178
167
  // prefix). restore() clears the session event log, so reattach prefix events
179
168
  // separately.
180
- const prefixCode = code.slice(0, resumeCheckpoint.pos);
181
169
  const prefixEvents = previous.events.slice(0, resumeCheckpoint.eventCount);
170
+ // The full document is loaded so the tail can be walked with `advance()`
171
+ // (see parseIncremental); tokenization still only proceeds line by line.
182
172
  const session = registry.createSession(language, {
183
- from: { code: prefixCode, snapshot: resumeCheckpoint },
173
+ from: { code, snapshot: resumeCheckpoint },
184
174
  });
185
175
  const checkpoints = previous.checkpoints.slice(0, resumeIndex + 1);
186
176
 
@@ -188,13 +178,24 @@ export function reparseIncremental(registry, language, previous, code) {
188
178
  const newSuffixStart = diff.start + diff.inserted.length;
189
179
  const posOffset = code.length - previous.code.length;
190
180
 
191
- const newLines = splitKeepEnds(code.slice(resumeCheckpoint.pos));
192
181
  let convergedAtOldIndex = -1;
193
182
  let oldIndex = resumeIndex;
194
183
  let linesSinceCheckpoint = 0;
195
184
 
196
- for (let li = 0; li < newLines.length; li++) {
197
- session.append(/** @type {string} */ (newLines[li]));
185
+ for (
186
+ let li = 0, lineStart = resumeCheckpoint.pos;
187
+ lineStart < code.length;
188
+ li++
189
+ ) {
190
+ const newline = code.indexOf("\n", lineStart);
191
+ // An unterminated tail is staged, not tokenized (see parseIncremental);
192
+ // it still gets its own iteration so the final checkpoint is stored.
193
+ const isTail = newline === -1;
194
+ if (!isTail) {
195
+ lineStart = newline + 1;
196
+ session.advance(lineStart);
197
+ }
198
+ const isLast = isTail || lineStart === code.length;
198
199
  const snap = session.snapshot();
199
200
  linesSinceCheckpoint++;
200
201
  // Check every line for convergence against previous checkpoints.
@@ -225,7 +226,7 @@ export function reparseIncremental(registry, language, previous, code) {
225
226
  shouldStore = true;
226
227
  }
227
228
  }
228
- if (!shouldStore && li === newLines.length - 1) shouldStore = true;
229
+ if (!shouldStore && isLast) shouldStore = true;
229
230
  if (shouldStore) {
230
231
  // snap.eventCount is session-local; shift to index the combined array.
231
232
  checkpoints.push({
@@ -234,7 +235,7 @@ export function reparseIncremental(registry, language, previous, code) {
234
235
  });
235
236
  linesSinceCheckpoint = 0;
236
237
  }
237
- if (convergedAtOldIndex >= 0) break;
238
+ if (convergedAtOldIndex >= 0 || isLast) break;
238
239
  }
239
240
 
240
241
  if (convergedAtOldIndex >= 0) {
@@ -0,0 +1,2 @@
1
+ export { agda } from "./";
2
+ export { agda as default } from "./";
@@ -0,0 +1,99 @@
1
+ export const agda =
2
+ /** @type {import("./index.d.ts").LanguageType<"agda">} */ ({
3
+ name: "agda",
4
+ aliases: ["agda"],
5
+ register: {
6
+ name: "agda",
7
+ caseInsensitive: false,
8
+ unicode: true,
9
+ disableAutodetect: false,
10
+ states: [
11
+ {
12
+ rules: [1, 4, 5, 6, 7, 9, 10],
13
+ keywords: {
14
+ module: ["keyword", 1],
15
+ where: ["keyword", 1],
16
+ import: ["keyword", 1],
17
+ data: ["keyword", 1],
18
+ record: ["keyword", 1],
19
+ field: ["keyword", 1],
20
+ constructor: ["keyword", 1],
21
+ postulate: ["keyword", 1],
22
+ open: ["keyword", 1],
23
+ using: ["keyword", 1],
24
+ renaming: ["keyword", 1],
25
+ hiding: ["keyword", 1],
26
+ public: ["keyword", 1],
27
+ private: ["keyword", 1],
28
+ variable: ["keyword", 1],
29
+ mutual: ["keyword", 1],
30
+ instance: ["keyword", 1],
31
+ abstract: ["keyword", 1],
32
+ macro: ["keyword", 1],
33
+ pattern: ["keyword", 1],
34
+ rewrite: ["keyword", 1],
35
+ with: ["keyword", 1],
36
+ in: ["keyword", 0],
37
+ let: ["keyword", 1],
38
+ do: ["keyword", 1],
39
+ case: ["keyword", 1],
40
+ of: ["keyword", 0],
41
+ infix: ["keyword", 1],
42
+ infixl: ["keyword", 1],
43
+ infixr: ["keyword", 1],
44
+ },
45
+ keywordPattern: "\\w+",
46
+ },
47
+ { rules: [2, 3], scope: "comment", begin: "--", end: "$" },
48
+ {
49
+ relevance: 0,
50
+ rules: [],
51
+ scope: "doctag",
52
+ begin: "[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
53
+ end: "(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):",
54
+ excludeBegin: true,
55
+ },
56
+ {
57
+ rules: [],
58
+ begin:
59
+ "[ ]+((?:I|a|is|so|us|to|at|if|in|it|on|[A-Za-z]+['](d|ve|re|ll|t|s|n)|[A-Za-z]+[-][a-z]+|[A-Za-z][a-z]{2,})[.]?[:]?([.][ ]|[ ])){3}",
60
+ end: "\\B|\\b",
61
+ },
62
+ {
63
+ relevance: 10,
64
+ rules: [],
65
+ scope: "meta",
66
+ begin: "\\{-#",
67
+ end: "#-\\}",
68
+ },
69
+ { rules: [5], scope: "comment", begin: "\\{-", end: "-\\}" },
70
+ {
71
+ relevance: 0,
72
+ rules: [],
73
+ begin:
74
+ "(\\b(?:data|record)\\s+)([\\p{L}\\p{N}_][\\p{L}\\p{N}_'?!-]*)",
75
+ end: "\\B|\\b",
76
+ captureScopes: { 1: null, 2: "title.class" },
77
+ },
78
+ { rules: [8], scope: "string", begin: '"', end: '"' },
79
+ { relevance: 0, rules: [], begin: "\\\\[\\s\\S]", end: "\\B|\\b" },
80
+ {
81
+ relevance: 5,
82
+ rules: [],
83
+ scope: "operator",
84
+ begin:
85
+ "[\\u2200\\u2203\\u2192\\u2190\\u2194\\u03BB\\u039B\\u2115\\u2124\\u211A\\u211D\\u2102\\u27E8\\u27E9\\u2208\\u2209\\u2227\\u2228\\u00AC\\u2264\\u2265\\u2260\\u2261\\u2218\\u00D7\\u22A2\\u228E\\u22A4\\u22A5\\u2237\\u21A6]",
86
+ end: "\\B|\\b",
87
+ },
88
+ {
89
+ relevance: 0,
90
+ rules: [],
91
+ scope: "number",
92
+ begin: "\\b\\d+(?:\\.\\d+)?\\b",
93
+ end: "\\B|\\b",
94
+ },
95
+ ],
96
+ aliases: ["agda"],
97
+ },
98
+ });
99
+ export default agda;