@shikijs/core 1.19.0 → 1.20.0

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/dist/index.d.mts CHANGED
@@ -1,8 +1,7 @@
1
- import { CreatedBundledHighlighterOptions, CreateHighlighterFactory, LanguageInput, ThemeInput, HighlighterCoreOptions, CodeToHastOptions, CodeToTokensOptions, TokensResult, RequireKeys, CodeToTokensBaseOptions, ThemedToken, CodeToTokensWithThemesOptions, ThemedTokenWithVariants, BundledHighlighterOptions, HighlighterGeneric, GrammarState, HighlighterCore, ShikiInternal, RegexEngine, LoadWasmOptions, ShikiTransformerContextCommon, CodeToHastRenderOptions, ShikiTransformerContextSource, ThemeRegistrationResolved, TokenizeWithThemeOptions, ThemeRegistrationAny, ShikiTransformer, MaybeArray, PlainTextLanguage, SpecialLanguage, SpecialTheme, MaybeGetter, TokenStyles, Position } from '@shikijs/types';
1
+ import { CreatedBundledHighlighterOptions, CreateHighlighterFactory, LanguageInput, ThemeInput, HighlighterCoreOptions, CodeToHastOptions, CodeToTokensOptions, TokensResult, RequireKeys, CodeToTokensBaseOptions, ThemedToken, CodeToTokensWithThemesOptions, ThemedTokenWithVariants, BundledHighlighterOptions, HighlighterGeneric, GrammarState, HighlighterCore, ShikiInternal, RegexEngine, LoadWasmOptions, ShikiTransformerContextCommon, CodeToHastRenderOptions, ShikiTransformerContextSource, ThemeRegistrationResolved, TokenizeWithThemeOptions, ThemeRegistrationAny, ThemeRegistration, ShikiTransformer, MaybeArray, PlainTextLanguage, SpecialLanguage, SpecialTheme, MaybeGetter, TokenStyles, Position } from '@shikijs/types';
2
2
  export * from '@shikijs/types';
3
3
  import { Root, Element } from 'hast';
4
4
  import { JavaScriptRegexEngineOptions } from '@shikijs/engine-javascript';
5
- export { defaultJavaScriptRegexConstructor } from '@shikijs/engine-javascript';
6
5
  import { IGrammar } from '@shikijs/vscode-textmate';
7
6
  export { FontStyle, EncodedTokenMetadata as StackElementMetadata } from '@shikijs/vscode-textmate';
8
7
  export { toHtml as hastToHtml } from 'hast-util-to-html';
@@ -21,7 +20,7 @@ export { toHtml as hastToHtml } from 'hast-util-to-html';
21
20
  * nord: () => import('shiki/themes/nord.mjs'),
22
21
  * // ...
23
22
  * },
24
- * engine: () => createWasmOnigEngine(), // or createJavaScriptRegexEngine()
23
+ * engine: () => createOnigurumaEngine(), // or createJavaScriptRegexEngine()
25
24
  * })
