mini-shiki 3.17.0 → 3.17.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/dist/shiki.js +22 -6
- package/package.json +5 -5
package/dist/shiki.js
CHANGED
|
@@ -41,6 +41,7 @@ function isSpecialTheme(theme) {
|
|
|
41
41
|
return isNoneTheme(theme);
|
|
42
42
|
}
|
|
43
43
|
function splitLines(code, preserveEnding = false) {
|
|
44
|
+
if (code.length === 0) return [["", 0]];
|
|
44
45
|
const parts = code.split(/(\r?\n)/g);
|
|
45
46
|
let index = 0;
|
|
46
47
|
const lines = [];
|
|
@@ -417,12 +418,27 @@ function tokenizeAnsiWithTheme(theme, fileContents, options) {
|
|
|
417
418
|
}));
|
|
418
419
|
}
|
|
419
420
|
function dimColor(color) {
|
|
420
|
-
const hexMatch = color.match(/#([0-9a-f]{3})
|
|
421
|
-
if (hexMatch)
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
421
|
+
const hexMatch = color.match(/#([0-9a-f]{3,8})/i);
|
|
422
|
+
if (hexMatch) {
|
|
423
|
+
const hex = hexMatch[1];
|
|
424
|
+
if (hex.length === 8) {
|
|
425
|
+
const alpha = Math.round(Number.parseInt(hex.slice(6, 8), 16) / 2).toString(16).padStart(2, "0");
|
|
426
|
+
return `#${hex.slice(0, 6)}${alpha}`;
|
|
427
|
+
} else if (hex.length === 6) return `#${hex}80`;
|
|
428
|
+
else if (hex.length === 4) {
|
|
429
|
+
const r = hex[0];
|
|
430
|
+
const g = hex[1];
|
|
431
|
+
const b = hex[2];
|
|
432
|
+
const a = hex[3];
|
|
433
|
+
const alpha = Math.round(Number.parseInt(`${a}${a}`, 16) / 2).toString(16).padStart(2, "0");
|
|
434
|
+
return `#${r}${r}${g}${g}${b}${b}${alpha}`;
|
|
435
|
+
} else if (hex.length === 3) {
|
|
436
|
+
const r = hex[0];
|
|
437
|
+
const g = hex[1];
|
|
438
|
+
const b = hex[2];
|
|
439
|
+
return `#${r}${r}${g}${g}${b}${b}80`;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
426
442
|
const cssVarMatch = color.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);
|
|
427
443
|
if (cssVarMatch) return `var(${cssVarMatch[1]}-dim)`;
|
|
428
444
|
return color;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mini-shiki",
|
|
3
|
-
"version": "3.17.
|
|
3
|
+
"version": "3.17.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": "git+https://github.com/un-ts/mini-shiki.git",
|
|
6
6
|
"homepage": "https://github.com/un-ts/mini-shiki#readme",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"static"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@shikijs/engine-oniguruma": "^3.17.
|
|
25
|
-
"@shikijs/langs": "^3.17.
|
|
26
|
-
"@shikijs/themes": "^3.17.
|
|
27
|
-
"@shikijs/types": "^3.17.
|
|
24
|
+
"@shikijs/engine-oniguruma": "^3.17.1",
|
|
25
|
+
"@shikijs/langs": "^3.17.1",
|
|
26
|
+
"@shikijs/themes": "^3.17.1",
|
|
27
|
+
"@shikijs/types": "^3.17.1",
|
|
28
28
|
"@shikijs/vscode-textmate": "^10.0.2"
|
|
29
29
|
}
|
|
30
30
|
}
|