@shikijs/colorized-brackets 3.2.2 → 3.4.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 +1 -1
- package/dist/index.mjs +10 -2
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -53,7 +53,7 @@ interface BracketPair {
|
|
|
53
53
|
*
|
|
54
54
|
* @param options
|
|
55
55
|
* @param options.themes - custom themes; all Shiki built-in themes are supported without additional configuration
|
|
56
|
-
* @param options.bracketPairs - bracket definitions;
|
|
56
|
+
* @param options.bracketPairs - bracket definitions; by default [], {}, (), and <> (TS-only)
|
|
57
57
|
* @param options.langs - language-specific overrides for themes and bracketPairs
|
|
58
58
|
* @returns Shiki transformer
|
|
59
59
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -584,7 +584,7 @@ function assignColorToToken(token, themes, shikiOptions, level) {
|
|
|
584
584
|
token.color = getColor(themes, themeName, level);
|
|
585
585
|
} else {
|
|
586
586
|
const { defaultColor = "light", cssVariablePrefix = "--shiki-" } = shikiOptions;
|
|
587
|
-
const styles = typeof token.htmlStyle === "string" ? {} : token.htmlStyle
|
|
587
|
+
const styles = typeof token.htmlStyle === "string" ? {} : structuredClone(token.htmlStyle ?? {});
|
|
588
588
|
for (const [colorName, theme] of Object.entries(shikiOptions.themes)) {
|
|
589
589
|
const themeName = typeof theme === "string" ? theme : theme?.name;
|
|
590
590
|
const cssProperty = colorName === defaultColor ? "color" : `${cssVariablePrefix}${colorName}`;
|
|
@@ -603,7 +603,7 @@ const DEFAULT_BRACKETS_COLORS = [
|
|
|
603
603
|
"rgba(255, 18, 18, 0.8)"
|
|
604
604
|
];
|
|
605
605
|
function getColor(themes, themeName, level) {
|
|
606
|
-
const colors = themeName == null ? DEFAULT_BRACKETS_COLORS :
|
|
606
|
+
const colors = themeName == null ? DEFAULT_BRACKETS_COLORS : getThemeColors(themeName, themes) ?? getThemeColors(themeName, builtInThemes) ?? DEFAULT_BRACKETS_COLORS;
|
|
607
607
|
const isUnexpected = level === -1;
|
|
608
608
|
if (isUnexpected) {
|
|
609
609
|
return colors[colors.length - 1];
|
|
@@ -611,6 +611,14 @@ function getColor(themes, themeName, level) {
|
|
|
611
611
|
return colors[level % (colors.length - 1)];
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
|
+
function getThemeColors(themeName, themes) {
|
|
615
|
+
if (themes[themeName])
|
|
616
|
+
return themes[themeName];
|
|
617
|
+
const startsWithName = Object.keys(themes).sort().reverse().find((key) => themeName.startsWith(key));
|
|
618
|
+
if (startsWithName)
|
|
619
|
+
return themes[startsWithName];
|
|
620
|
+
return null;
|
|
621
|
+
}
|
|
614
622
|
|
|
615
623
|
function splitBracketTokens(rawToken, config, lang) {
|
|
616
624
|
const embeddedLang = getEmbeddedLang(rawToken);
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/colorized-brackets",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "3.4.0",
|
|
5
|
+
"description": "VSCode-style colorized brackets transformer for Shiki",
|
|
6
6
|
"author": "Michael Moore <mscottmoore@pm.me>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/shikijs/shiki#readme",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"shiki": "3.
|
|
30
|
+
"shiki": "3.4.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "unbuild",
|