26
25
  * ```
27
26
  *
@@ -122,9 +121,26 @@ declare function getShikiInternal(options?: HighlighterCoreOptions): Promise<Shi
122
121
  */
123
122
  declare function createShikiInternalSync(options: HighlighterCoreOptions<true>): ShikiInternal;
124
123
 
124
+ /**
125
+ * @deprecated Import `createJavaScriptRegexEngine` from `@shikijs/engine-javascript` or `shiki/engine/javascript` instead.
126
+ */
125
127
  declare function createJavaScriptRegexEngine(options?: JavaScriptRegexEngineOptions): RegexEngine;
128
+ /**
129
+ * @deprecated Import `defaultJavaScriptRegexConstructor` from `@shikijs/engine-javascript` or `shiki/engine/javascript` instead.
130
+ */
131
+ declare function defaultJavaScriptRegexConstructor(pattern: string): RegExp;
126
132
 
133
+ /**
134
+ * @deprecated Import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead.
135
+ */
136
+ declare function createOnigurumaEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
137
+ /**
138
+ * @deprecated Import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead.
139
+ */
127
140
  declare function createWasmOnigEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
141
+ /**
142
+ * @deprecated Import `loadWasm` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead.
143
+ */
128
144
  declare function loadWasm(options: LoadWasmOptions): Promise<void>;
129
145
 
130
146
  declare function codeToHast(internal: ShikiInternal, code: string, options: CodeToHastOptions, transformerContext?: ShikiTransformerContextCommon): Root;
@@ -160,6 +176,39 @@ declare function codeToTokensWithThemes(internal: ShikiInternal, code: string, o
160
176
  */
161
177
  declare function normalizeTheme(rawTheme: ThemeRegistrationAny): ThemeRegistrationResolved;
162
178
 
179
+ interface CssVariablesThemeOptions {
180
+ /**
181
+ * Theme name. Need to unique if multiple css variables themes are created
182
+ *
183
+ * @default 'css-variables'
184
+ */
185
+ name?: string;
186
+ /**
187
+ * Prefix for css variables
188
+ *
189
+ * @default '--shiki-'
190
+ */
191
+ variablePrefix?: string;
192
+ /**
193
+ * Default value for css variables, the key is without the prefix
194
+ *
195
+ * @example `{ 'token-comment': '#888' }` will generate `var(--shiki-token-comment, #888)` for comments
196
+ */
197
+ variableDefaults?: Record<string, string>;
198
+ /**
199
+ * Enable font style
200
+ *
201
+ * @default true
202
+ */
203
+ fontStyle?: boolean;
204
+ }
205
+ /**
206
+ * A factory function to create a css-variable-based theme
207
+ *
208
+ * @see https://shiki.style/guide/theme-colors#css-variables-theme
209
+ */
210
+ declare function createCssVariablesTheme(options?: CssVariablesThemeOptions): ThemeRegistration;
211
+
163
212
  /**
164
213
  * A built-in transformer to add decorations to the highlighted code.
165
214
  */
@@ -243,4 +292,4 @@ declare function enableDeprecationWarnings(value?: boolean): void;
243
292
  */
244
293
  declare function warnDeprecated(message: string): void;
245
294
 
246
- export { type ShorthandsBundle, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighterCore, createHighlighterCoreSync, createJavaScriptRegexEngine, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createWasmOnigEngine, createdBundledHighlighter, enableDeprecationWarnings, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, loadWasm, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
295
+ export { type CssVariablesThemeOptions, type ShorthandsBundle, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createCssVariablesTheme, createHighlighterCore, createHighlighterCoreSync, createJavaScriptRegexEngine, createOnigurumaEngine, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createWasmOnigEngine, createdBundledHighlighter, defaultJavaScriptRegexConstructor, enableDeprecationWarnings, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, loadWasm, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { CreatedBundledHighlighterOptions, CreateHighlighterFactory, LanguageInput, ThemeInput, HighlighterCoreOptions, CodeToHastOptions, CodeToTokensOptions, TokensResult, RequireKeys, CodeToTokensBaseOptions, ThemedToken, CodeToTokensWithThemesOptions, ThemedTokenWithVariants, BundledHighlighterOptions, HighlighterGeneric, GrammarState, HighlighterCore, ShikiInternal, RegexEngine, LoadWasmOptions, ShikiTransformerContextCommon, CodeToHastRenderOptions, ShikiTransformerContextSource, ThemeRegistrationResolved, TokenizeWithThemeOptions, ThemeRegistrationAny, ShikiTransformer, MaybeArray, PlainTextLanguage, SpecialLanguage, SpecialTheme, MaybeGetter, TokenStyles, Position } from '@shikijs/types';
1
+ import { CreatedBundledHighlighterOptions, CreateHighlighterFactory, LanguageInput, ThemeInput, HighlighterCoreOptions, CodeToHastOptions, CodeToTokensOptions, TokensResult, RequireKeys, CodeToTokensBaseOptions, ThemedToken, CodeToTokensWithThemesOptions, ThemedTokenWithVariants, BundledHighlighterOptions, HighlighterGeneric, GrammarState, HighlighterCore, ShikiInternal, RegexEngine, LoadWasmOptions, ShikiTransformerContextCommon, CodeToHastRenderOptions, ShikiTransformerContextSource, ThemeRegistrationResolved, TokenizeWithThemeOptions, ThemeRegistrationAny, ThemeRegistration, ShikiTransformer, MaybeArray, PlainTextLanguage, SpecialLanguage, SpecialTheme, MaybeGetter, TokenStyles, Position } from '@shikijs/types';
2
2
  export * from '@shikijs/types';
3
3
  import { Root, Element } from 'hast';
4
4
  import { JavaScriptRegexEngineOptions } from '@shikijs/engine-javascript';
5
- export { defaultJavaScriptRegexConstructor } from '@shikijs/engine-javascript';
6
5
  import { IGrammar } from '@shikijs/vscode-textmate';
7
6
  export { FontStyle, EncodedTokenMetadata as StackElementMetadata } from '@shikijs/vscode-textmate';
8
7
  export { toHtml as hastToHtml } from 'hast-util-to-html';
@@ -21,7 +20,7 @@ export { toHtml as hastToHtml } from 'hast-util-to-html';
21
20
  * nord: () => import('shiki/themes/nord.mjs'),
22
21
  * // ...
23
22
  * },
24
- * engine: () => createWasmOnigEngine(), // or createJavaScriptRegexEngine()
23
+ * engine: () => createOnigurumaEngine(), // or createJavaScriptRegexEngine()
25
24
  * })
