@scalar/highlight 0.5.0 → 0.6.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @scalar/highlight
2
2
 
3
+ ## 0.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#11004](https://github.com/scalar/scalar/pull/11004): Preserve package output paths and application aliases when building with TypeScript 6.
8
+
9
+ ## 0.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#9939](https://github.com/scalar/scalar/pull/9939): Add a dedicated `curl` grammar, so curl command lines keep the colouring they had under `@scalar/code-highlight`.
14
+
15
+ `curl` was mapped to the bash grammar. That is a defensible reading — a curl invocation is a shell command line — but it loses the two tokens a reader actually looks for. `@scalar/code-highlight` ships a bespoke curl grammar, and `code.css` is written against it: `.hljs.language-curl .hljs-literal` and `.hljs.language-curl .hljs-string` both have curl-specific rules. Under bash, `curl` and the request method came out unscoped, so the command name lost its keyword colour and `POST` lost its symbol colour entirely.
16
+
17
+ The new grammar mirrors the reference: the command is a keyword, `--request`/`-X` and other flags are literals, the method they carry is a symbol, and `$(…)` inside a double-quoted value reads as a variable. Output now matches the reference class for class.
18
+
19
+ This also adds a `symbol` scope to the vocabulary, mapped to `hljs-symbol` in the compat layer — a scope highlight.js has and `code.css` already styles, and the natural home for Ruby symbols and Erlang atoms too.
20
+
21
+ A curl sample joins the shared test corpus, so the differential suites compare this grammar against the reference on every run.
22
+
23
+ ### Patch Changes
24
+
25
+ - [#9939](https://github.com/scalar/scalar/pull/9939): feat(highlight): colour the names declarations bind in Java, C#, Go and Rust, and PowerShell parameters like shell flags
26
+ - [#10721](https://github.com/scalar/scalar/pull/10721): Update compatible dependencies while retaining the existing Node.js support and five-day release-age policy.
27
+ - [#9939](https://github.com/scalar/scalar/pull/9939): Fix JavaScript comparisons read as generic calls, and keep compiled grammars when a grammar is registered again
28
+
29
+ An identifier followed by `<` read as the start of a generic call, so `count` in `if (count <= max)` and `b` in `b <= 10` were painted as function names. The generic branch now requires a type argument list that closes and is followed by `(`, so `useState<number>(0)` still scopes and a comparison does not.
30
+
31
+ `registerLanguage` also evicted a grammar's compiled form whenever it was called, even with the grammar already registered under every one of its names. A caller that registers on every render recompiled on every render, which cost close to twenty times the highlight itself. Registering the same grammar again is now a no-op.
32
+
3
33
  ## 0.5.0
4
34
 
5
35
  ### Minor Changes
package/README.md CHANGED
@@ -1,7 +1,21 @@
1
1
  # @scalar/highlight
2
2
 
3
+ [![Version](https://img.shields.io/npm/v/%40scalar/highlight)](https://www.npmjs.com/package/@scalar/highlight)
4
+ [![Downloads](https://img.shields.io/npm/dm/%40scalar/highlight)](https://www.npmjs.com/package/@scalar/highlight)
5
+ [![License](https://img.shields.io/npm/l/%40scalar%2Fhighlight)](https://www.npmjs.com/package/@scalar/highlight)
6
+ [![Discord](https://img.shields.io/discord/1135330207960678410?style=flat&color=5865F2)](https://discord.gg/scalar)
7
+
3
8
  Scalar's code highlighter.
4
9
 
10
+ <picture>
11
+ <source
12
+ media="(prefers-color-scheme: dark)"
13
+ srcset="https://github.com/user-attachments/assets/380abb34-8814-4b34-8926-19ab84a91d79">
14
+ <img
15
+ alt="Python, TypeScript, Rust and HTTP highlighted by @scalar/highlight"
16
+ src="https://github.com/user-attachments/assets/8ac62023-f56c-4dcd-a7e3-d0272a43c610">
17
+ </picture>
18
+
5
19
  - **Small.** 3.5 KB core, ~1.7 KB for Python, gzipped. Nothing you do not import.
6
20
  - **No theme system.** Colors come from the `--scalar-*` variables `@scalar/themes` already defines, so a code block follows the app's theme and switches with `.light-mode` / `.dark-mode` — without being re-highlighted.
7
21
  - **Zero runtime dependencies.**
@@ -358,6 +372,10 @@ devDependencies and neither reaches consumers.
358
372
 
359
373
  Repository-wide conventions live in the root [`AGENTS.md`](../../AGENTS.md).
360
374
 
375
+ ## Community
376
+
377
+ We are API nerds. You too? Let's chat on Discord: <https://discord.gg/scalar>
378
+
361
379
  ## License
362
380
 
363
- MIT
381
+ The source code in this repository is licensed under [MIT](https://github.com/scalar/scalar/blob/main/LICENSE).
package/dist/all.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"all.d.ts","sourceRoot":"","sources":["../src/all.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AA2C3C;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,EA0C9B,CAAA;AAID;;;;;;;GAOG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC3E,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC3E,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC5D,YAAY,EACV,eAAe,EACf,IAAI,EACJ,OAAO,EACP,OAAO,EACP,IAAI,EACJ,SAAS,EACT,KAAK,EACL,SAAS,EACT,KAAK,GACN,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"all.d.ts","sourceRoot":"","sources":["../src/all.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AA4C3C;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,EA2C9B,CAAA;AAID;;;;;;;GAOG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC3E,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC3E,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC5D,YAAY,EACV,eAAe,EACf,IAAI,EACJ,OAAO,EACP,OAAO,EACP,IAAI,EACJ,SAAS,EACT,KAAK,EACL,SAAS,EACT,KAAK,GACN,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA"}
package/dist/all.js CHANGED
@@ -5,6 +5,7 @@ import clojure from './langs/clojure.js';
5
5
  import cpp from './langs/cpp.js';
6
6
  import csharp from './langs/csharp.js';
7
7
  import css from './langs/css.js';
8
+ import curl from './langs/curl.js';
8
9
  import dart from './langs/dart.js';
9
10
  import diff from './langs/diff.js';
10
11
  import dockerfile from './langs/dockerfile.js';
@@ -54,6 +55,7 @@ export const languages = [
54
55
  cpp,
55
56
  csharp,
56
57
  css,
58
+ curl,
57
59
  dart,
58
60
  diff,
59
61
  dockerfile,
@@ -1 +1 @@
1
- {"version":3,"file":"hljs.d.ts","sourceRoot":"","sources":["../../src/compat/hljs.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAmE/C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,MAAM,GAAG,IAYlD,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"hljs.d.ts","sourceRoot":"","sources":["../../src/compat/hljs.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAoE/C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,MAAM,GAAG,IAYlD,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -33,6 +33,7 @@ const HLJS_CLASSES = {
33
33
  'variable.parameter': 'hljs-params',
34
34
  'variable.member': 'hljs-property',
35
35
  'variable.special': 'hljs-variable',
36
+ symbol: 'hljs-symbol',
36
37
  // --- keywords -------------------------------------------------------------
37
38
  keyword: 'hljs-keyword',
38
39
  'keyword.control': 'hljs-keyword',
@@ -1 +1 @@
1
- {"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../src/compat/languages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAQ3D,CAAA;AA6HD;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,keAoD1B,CAAA;AAEV,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE1E;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,EAEzB,MAAM,CAAC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC,CAAA;AAE/C,gFAAgF;AAChF,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAAiE,CAAA;AAE1G;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAK5C,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,eAAe,GAAG,SAG3D,CAAA"}
1
+ {"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../src/compat/languages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAQ3D,CAAA;AA0HD;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,keAoD1B,CAAA;AAEV,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE1E;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,EAEzB,MAAM,CAAC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC,CAAA;AAE/C,gFAAgF;AAChF,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAAiE,CAAA;AAE1G;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAK5C,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,eAAe,GAAG,SAG3D,CAAA"}
@@ -36,10 +36,7 @@ const GRAMMAR_FOR = {
36
36
  cs: 'csharp',
37
37
  csharp: 'csharp',
38
38
  css: 'css',
39
- // A curl invocation is a shell command line, so the bash grammar is the
40
- // honest answer. `code.css` still targets `.hljs.language-curl` by name —
41
- // the class comes from what the caller asked for, not from the grammar.
42
- curl: 'bash',
39
+ curl: 'curl',
43
40
  cxx: 'cpp',
44
41
  dart: 'dart',
45
42
  diff: 'diff',
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/core/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAYvD,eAAO,MAAM,gBAAgB,GAAI,GAAG,UAAU,OAAO,EAAE,KAAG,IAyBzD,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,OAE3C,CAAA;AAED,gEAAgE;AAChE,eAAO,MAAM,aAAa,QAAO,MAAM,EAEtC,CAAA;AAMD,qEAAqE;AACrE,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,eAAe,GAAG,SAkB5D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,GAAG,OAAO,GAAG,eAAe,KAAG,eAgBzE,CAAA"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/core/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAYvD,eAAO,MAAM,gBAAgB,GAAI,GAAG,UAAU,OAAO,EAAE,KAAG,IAiCzD,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,OAE3C,CAAA;AAED,gEAAgE;AAChE,eAAO,MAAM,aAAa,QAAO,MAAM,EAEtC,CAAA;AAMD,qEAAqE;AACrE,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,eAAe,GAAG,SAkB5D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,GAAG,OAAO,GAAG,eAAe,KAAG,eAgBzE,CAAA"}
@@ -11,6 +11,14 @@ const cache = new Map();
11
11
  export const registerLanguage = (...grammars) => {
12
12
  for (const grammar of grammars) {
13
13
  const name = grammar.name.toLowerCase();
14
+ const keys = [name, ...(grammar.aliases ?? [])].map((key) => key.toLowerCase());
15
+ // Registering the same grammar again changes nothing, so it keeps its
16
+ // compiled form. Evicting it here made a caller that registers on every
17
+ // render — a component's setup, say — recompile on every call, which is
18
+ // close to twenty times the cost of the highlight itself.
19
+ if (keys.every((key) => sources.get(key) === grammar)) {
20
+ continue;
21
+ }
14
22
  // Re-registering replaces a language outright, so retire every name the
15
23
  // previous grammar answered to before claiming the new one's. Evicting only
16
24
  // the canonical name would leave each alias pointing at, and cached as, the
@@ -25,10 +33,9 @@ export const registerLanguage = (...grammars) => {
25
33
  cache.delete(lower);
26
34
  }
27
35
  }
28
- for (const key of [name, ...(grammar.aliases ?? [])]) {
29
- const lower = key.toLowerCase();
30
- sources.set(lower, grammar);
31
- cache.delete(lower);
36
+ for (const key of keys) {
37
+ sources.set(key, grammar);
38
+ cache.delete(key);
32
39
  }
33
40
  }
34
41
  };
@@ -6,7 +6,7 @@
6
6
  * without knowing anything about them.
7
7
  *
8
8
  * Each scope maps to a short CSS class so the rendered HTML stays small
9
- * (`<span class="ch-kd">def</span>`). Themes never mention these codes — they
9
+ * (`<span class="shl-kd">def</span>`). Themes never mention these codes — they
10
10
  * are written against the readable scope names and the codes are applied here.
11
11
  *
12
12
  * Scopes are hierarchical: `function.builtin` falls back to `function` when a
@@ -36,6 +36,8 @@ export declare const SCOPES: {
36
36
  readonly 'variable.member': "vm";
37
37
  /** `__name__`, `__init__` — dunder / magic names. */
38
38
  readonly 'variable.special': "vs";
39
+ /** `:name` in Ruby, an atom in Erlang, an HTTP method in a curl line. */
40
+ readonly symbol: "sy";
39
41
  readonly keyword: "k";
40
42
  /** `if`, `for`, `return`, `await`, `yield`. */
41
43
  readonly 'keyword.control': "kc";
@@ -1 +1 @@
1
- {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../src/core/scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,MAAM;;;;;IAQjB,kFAAkF;;IAElF,0DAA0D;;;;;;IAQ1D,0CAA0C;;;IAG1C,sCAAsC;;;IAGtC,sCAAsC;;IAEtC,qDAAqD;;;IAKrD,+CAA+C;;IAE/C,qDAAqD;;;IAGrD,yEAAyE;;IAIzE,iCAAiC;;IAEjC,2BAA2B;;IAE3B,kCAAkC;;;;IAIlC,gDAAgD;;;;;;;;;;;IAehD,8CAA8C;;;IAG9C,4BAA4B;;;;;;;;;;;CAYpB,CAAA;AAEV,MAAM,MAAM,KAAK,GAAG,MAAM,OAAO,MAAM,CAAA;AAEvC,6EAA6E;AAC7E,eAAO,MAAM,WAAW,EAA0B,KAAK,EAAE,CAAA;AAEzD;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,MAM1C,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,MAAM,EAQhD,CAAA"}
1
+ {"version":3,"file":"scopes.d.ts","sourceRoot":"","sources":["../../src/core/scopes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,MAAM;;;;;IAQjB,kFAAkF;;IAElF,0DAA0D;;;;;;IAQ1D,0CAA0C;;;IAG1C,sCAAsC;;;IAGtC,sCAAsC;;IAEtC,qDAAqD;;IAGrD,yEAAyE;;;IAKzE,+CAA+C;;IAE/C,qDAAqD;;;IAGrD,yEAAyE;;IAIzE,iCAAiC;;IAEjC,2BAA2B;;IAE3B,kCAAkC;;;;IAIlC,gDAAgD;;;;;;;;;;;IAehD,8CAA8C;;;IAG9C,4BAA4B;;;;;;;;;;;CAYpB,CAAA;AAEV,MAAM,MAAM,KAAK,GAAG,MAAM,OAAO,MAAM,CAAA;AAEvC,6EAA6E;AAC7E,eAAO,MAAM,WAAW,EAA0B,KAAK,EAAE,CAAA;AAEzD;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,MAM1C,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,KAAG,MAAM,EAQhD,CAAA"}
@@ -6,7 +6,7 @@
6
6
  * without knowing anything about them.
7
7
  *
8
8
  * Each scope maps to a short CSS class so the rendered HTML stays small
9
- * (`<span class="ch-kd">def</span>`). Themes never mention these codes — they
9
+ * (`<span class="shl-kd">def</span>`). Themes never mention these codes — they
10
10
  * are written against the readable scope names and the codes are applied here.
11
11
  *
12
12
  * Scopes are hierarchical: `function.builtin` falls back to `function` when a
@@ -39,6 +39,8 @@ export const SCOPES = {
39
39
  'variable.member': 'vm',
40
40
  /** `__name__`, `__init__` — dunder / magic names. */
41
41
  'variable.special': 'vs',
42
+ /** `:name` in Ruby, an atom in Erlang, an HTTP method in a curl line. */
43
+ symbol: 'sy',
42
44
  // --- keywords -------------------------------------------------------------
43
45
  keyword: 'k',
44
46
  /** `if`, `for`, `return`, `await`, `yield`. */
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import type { CompiledGrammar, Grammar, Token } from './core/types.js';
4
4
  export type LanguageInput = string | Grammar | CompiledGrammar;
5
5
  /** Highlights to an HTML fragment (the inside of a `<code>` element). */
6
6
  export declare const highlight: (code: string, lang: LanguageInput, options?: RenderOptions) => string;
7
- /** Highlights to a complete `<pre class="ch">` block. */
7
+ /** Highlights to a complete `<pre class="shl-code">` block. */
8
8
  export declare const highlightBlock: (code: string, lang: LanguageInput, options?: BlockOptions) => string;
9
9
  /** Tokenizes to an array — for rendering somewhere other than HTML. */
10
10
  export declare const tokenize: (code: string, lang: LanguageInput) => Token[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAGhE,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEnE,iFAAiF;AACjF,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,eAAe,CAAA;AAE9D,yEAAyE;AACzE,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,MAAM,aAAa,EAAE,UAAU,aAAa,KAAG,MAEtF,CAAA;AAED,yDAAyD;AACzD,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,MAAM,aAAa,EAAE,UAAU,YAAY,KAAG,MAE1F,CAAA;AAED,uEAAuE;AACvE,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,EAAE,MAAM,aAAa,KAAG,KAAK,EAEjE,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC3E,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC3E,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC5D,YAAY,EACV,eAAe,EACf,IAAI,EACJ,OAAO,EACP,OAAO,EACP,IAAI,EACJ,SAAS,EACT,KAAK,EACL,SAAS,EACT,KAAK,GACN,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAGhE,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEnE,iFAAiF;AACjF,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,eAAe,CAAA;AAE9D,yEAAyE;AACzE,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,MAAM,aAAa,EAAE,UAAU,aAAa,KAAG,MAEtF,CAAA;AAED,+DAA+D;AAC/D,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,MAAM,aAAa,EAAE,UAAU,YAAY,KAAG,MAE1F,CAAA;AAED,uEAAuE;AACvE,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,EAAE,MAAM,aAAa,KAAG,KAAK,EAEjE,CAAA;AAED,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC3E,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC3E,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC5D,YAAY,EACV,eAAe,EACf,IAAI,EACJ,OAAO,EACP,OAAO,EACP,IAAI,EACJ,SAAS,EACT,KAAK,EACL,SAAS,EACT,KAAK,GACN,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { tokenizeToArray } from './core/tokenize.js';
5
5
  export const highlight = (code, lang, options) => {
6
6
  return render(code, resolveGrammar(lang), options);
7
7
  };
8
- /** Highlights to a complete `<pre class="ch">` block. */
8
+ /** Highlights to a complete `<pre class="shl-code">` block. */
9
9
  export const highlightBlock = (code, lang, options) => {
10
10
  return renderBlock(code, resolveGrammar(lang), options);
11
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"csharp.d.ts","sourceRoot":"","sources":["../../src/langs/csharp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAuD5C,QAAA,MAAM,MAAM,EAAE,OAkSb,CAAA;AAED,eAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"csharp.d.ts","sourceRoot":"","sources":["../../src/langs/csharp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAuD5C,QAAA,MAAM,MAAM,EAAE,OAuSb,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -108,6 +108,12 @@ const csharp = {
108
108
  match: '\\b(?:if|else|for|foreach|while|do|switch|case|default|break|continue|return|goto|throw|try|catch|finally|yield|await|lock|when|from|select|orderby|join|into)\\b',
109
109
  scope: 'keyword.control',
110
110
  },
111
+ // `var client = …` binds a name; matched before `var` alone so the name
112
+ // is not left to the rules below.
113
+ {
114
+ match: `\\b(var)([ \\t]+)(${ID})(?=[ \\t]*[=;])`,
115
+ scope: ['keyword.declaration', null, 'variable'],
116
+ },
111
117
  {
112
118
  match: '\\b(?:class|struct|interface|enum|record|delegate|namespace|var|const|readonly|volatile|static|public|private|protected|internal|abstract|sealed|virtual|override|partial|async|event|extern|unsafe|fixed|implicit|explicit|operator|params|ref|out|where|get|set|init|required|global)\\b',
113
119
  scope: 'keyword.declaration',
@@ -137,18 +143,17 @@ const csharp = {
137
143
  match: `\\b${ID}(?=(?:${GENERIC})?(?:\\[\\])*\\??[ \\t]+(?!(?:is|as|in|when|and|or|not|switch|with)\\b)${ID}[ \\t]*[=;,){(])`,
138
144
  scope: 'type',
139
145
  },
140
- // A definition, told from a call by the return type (or the access
141
- // modifier of a constructor) sitting in front of it.
142
- {
143
- match: `${NOT_AFTER}${ID}(?=[ \\t]*(?:${GENERIC})?[ \\t]*\\()`,
144
- scope: 'function',
145
- },
146
- // A property or expression-bodied member: same shape, but `{` or `=>`
147
- // where a method has its parameter list. Scoped as a member so it looks
148
- // the same at its declaration as it does at `obj.Name`.
146
+ // A name sitting after a type (or the access modifier of a
147
+ // constructor) is being declared, and what follows says what it is:
148
+ // `(` a method, `{` or `=>` a property or expression-bodied member,
149
+ // scoped as a member so it looks the same as it does at `obj.Name`,
150
+ // and `=` or `;` a variable, `HttpClient client = …`, `int count;`. One
151
+ // rule with three endings, because each extra rule with these
152
+ // lookbehinds costs a pass at every position. A name after a spaced
153
+ // `>` is a comparison, `t = a > b;`, so the variable ending skips it.
149
154
  {
150
- match: `${NOT_AFTER}${ID}(?=[ \\t]*(?:\\{|=>))`,
151
- scope: 'variable.member',
155
+ match: `${NOT_AFTER}(?:(${ID})(?=[ \\t]*(?:${GENERIC})?[ \\t]*\\()|(${ID})(?=[ \\t]*(?:\\{|=>))|(?<![ \\t]>[ \\t])(${ID})(?=[ \\t]*(?:=(?![=>])|;)))`,
156
+ scope: ['function', 'variable.member', 'variable'],
152
157
  },
153
158
  {
154
159
  match: `\\b${ID}(?=[ \\t]*(?:${GENERIC})?[ \\t]*\\()`,
@@ -0,0 +1,4 @@
1
+ import type { Grammar } from '../core/types.js';
2
+ declare const curl: Grammar;
3
+ export default curl;
4
+ //# sourceMappingURL=curl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../src/langs/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAgB5C,QAAA,MAAM,IAAI,EAAE,OAoDX,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * cURL command lines.
3
+ *
4
+ * A curl invocation is a shell command, but reading one is nothing like
5
+ * reading a shell script: what matters is the request method and which flag
6
+ * carries which value, not control flow. `@scalar/code-highlight` shipped a
7
+ * bespoke curl grammar for that reason and `code.css` styles
8
+ * `.hljs.language-curl` to match it, so this mirrors that scoping rather than
9
+ * deferring to bash — which leaves `curl` and the method word unscoped.
10
+ */
11
+ /** The methods `--request` and `-X` accept. Matched case-insensitively. */
12
+ const METHODS = 'get|post|put|patch|delete|head|options|trace|connect';
13
+ const curl = {
14
+ name: 'curl',
15
+ states: {
16
+ root: {
17
+ // curl itself does not care about the case of a method, and neither did
18
+ // the grammar this replaces.
19
+ ignoreCase: true,
20
+ rules: [
21
+ { match: '\\bcurl\\b', scope: 'keyword' },
22
+ // The method is the most useful token on the line, so it carries its
23
+ // own scope instead of blending into the flag that introduces it.
24
+ {
25
+ match: `(^|\\s)(--request|-X)(\\s+)(${METHODS})\\b`,
26
+ scope: [null, 'constant.builtin', null, 'symbol'],
27
+ },
28
+ // Anchored to a boundary so the hyphens inside a URL or a header name
29
+ // are not mistaken for flags.
30
+ { match: '(^|\\s)(--[A-Za-z][\\w-]*)', scope: [null, 'constant.builtin'] },
31
+ { match: '(^|\\s)(-[A-Za-z])(?![\\w-])', scope: [null, 'constant.builtin'] },
32
+ // Ahead of the opening-quote rule: an escaped quote is content, not a
33
+ // string boundary.
34
+ { match: '\\\\"', scope: 'string' },
35
+ { match: '"', scope: 'string', push: 'string-double' },
36
+ { match: "'", scope: 'string', push: 'string-single' },
37
+ { match: '\\b\\d+(?:\\.\\d+)?\\b', scope: 'number' },
38
+ ],
39
+ },
40
+ 'string-double': {
41
+ default: 'string',
42
+ rules: [
43
+ { match: '\\\\.', scope: 'string.escape' },
44
+ // `$(...)` runs a command, so it reads as a value rather than text.
45
+ { match: '\\$\\(', scope: 'variable', push: 'subshell' },
46
+ { match: '"', scope: 'string', pop: true },
47
+ ],
48
+ },
49
+ subshell: {
50
+ default: 'variable',
51
+ rules: [{ match: '\\)', scope: 'variable', pop: true }],
52
+ },
53
+ // Single quotes are literal in the shell, so nothing expands inside them.
54
+ 'string-single': {
55
+ default: 'string',
56
+ rules: [{ match: "'", scope: 'string', pop: true }],
57
+ },
58
+ },
59
+ };
60
+ export default curl;
@@ -1 +1 @@
1
- {"version":3,"file":"go.d.ts","sourceRoot":"","sources":["../../src/langs/go.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,UAAU;AACV,QAAA,MAAM,EAAE,EAAE,OAsHT,CAAA;AAED,eAAe,EAAE,CAAA"}
1
+ {"version":3,"file":"go.d.ts","sourceRoot":"","sources":["../../src/langs/go.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C,UAAU;AACV,QAAA,MAAM,EAAE,EAAE,OA8HT,CAAA;AAED,eAAe,EAAE,CAAA"}
package/dist/langs/go.js CHANGED
@@ -32,6 +32,10 @@ const go = {
32
32
  match: '(package)(\\s+)([A-Za-z_]\\w*)',
33
33
  scope: ['keyword.declaration', null, 'namespace'],
34
34
  },
35
+ {
36
+ match: '\\b(var)(\\s+)([A-Za-z_]\\w*)',
37
+ scope: ['keyword.declaration', null, 'variable'],
38
+ },
35
39
  {
36
40
  match: '\\b(?:func|var|const|type|struct|interface|map|chan|package)\\b',
37
41
  scope: 'keyword.declaration',
@@ -70,6 +74,10 @@ const go = {
70
74
  match: '(\\.)([A-Za-z_]\\w*)',
71
75
  scope: ['punctuation', 'variable.member'],
72
76
  },
77
+ // The names a short declaration binds: `res, err := …`, `for i, v :=`.
78
+ // Each name looks ahead over the rest of the list to the `:=`; the list
79
+ // is capped at eight names so a long argument list stays linear.
80
+ { match: '\\b[A-Za-z_]\\w*\\b(?=(?:\\s*,\\s*[A-Za-z_]\\w*){0,7}\\s*:=)', scope: 'variable' },
73
81
  { match: '\\b[A-Z][A-Z0-9_]+\\b', scope: 'constant' },
74
82
  { match: '\\b[A-Z][A-Za-z0-9_]*\\b', scope: 'type' },
75
83
  { match: '\\b[a-z_]\\w*(?=\\s*\\()', scope: 'function.call' },
@@ -1 +1 @@
1
- {"version":3,"file":"java.d.ts","sourceRoot":"","sources":["../../src/langs/java.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AA0C5C,QAAA,MAAM,IAAI,EAAE,OA6JX,CAAA;AAED,eAAe,IAAI,CAAA"}
1
+ {"version":3,"file":"java.d.ts","sourceRoot":"","sources":["../../src/langs/java.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AA0C5C,QAAA,MAAM,IAAI,EAAE,OAoKX,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -100,18 +100,25 @@ const java = {
100
100
  },
101
101
  // A declaration is a name that follows a type, which in Java always
102
102
  // ends in an identifier character, a `>` or a `]`: `int run(`,
103
- // `Money priceOf(`, `List<T> items(`, `String[] main(`. The exclusions
104
- // are the tokens that end the same way but introduce a *call*: `->` for
105
- // a lambda body, and the keywords that can sit directly before one.
103
+ // `Money priceOf(`, `List<T> items(`, `String[] main(`. Followed by
104
+ // `(` it names a method; followed by `=`, `;` or a for-each `:` it
105
+ // names a variable: `Request request = …`, `int count;`,
106
+ // `for (Item item :`. One rule with two endings, because a second rule
107
+ // with the same lookbehinds costs a pass at every position.
106
108
  //
107
- // The reading it gets wrong: a `>` comparison against a call looks
108
- // exactly like a generic return type, so `if (a[i] > f(x))` and
109
- // `if (list.size() > max(a, b))` scope the call as a definition. A
110
- // subscript is safe — `if (xs[i]) run();` has a `)` before the space,
111
- // which the lookbehind class does not accept.
109
+ // The exclusions are the tokens that end the same way but come before
110
+ // a call or a bare value: `->` for a lambda body, the keywords that can
111
+ // sit directly before one (`return total;`, `case READY:`), and a `>`
112
+ // with a space before it, which is a comparison rather than the end of
113
+ // `List<String>`, so `if (a > f(x))` and `t = a > b;` stay as they are.
114
+ //
115
+ // The reading it still gets wrong: a comparison spaced on one side only,
116
+ // `if (a> f(x))`, scopes the call as a definition. A subscript is safe —
117
+ // `if (xs[i]) run();` has a `)` before the space, which the lookbehind
118
+ // class does not accept.
112
119
  {
113
- match: `(?<=[\\w$>\\]])(?<!->)(?<!\\b(?:return|new|throw|else|yield|assert|do))([ \\t]+)(${ID})(?=[ \\t]*\\()`,
114
- scope: [null, 'function'],
120
+ match: `(?<=[\\w$>\\]])(?<![ \\t]>)(?<!->)(?<!\\b(?:return|new|throw|else|yield|assert|do|case|break|continue))([ \\t]+)(?:(${ID})(?=[ \\t]*\\()|(${ID})(?=[ \\t]*(?:=(?!=)|;|:(?!:))))`,
121
+ scope: [null, 'function', 'variable'],
115
122
  },
116
123
  // SCREAMING_CASE reads as a constant — which also covers enum members —
117
124
  // and CapWords as a type. Between them they cover classes, interfaces
@@ -1 +1 @@
1
- {"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../src/langs/javascript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAkF5C,QAAA,MAAM,UAAU,EAAE,OAwajB,CAAA;AAED,eAAe,UAAU,CAAA"}
1
+ {"version":3,"file":"javascript.d.ts","sourceRoot":"","sources":["../../src/langs/javascript.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AA0F5C,QAAA,MAAM,UAAU,EAAE,OA6ajB,CAAA;AAED,eAAe,UAAU,CAAA"}
@@ -59,6 +59,13 @@ const NOT_TS_AFTER = '(?!>[ \\t]*\\()(?!\\s+(?:extends\\b|=))(?!>(?![ \\t]*$)(?!
59
59
  const NOT_KEY = '(?!\\??:)';
60
60
  /** A JSX tag name: a component, a member expression, or a lowercase element. */
61
61
  const TAG = '[A-Z][\\w.]*|[a-z][\\w-]*(?:[.:][\\w-]+)*';
62
+ /**
63
+ * What follows the `<` of a type argument list that leads into a call:
64
+ * `number>(` in `useState<number>(0)`. Stops at an assignment or an unmatched
65
+ * bracket; balanced function and object types are allowed, but the scan cannot
66
+ * escape into a function body.
67
+ */
68
+ const GENERIC_CALL_REST = '(?:[^;=(){}\\n]|=>|\\([^(){}\\n]{0,128}\\)|\\{[^{}()\\n]{0,128}\\}){1,512}>[ \\t]*\\(';
62
69
  /**
63
70
  * What follows a name that is assigned a function: `= () =>`, `= async x =>`,
64
71
  * `= function`, and the generic `= <T,>(x: T) =>`. The parameter list cannot
@@ -195,7 +202,12 @@ const javascript = {
195
202
  // Requiring no space before the colon keeps `cond ? a : b` out.
196
203
  { match: `\\b${ID}(?=\\??:)`, scope: 'property' },
197
204
  { match: `\\b${ID}(?=\\s*=>)`, scope: 'variable.parameter' },
198
- { match: `\\b${ID}(?=[ \\t]*[(<]|\`)`, scope: 'function.call' },
205
+ { match: `\\b${ID}(?=[ \\t]*\\(|\`)`, scope: 'function.call' },
206
+ // A generic call such as `useState<number>(0)`. The argument list has to
207
+ // close and be followed by `(`, so a comparison like `count <= max` is
208
+ // not mistaken for a call. The body mirrors the generic-call scan in
209
+ // `nesting`, which bounds it so a long line cannot make it quadratic.
210
+ { match: `\\b${ID}(?=[ \\t]*<${GENERIC_CALL_REST})`, scope: 'function.call' },
199
211
  {
200
212
  // Bare `=` goes last so `=>`, `==`, `===` and the compound forms all
201
213
  // get first refusal. Without it plain assignment matched nothing.
@@ -310,7 +322,7 @@ const javascript = {
310
322
  // assignment or an unmatched closing parenthesis or brace. Balanced function/object
311
323
  // types are allowed, but the scan cannot escape into the function body.
312
324
  {
313
- match: '<(?=(?:[^;=(){}\\n]|=>|\\([^(){}\\n]{0,128}\\)|\\{[^{}()\\n]{0,128}\\}){1,512}>[ \\t]*\\()',
325
+ match: `<(?=${GENERIC_CALL_REST})`,
314
326
  scope: 'punctuation.bracket',
315
327
  push: 'type-angle',
316
328
  },
@@ -1 +1 @@
1
- {"version":3,"file":"powershell.d.ts","sourceRoot":"","sources":["../../src/langs/powershell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AA8D5C,QAAA,MAAM,UAAU,EAAE,OAoRjB,CAAA;AAED,eAAe,UAAU,CAAA"}
1
+ {"version":3,"file":"powershell.d.ts","sourceRoot":"","sources":["../../src/langs/powershell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AA8D5C,QAAA,MAAM,UAAU,EAAE,OAuRjB,CAAA;AAED,eAAe,UAAU,CAAA"}
@@ -163,7 +163,10 @@ const powershell = {
163
163
  // to be a lookbehind rather than a consumed separator, because the
164
164
  // merged regex picks the leftmost match before it picks the
165
165
  // higher-priority rule — eating the space would make `-eq` a parameter.
166
- { match: '(?<![\\w)\\]}\'"])-[a-z]\\w*', scope: 'variable.parameter' },
166
+ // Scoped as a constant, as Bash scopes a flag, so `-Uri` and `--request`
167
+ // look alike; the parameter scope is kept for the names a script
168
+ // declares in `param(…)`.
169
+ { match: '(?<![\\w)\\]}\'"])-[a-z]\\w*', scope: 'constant' },
167
170
  { match: `\\b${ID}(?=\\()`, scope: 'function.call' },
168
171
  // ---- numbers -------------------------------------------------------
169
172
  {
@@ -1 +1 @@
1
- {"version":3,"file":"rust.d.ts","sourceRoot":"","sources":["../../src/langs/rust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C;;;;;GAKG;AACH,QAAA,MAAM,IAAI,EAAE,OAsIX,CAAA;AAED,eAAe,IAAI,CAAA"}
1
+ {"version":3,"file":"rust.d.ts","sourceRoot":"","sources":["../../src/langs/rust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C;;;;;GAKG;AACH,QAAA,MAAM,IAAI,EAAE,OA6IX,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -47,6 +47,13 @@ const rust = {
47
47
  match: '(fn)(\\s+)([A-Za-z_]\\w*)',
48
48
  scope: ['keyword.declaration', null, 'function'],
49
49
  },
50
+ // `let client =` and `let mut count =` bind a name. A capitalised word
51
+ // after `let` is a pattern (`let Some(x) =`), so it is left to the
52
+ // type rules.
53
+ {
54
+ match: '\\b(let)(\\s+)(?:(mut)(\\s+))?((?:r#)?[a-z_]\\w*)',
55
+ scope: ['keyword.declaration', null, 'keyword.declaration', null, 'variable'],
56
+ },
50
57
  {
51
58
  match: '\\b(?:fn|let|const|static|struct|enum|trait|impl|type|mod|union|async|move|dyn|pub|crate|unsafe|extern|ref|mut|where)\\b',
52
59
  scope: 'keyword.declaration',
package/dist/lazy.d.ts CHANGED
@@ -17,6 +17,7 @@ declare const loaders: {
17
17
  cpp: () => Promise<typeof import("./langs/cpp.js")>;
18
18
  csharp: () => Promise<typeof import("./langs/csharp.js")>;
19
19
  css: () => Promise<typeof import("./langs/css.js")>;
20
+ curl: () => Promise<typeof import("./langs/curl.js")>;
20
21
  dart: () => Promise<typeof import("./langs/dart.js")>;
21
22
  diff: () => Promise<typeof import("./langs/diff.js")>;
22
23
  dockerfile: () => Promise<typeof import("./langs/dockerfile.js")>;
@@ -1 +1 @@
1
- {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../src/lazy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD;;;;;;;;;;GAUG;AACH,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CkD,CAAA;AAE/D,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,OAAO,CAAA;AAsGlD,eAAO,MAAM,gBAAgB,EAA2B,eAAe,EAAE,CAAA;AAEzE,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,eAAe,GAAG,SASpE,CAAA;AAID;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,OAAO,CAAC,eAAe,CA4BlE,CAAA;AAED,uCAAuC;AACvC,eAAO,MAAM,aAAa,GAAI,GAAG,OAAO,MAAM,EAAE,KAAG,OAAO,CAAC,eAAe,EAAE,CAE3E,CAAA"}
1
+ {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../src/lazy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD;;;;;;;;;;GAUG;AACH,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CkD,CAAA;AAE/D,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,OAAO,CAAA;AAqGlD,eAAO,MAAM,gBAAgB,EAA2B,eAAe,EAAE,CAAA;AAEzE,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,KAAG,eAAe,GAAG,SASpE,CAAA;AAID;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,OAAO,CAAC,eAAe,CA4BlE,CAAA;AAED,uCAAuC;AACvC,eAAO,MAAM,aAAa,GAAI,GAAG,OAAO,MAAM,EAAE,KAAG,OAAO,CAAC,eAAe,EAAE,CAE3E,CAAA"}
package/dist/lazy.js CHANGED
@@ -17,6 +17,7 @@ const loaders = {
17
17
  cpp: () => import('./langs/cpp.js'),
18
18
  csharp: () => import('./langs/csharp.js'),
19
19
  css: () => import('./langs/css.js'),
20
+ curl: () => import('./langs/curl.js'),
20
21
  dart: () => import('./langs/dart.js'),
21
22
  diff: () => import('./langs/diff.js'),
22
23
  dockerfile: () => import('./langs/dockerfile.js'),
@@ -72,7 +73,6 @@ const aliases = {
72
73
  containerfile: 'dockerfile',
73
74
  cppm: 'cpp',
74
75
  cs: 'csharp',
75
- curl: 'bash',
76
76
  cxx: 'cpp',
77
77
  docker: 'dockerfile',
78
78
  edn: 'clojure',
package/dist/style.css CHANGED
@@ -258,6 +258,7 @@
258
258
  }
259
259
 
260
260
  .shl-code .shl-fb,
261
+ .shl-code .shl-sy,
261
262
  .shl-code .shl-o {
262
263
  color: var(--scalar-hl-builtin);
263
264
  }
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "code",
17
17
  "performance"
18
18
  ],
19
- "version": "0.5.0",
19
+ "version": "0.6.1",
20
20
  "engines": {
21
21
  "node": ">=22"
22
22
  },
@@ -69,13 +69,13 @@
69
69
  "**/*.css"
70
70
  ],
71
71
  "dependencies": {
72
- "@types/hast": "^3.0.4"
72
+ "@types/hast": "^3.0.5"
73
73
  },
74
74
  "devDependencies": {
75
- "@scalar/code-highlight": "0.4.10",
76
- "highlight.js": "^11.11.1",
77
- "rolldown": "1.1.5",
78
- "vitest": "4.1.10"
75
+ "@scalar/code-highlight": "0.4.15",
76
+ "highlight.js": "^11.12.0",
77
+ "rolldown": "1.2.14",
78
+ "vitest": "5.0.5"
79
79
  },
80
80
  "scripts": {
81
81
  "bench": "tsx bench/bench.ts",