@tenphi/starlight 0.11.1 → 0.11.3
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.
|
@@ -78,13 +78,19 @@ export default function GlobalStyles() {
|
|
|
78
78
|
cursor: "pointer",
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
useGlobalStyles(
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
useGlobalStyles(
|
|
82
|
+
":where(img:not([width]), picture, video:not([width]), canvas:not([width]), svg:not([width]), iframe:not([width]))",
|
|
83
|
+
{
|
|
84
|
+
maxInlineSize: "100%",
|
|
85
|
+
},
|
|
86
|
+
);
|
|
84
87
|
|
|
85
|
-
useGlobalStyles(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
useGlobalStyles(
|
|
89
|
+
":where(img:not([height]), picture, video:not([height]), canvas:not([height]), svg:not([height]))",
|
|
90
|
+
{
|
|
91
|
+
blockSize: "auto",
|
|
92
|
+
},
|
|
93
|
+
);
|
|
88
94
|
|
|
89
95
|
useGlobalStyles(":where([hidden], .sl-hidden)", {
|
|
90
96
|
hide: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rendered-content.d.ts","names":[],"sources":["../../src/markdown/rendered-content.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"rendered-content.d.ts","names":[],"sources":["../../src/markdown/rendered-content.ts"],"mappings":";;iBAMgB,qBAAqB"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
//#region src/markdown/rendered-content.ts
|
|
2
|
-
const headingPattern = /<h([1-6])\b([^>]*)>([\s\S]*?)<\/h\1>/gi;
|
|
2
|
+
const headingPattern = /<div\b[^>]*\bclass=["'][^"']*\bsl-heading-wrapper\b[^"']*["'][^>]*>[\s\S]*?<\/div>|<h([1-6])\b([^>]*)>([\s\S]*?)<\/h\1>/gi;
|
|
3
3
|
const idPattern = /\sid=(['"])(.*?)\1/i;
|
|
4
4
|
const tags = /<[^>]*>/g;
|
|
5
5
|
/** Wrap rendered headings with a visible, accessible permalink. */
|
|
6
6
|
function addHeadingPermalinks(html) {
|
|
7
7
|
return html.replace(headingPattern, (heading, level, attributes, content) => {
|
|
8
|
+
if (!level || attributes === void 0 || content === void 0) return heading;
|
|
8
9
|
const id = idPattern.exec(attributes)?.[2];
|
|
9
10
|
if (!id) return heading;
|
|
10
11
|
const title = escapeAttribute(decodeEntities(content.replace(tags, "").trim()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rendered-content.js","names":[],"sources":["../../src/markdown/rendered-content.ts"],"sourcesContent":["const headingPattern =
|
|
1
|
+
{"version":3,"file":"rendered-content.js","names":[],"sources":["../../src/markdown/rendered-content.ts"],"sourcesContent":["const headingPattern =\n /<div\\b[^>]*\\bclass=[\"'][^\"']*\\bsl-heading-wrapper\\b[^\"']*[\"'][^>]*>[\\s\\S]*?<\\/div>|<h([1-6])\\b([^>]*)>([\\s\\S]*?)<\\/h\\1>/gi;\nconst idPattern = /\\sid=(['\"])(.*?)\\1/i;\nconst tags = /<[^>]*>/g;\n\n/** Wrap rendered headings with a visible, accessible permalink. */\nexport function addHeadingPermalinks(html: string): string {\n return html.replace(\n headingPattern,\n (\n heading,\n level: string | undefined,\n attributes: string | undefined,\n content: string | undefined,\n ) => {\n // Starlight adds its own icon permalink before this rendered HTML reaches\n // the MarkdownContent override. Consume that complete wrapper unchanged\n // so the inner heading is not matched and wrapped a second time.\n if (!level || attributes === undefined || content === undefined) {\n return heading;\n }\n const id = idPattern.exec(attributes)?.[2];\n if (!id) return heading;\n const title = escapeAttribute(\n decodeEntities(content.replace(tags, \"\").trim()),\n );\n return `<div class=\"sl-heading-wrapper level-h${level}\">${heading}<a class=\"sl-anchor-link\" href=\"#${escapeAttribute(id)}\" aria-label=\"Permalink to “${title}”\">#</a></div>`;\n },\n );\n}\n\nfunction decodeEntities(value: string): string {\n const named: Record<string, string> = {\n amp: \"&\",\n apos: \"'\",\n gt: \">\",\n lt: \"<\",\n quot: '\"',\n };\n return value.replace(\n /&(?:#(\\d+)|#x([\\da-f]+)|(amp|apos|gt|lt|quot));/gi,\n (entity, decimal: string, hexadecimal: string, name: string) => {\n const point = decimal\n ? Number.parseInt(decimal, 10)\n : hexadecimal\n ? Number.parseInt(hexadecimal, 16)\n : undefined;\n return point === undefined\n ? (named[name.toLowerCase()] ?? entity)\n : String.fromCodePoint(point);\n },\n );\n}\n\nfunction escapeAttribute(value: string): string {\n return value\n .replaceAll(\"&\", \"&\")\n .replaceAll('\"', \""\")\n .replaceAll(\"'\", \"'\")\n .replaceAll(\"<\", \"<\")\n .replaceAll(\">\", \">\");\n}\n"],"mappings":";AAAA,MAAM,iBACJ;AACF,MAAM,YAAY;AAClB,MAAM,OAAO;;AAGb,SAAgB,qBAAqB,MAAsB;CACzD,OAAO,KAAK,QACV,iBAEE,SACA,OACA,YACA,YACG;EAIH,IAAI,CAAC,SAAS,eAAe,KAAA,KAAa,YAAY,KAAA,GACpD,OAAO;EAET,MAAM,KAAK,UAAU,KAAK,UAAU,CAAC,GAAG;EACxC,IAAI,CAAC,IAAI,OAAO;EAChB,MAAM,QAAQ,gBACZ,eAAe,QAAQ,QAAQ,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CACjD;EACA,OAAO,yCAAyC,MAAM,IAAI,QAAQ,mCAAmC,gBAAgB,EAAE,EAAE,8BAA8B,MAAM;CAC/J,CACF;AACF;AAEA,SAAS,eAAe,OAAuB;CAC7C,MAAM,QAAgC;EACpC,KAAK;EACL,MAAM;EACN,IAAI;EACJ,IAAI;EACJ,MAAM;CACR;CACA,OAAO,MAAM,QACX,sDACC,QAAQ,SAAiB,aAAqB,SAAiB;EAC9D,MAAM,QAAQ,UACV,OAAO,SAAS,SAAS,EAAE,IAC3B,cACE,OAAO,SAAS,aAAa,EAAE,IAC/B,KAAA;EACN,OAAO,UAAU,KAAA,IACZ,MAAM,KAAK,YAAY,MAAM,SAC9B,OAAO,cAAc,KAAK;CAChC,CACF;AACF;AAEA,SAAS,gBAAgB,OAAuB;CAC9C,OAAO,MACJ,WAAW,KAAK,OAAO,CAAC,CACxB,WAAW,MAAK,QAAQ,CAAC,CACzB,WAAW,KAAK,OAAO,CAAC,CACxB,WAAW,KAAK,MAAM,CAAC,CACvB,WAAW,KAAK,MAAM;AAC3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenphi/starlight",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"description": "Astro and Starlight renderer for Cookbook",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@astrojs/starlight": "^0.41.10",
|
|
50
50
|
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
|
51
51
|
"@fontsource-variable/onest": "^5.3.0",
|
|
52
|
-
"@tenphi/docs": "0.11.
|
|
52
|
+
"@tenphi/docs": "0.11.3",
|
|
53
53
|
"@tenphi/glaze": "2.0.0",
|
|
54
54
|
"@tenphi/tasty": "3.8.0",
|
|
55
55
|
"beautiful-mermaid": "^1.1.3",
|