26
25
  * ```
27
26
  *
@@ -122,9 +121,26 @@ declare function getShikiInternal(options?: HighlighterCoreOptions): Promise<Shi
122
121
  */
123
122
  declare function createShikiInternalSync(options: HighlighterCoreOptions<true>): ShikiInternal;
124
123
 
124
+ /**
125
+ * @deprecated Import `createJavaScriptRegexEngine` from `@shikijs/engine-javascript` or `shiki/engine/javascript` instead.
126
+ */
125
127
  declare function createJavaScriptRegexEngine(options?: JavaScriptRegexEngineOptions): RegexEngine;
128
+ /**
129
+ * @deprecated Import `defaultJavaScriptRegexConstructor` from `@shikijs/engine-javascript` or `shiki/engine/javascript` instead.
130
+ */
131
+ declare function defaultJavaScriptRegexConstructor(pattern: string): RegExp;
126
132
 
133
+ /**
134
+ * @deprecated Import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead.
135
+ */
136
+ declare function createOnigurumaEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
137
+ /**
138
+ * @deprecated Import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead.
139
+ */
127
140
  declare function createWasmOnigEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
141
+ /**
142
+ * @deprecated Import `loadWasm` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead.
143
+ */
128
144
  declare function loadWasm(options: LoadWasmOptions): Promise<void>;
129
145
 
130
146
  declare function codeToHast(internal: ShikiInternal, code: string, options: CodeToHastOptions, transformerContext?: ShikiTransformerContextCommon): Root;
@@ -160,6 +176,39 @@ declare function codeToTokensWithThemes(internal: ShikiInternal, code: string, o
160
176
  */
161
177
  declare function normalizeTheme(rawTheme: ThemeRegistrationAny): ThemeRegistrationResolved;
162
178
 
179
+ interface CssVariablesThemeOptions {
180
+ /**
181
+ * Theme name. Need to unique if multiple css variables themes are created
182
+ *
183
+ * @default 'css-variables'
184
+ */
185
+ name?: string;
186
+ /**
187
+ * Prefix for css variables
188
+ *
189
+ * @default '--shiki-'
190
+ */
191
+ variablePrefix?: string;
192
+ /**
193
+ * Default value for css variables, the key is without the prefix
194
+ *
195
+ * @example `{ 'token-comment': '#888' }` will generate `var(--shiki-token-comment, #888)` for comments
196
+ */
197
+ variableDefaults?: Record<string, string>;
198
+ /**
199
+ * Enable font style
200
+ *
201
+ * @default true
202
+ */
203
+ fontStyle?: boolean;
204
+ }
205
+ /**
206
+ * A factory function to create a css-variable-based theme
207
+ *
208
+ * @see https://shiki.style/guide/theme-colors#css-variables-theme
209
+ */
210
+ declare function createCssVariablesTheme(options?: CssVariablesThemeOptions): ThemeRegistration;
211
+
163
212
  /**
164
213
  * A built-in transformer to add decorations to the highlighted code.
165
214
  */
@@ -243,4 +292,4 @@ declare function enableDeprecationWarnings(value?: boolean): void;
243
292
  */
244
293
  declare function warnDeprecated(message: string): void;
245
294
 
246
- export { type ShorthandsBundle, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighterCore, createHighlighterCoreSync, createJavaScriptRegexEngine, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createWasmOnigEngine, createdBundledHighlighter, enableDeprecationWarnings, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, loadWasm, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
295
+ export { type CssVariablesThemeOptions, type ShorthandsBundle, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createCssVariablesTheme, createHighlighterCore, createHighlighterCoreSync, createJavaScriptRegexEngine, createOnigurumaEngine, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createWasmOnigEngine, createdBundledHighlighter, defaultJavaScriptRegexConstructor, enableDeprecationWarnings, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, loadWasm, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
package/dist/index.mjs CHANGED
@@ -1,18 +1,21 @@
1
1
  import { ShikiError as ShikiError$1 } from '@shikijs/types';
2
2
  export * from '@shikijs/types';
3
- import { createWasmOnigEngine as createWasmOnigEngine$1, loadWasm as loadWasm$1, getDefaultWasmLoader } from '@shikijs/engine-oniguruma';
3
+ import { createOnigurumaEngine as createOnigurumaEngine$1, loadWasm as loadWasm$1, getDefaultWasmLoader } from '@shikijs/engine-oniguruma';
4
4
  import { w as warnDeprecated } from './shared/core.afb6276c.mjs';
5
5
  export { e as enableDeprecationWarnings } from './shared/core.afb6276c.mjs';
6
6
  import { FontStyle, INITIAL, EncodedTokenMetadata, Registry as Registry$1, Theme } from '@shikijs/vscode-textmate';
7
7
  export { FontStyle, EncodedTokenMetadata as StackElementMetadata } from '@shikijs/vscode-textmate';
8
8
  import { toHtml } from 'hast-util-to-html';
9
9
  export { toHtml as hastToHtml } from 'hast-util-to-html';
10
- import { createJavaScriptRegexEngine as createJavaScriptRegexEngine$1 } from '@shikijs/engine-javascript';
11
- export { defaultJavaScriptRegexConstructor } from '@shikijs/engine-javascript';
10
+ import { createJavaScriptRegexEngine as createJavaScriptRegexEngine$1, defaultJavaScriptRegexConstructor as defaultJavaScriptRegexConstructor$1 } from '@shikijs/engine-javascript';
12
11
 
12
+ function createOnigurumaEngine(options) {
13
+ warnDeprecated("import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead");
14
+ return createOnigurumaEngine$1(options);
15
+ }
13
16
  function createWasmOnigEngine(options) {
14
- warnDeprecated("import `createWasmOnigEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead");
15
- return createWasmOnigEngine$1(options);
17
+ warnDeprecated("import `createOnigurumaEngine` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead");
18
+ return createOnigurumaEngine$1(options);
16
19
  }
17
20
  function loadWasm(options) {
18
21
  warnDeprecated("import `loadWasm` from `@shikijs/engine-oniguruma` or `shiki/engine/oniguruma` instead");
@@ -1701,7 +1704,7 @@ function createShikiInternalSync(options) {
1701
1704
 
1702
1705
  async function createShikiInternal(options = {}) {
1703
1706
  if (options.loadWasm) {
1704
- warnDeprecated("`loadWasm` option is deprecated. Use `engine: createWasmOnigEngine(loadWasm)` instead.");
1707
+ warnDeprecated("`loadWasm` option is deprecated. Use `engine: createOnigurumaEngine(loadWasm)` instead.");
1705
1708
  }
1706
1709
  const [
1707
1710
  themes,
@@ -1710,7 +1713,7 @@ async function createShikiInternal(options = {}) {
1710
1713
  ] = await Promise.all([
1711
1714
  resolveThemes(options.themes || []),
1712
1715
  resolveLangs(options.langs || []),
1713
- options.engine || createWasmOnigEngine$1(options.loadWasm || getDefaultWasmLoader())
1716
+ options.engine || createOnigurumaEngine$1(options.loadWasm || getDefaultWasmLoader())
1714
1717
  ]);
1715
1718
  return createShikiInternalSync({
1716
1719
  ...options,
@@ -1786,7 +1789,7 @@ function createdBundledHighlighter(arg1, arg2, arg3) {
1786
1789
  warnDeprecated("`createdBundledHighlighter` signature with `bundledLanguages` and `bundledThemes` is deprecated. Use the options object signature instead.");
1787
1790
  bundledLanguages = arg1;
1788
1791
  bundledThemes = arg2;
1789
- engine = () => createWasmOnigEngine(arg3);
1792
+ engine = () => createOnigurumaEngine(arg3);
1790
1793
  } else {
1791
1794
  const options = arg1;
1792
1795
  bundledLanguages = options.langs;
@@ -1912,5 +1915,244 @@ function createJavaScriptRegexEngine(options) {
1912
1915
  warnDeprecated("import `createJavaScriptRegexEngine` from `@shikijs/engine-javascript` or `shiki/engine/javascript` instead");
1913
1916
  return createJavaScriptRegexEngine$1(options);
1914
1917
  }
1918
+ function defaultJavaScriptRegexConstructor(pattern) {
1919
+ warnDeprecated("import `defaultJavaScriptRegexConstructor` from `@shikijs/engine-javascript` or `shiki/engine/javascript` instead");
1920
+ return defaultJavaScriptRegexConstructor$1(pattern);
1921
+ }
1922
+
1923
+ function createCssVariablesTheme(options = {}) {
1924
+ const {
1925
+ name = "css-variables",
1926
+ variablePrefix = "--shiki-",
1927
+ fontStyle = true
1928
+ } = options;
1929
+ const variable = (name2) => {
1930
+ if (options.variableDefaults?.[name2])
1931
+ return `var(${variablePrefix}${name2}, ${options.variableDefaults[name2]})`;
1932
+ return `var(${variablePrefix}${name2})`;
1933
+ };
1934
+ const theme = {
1935
+ name,
1936
+ type: "dark",
1937
+ colors: {
1938
+ "editor.foreground": variable("foreground"),
1939
+ "editor.background": variable("background"),
1940
+ "terminal.ansiBlack": variable("ansi-black"),
1941
+ "terminal.ansiRed": variable("ansi-red"),
1942
+ "terminal.ansiGreen": variable("ansi-green"),
1943
+ "terminal.ansiYellow": variable("ansi-yellow"),
1944
+ "terminal.ansiBlue": variable("ansi-blue"),
1945
+ "terminal.ansiMagenta": variable("ansi-magenta"),
1946
+ "terminal.ansiCyan": variable("ansi-cyan"),
1947
+ "terminal.ansiWhite": variable("ansi-white"),
1948
+ "terminal.ansiBrightBlack": variable("ansi-bright-black"),
1949
+ "terminal.ansiBrightRed": variable("ansi-bright-red"),
1950
+ "terminal.ansiBrightGreen": variable("ansi-bright-green"),
1951
+ "terminal.ansiBrightYellow": variable("ansi-bright-yellow"),
1952
+ "terminal.ansiBrightBlue": variable("ansi-bright-blue"),
1953
+ "terminal.ansiBrightMagenta": variable("ansi-bright-magenta"),
1954
+ "terminal.ansiBrightCyan": variable("ansi-bright-cyan"),
1955
+ "terminal.ansiBrightWhite": variable("ansi-bright-white")
1956
+ },
1957
+ tokenColors: [
1958
+ {
1959
+ scope: [
1960
+ "keyword.operator.accessor",
1961
+ "meta.group.braces.round.function.arguments",
1962
+ "meta.template.expression",
1963
+ "markup.fenced_code meta.embedded.block"
1964
+ ],
1965
+ settings: {
1966
+ foreground: variable("foreground")
1967
+ }
1968
+ },
1969
+ {
1970
+ scope: "emphasis",
1971
+ settings: {
1972
+ fontStyle: "italic"
1973
+ }
1974
+ },
1975
+ {
1976
+ scope: ["strong", "markup.heading.markdown", "markup.bold.markdown"],
1977
+ settings: {
1978
+ fontStyle: "bold"
1979
+ }
1980
+ },
1981
+ {
1982
+ scope: ["markup.italic.markdown"],
1983
+ settings: {
1984
+ fontStyle: "italic"
1985
+ }
1986
+ },
1987
+ {
1988
+ scope: "meta.link.inline.markdown",
1989
+ settings: {
1990
+ fontStyle: "underline",
1991
+ foreground: variable("token-link")
1992
+ }
1993
+ },
1994
+ {
1995
+ scope: ["string", "markup.fenced_code", "markup.inline"],
1996
+ settings: {
1997
+ foreground: variable("token-string")
1998
+ }
1999
+ },
2000
+ {
2001
+ scope: ["comment", "string.quoted.docstring.multi"],
2002
+ settings: {
2003
+ foreground: variable("token-comment")
2004
+ }
2005
+ },
2006
+ {
2007
+ scope: [
2008
+ "constant.numeric",
2009
+ "constant.language",
2010
+ "constant.other.placeholder",
2011
+ "constant.character.format.placeholder",
2012
+ "variable.language.this",
2013
+ "variable.other.object",
2014
+ "variable.other.class",
2015
+ "variable.other.constant",
2016
+ "meta.property-name",
2017
+ "meta.property-value",
2018
+ "support"
2019
+ ],
2020
+ settings: {
2021
+ foreground: variable("token-constant")
2022
+ }
2023
+ },
2024
+ {
2025
+ scope: [
2026
+ "keyword",
2027
+ "storage.modifier",
2028
+ "storage.type",
2029
+ "storage.control.clojure",
2030
+ "entity.name.function.clojure",
2031
+ "entity.name.tag.yaml",
2032
+ "support.function.node",
2033
+ "support.type.property-name.json",
2034
+ "punctuation.separator.key-value",
2035
+ "punctuation.definition.template-expression"
2036
+ ],
2037
+ settings: {
2038
+ foreground: variable("token-keyword")
2039
+ }
2040
+ },
2041
+ {
2042
+ scope: "variable.parameter.function",
2043
+ settings: {
2044
+ foreground: variable("token-parameter")
2045
+ }
2046
+ },
2047
+ {
2048
+ scope: [
2049
+ "support.function",
2050
+ "entity.name.type",
2051
+ "entity.other.inherited-class",
2052
+ "meta.function-call",
2053
+ "meta.instance.constructor",
2054
+ "entity.other.attribute-name",
2055
+ "entity.name.function",
2056
+ "constant.keyword.clojure"
2057
+ ],
2058
+ settings: {
2059
+ foreground: variable("token-function")
2060
+ }
2061
+ },
2062
+ {
2063
+ scope: [
2064
+ "entity.name.tag",
2065
+ "string.quoted",
2066
+ "string.regexp",
2067
+ "string.interpolated",
2068
+ "string.template",
2069
+ "string.unquoted.plain.out.yaml",
2070
+ "keyword.other.template"
2071
+ ],
2072
+ settings: {
2073
+ foreground: variable("token-string-expression")
2074
+ }
2075
+ },
2076
+ {
2077
+ scope: [
2078
+ "punctuation.definition.arguments",
2079
+ "punctuation.definition.dict",
2080
+ "punctuation.separator",
2081
+ "meta.function-call.arguments"
2082
+ ],
2083
+ settings: {
2084
+ foreground: variable("token-punctuation")
2085
+ }
2086
+ },
2087
+ {
2088
+ // [Custom] Markdown links
2089
+ scope: [
2090
+ "markup.underline.link",
2091
+ "punctuation.definition.metadata.markdown"
2092
+ ],
2093
+ settings: {
2094
+ foreground: variable("token-link")
2095
+ }
2096
+ },
2097
+ {
2098
+ // [Custom] Markdown list
2099
+ scope: ["beginning.punctuation.definition.list.markdown"],
2100
+ settings: {
2101
+ foreground: variable("token-string")
2102
+ }
2103
+ },
2104
+ {
2105
+ // [Custom] Markdown punctuation definition brackets
2106
+ scope: [
2107
+ "punctuation.definition.string.begin.markdown",
2108
+ "punctuation.definition.string.end.markdown",
2109
+ "string.other.link.title.markdown",
2110
+ "string.other.link.description.markdown"
2111
+ ],
2112
+ settings: {
2113
+ foreground: variable("token-keyword")
2114
+ }
2115
+ },
2116
+ {
2117
+ // [Custom] Diff
2118
+ scope: [
2119
+ "markup.inserted",
2120
+ "meta.diff.header.to-file",
2121
+ "punctuation.definition.inserted"
2122
+ ],
2123
+ settings: {
2124
+ foreground: variable("token-inserted")
2125
+ }
2126
+ },
2127
+ {
2128
+ scope: [
2129
+ "markup.deleted",
2130
+ "meta.diff.header.from-file",
2131
+ "punctuation.definition.deleted"
2132
+ ],
2133
+ settings: {
2134
+ foreground: variable("token-deleted")
2135
+ }
2136
+ },
2137
+ {
2138
+ scope: [
2139
+ "markup.changed",
2140
+ "punctuation.definition.changed"
2141
+ ],
2142
+ settings: {
2143
+ foreground: variable("token-changed")
2144
+ }
2145
+ }
2146
+ ]
2147
+ };
2148
+ if (!fontStyle) {
2149
+ theme.tokenColors = theme.tokenColors?.map((tokenColor) => {
2150
+ if (tokenColor.settings?.fontStyle)
2151
+ delete tokenColor.settings.fontStyle;
2152
+ return tokenColor;
2153
+ });
2154
+ }
2155
+ return theme;
2156
+ }
1915
2157
 
1916
- export { addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighterCore, createHighlighterCoreSync, createJavaScriptRegexEngine, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createWasmOnigEngine, createdBundledHighlighter, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, loadWasm, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
2158
+ export { addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createCssVariablesTheme, createHighlighterCore, createHighlighterCoreSync, createJavaScriptRegexEngine, createOnigurumaEngine, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createWasmOnigEngine, createdBundledHighlighter, defaultJavaScriptRegexConstructor, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, loadWasm, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shikijs/core",
3
3
  "type": "module",
4
- "version": "1.19.0",
4
+ "version": "1.20.0",
5
5
  "description": "Core of Shiki",
6
6
  "author": "Pine Wu <octref@gmail.com>; Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -63,9 +63,9 @@
63
63
  "@shikijs/vscode-textmate": "^9.2.2",
64
64
  "@types/hast": "^3.0.4",
65
65
  "hast-util-to-html": "^9.0.3",
66
- "@shikijs/engine-javascript": "1.19.0",
67
- "@shikijs/engine-oniguruma": "1.19.0",
68
- "@shikijs/types": "1.19.0"
66
+ "@shikijs/engine-javascript": "1.20.0",
67
+ "@shikijs/engine-oniguruma": "1.20.0",
68
+ "@shikijs/types": "1.20.0"
69
69
  },
70
70
  "scripts": {
71
71
  "build": "unbuild",