starlight-cannoli-plugins 2.14.1 → 2.15.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/{chunk-ETBDUEFH.js → chunk-RAKGKJJO.js} +12 -12
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/plugins/astro-latex-compile.d.ts +5 -5
- package/dist/plugins/astro-latex-compile.js +3 -3
- package/dist/plugins/astro-sync-docs-to-public/page-script.js +7 -0
- package/package.json +1 -1
|
@@ -112,7 +112,7 @@ function formatLatexError(parsed) {
|
|
|
112
112
|
const warningCount = parsed.errors.filter(
|
|
113
113
|
(e) => e.severity === "warning"
|
|
114
114
|
).length;
|
|
115
|
-
let output = `${RED}[
|
|
115
|
+
let output = `${RED}[astro-latex-compile] LaTeX compilation failed${RESET}
|
|
116
116
|
`;
|
|
117
117
|
output += `${RED}${errorCount} error${errorCount !== 1 ? "s" : ""}${RESET}`;
|
|
118
118
|
if (warningCount > 0) {
|
|
@@ -412,7 +412,7 @@ function buildLatexSource(latexCode) {
|
|
|
412
412
|
return latexCode.trim();
|
|
413
413
|
}
|
|
414
414
|
throw new Error(
|
|
415
|
-
`[
|
|
415
|
+
`[astro-latex-compile] Code block is not a complete LaTeX document. Blocks must contain both \\documentclass and \\begin{document}.`
|
|
416
416
|
);
|
|
417
417
|
}
|
|
418
418
|
async function compileLatexToSvg(latexCode, svgOutputDir, texInputDirs = [], inputsSalt = "") {
|
|
@@ -442,7 +442,7 @@ async function compileLatexToSvg(latexCode, svgOutputDir, texInputDirs = [], inp
|
|
|
442
442
|
} catch (err) {
|
|
443
443
|
const code = err.code;
|
|
444
444
|
throw new Error(
|
|
445
|
-
`[
|
|
445
|
+
`[astro-latex-compile] pdflatex not found on PATH (${code}).`,
|
|
446
446
|
{ cause: err }
|
|
447
447
|
);
|
|
448
448
|
}
|
|
@@ -466,14 +466,14 @@ async function compileLatexToSvg(latexCode, svgOutputDir, texInputDirs = [], inp
|
|
|
466
466
|
} catch (err) {
|
|
467
467
|
const code = err.code;
|
|
468
468
|
throw new Error(
|
|
469
|
-
`[
|
|
469
|
+
`[astro-latex-compile] dvisvgm not found on PATH (${code}).`,
|
|
470
470
|
{ cause: err }
|
|
471
471
|
);
|
|
472
472
|
}
|
|
473
473
|
if (svgResult.status !== 0) {
|
|
474
474
|
const errorOutput = svgResult.stderr || svgResult.stdout || "";
|
|
475
475
|
throw new Error(
|
|
476
|
-
`[
|
|
476
|
+
`[astro-latex-compile] PDF to SVG conversion failed (hash: ${hash}).
|
|
477
477
|
Error: ${errorOutput}`
|
|
478
478
|
);
|
|
479
479
|
}
|
|
@@ -497,7 +497,7 @@ function getFrontmatterOffset(absoluteFilePath) {
|
|
|
497
497
|
return 0;
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
-
function
|
|
500
|
+
function latexCompileTransformer(options) {
|
|
501
501
|
const svgOutputDir = resolve2(options.svgOutputDir);
|
|
502
502
|
return async function transformer(tree, file) {
|
|
503
503
|
const nodes = [];
|
|
@@ -526,14 +526,14 @@ function remarkLatexCompile(options) {
|
|
|
526
526
|
);
|
|
527
527
|
if (result.wasCompiled) {
|
|
528
528
|
console.log(
|
|
529
|
-
`[
|
|
529
|
+
`[astro-latex-compile] ${relFilePath}:${lineNumberStr}: compiled ${result.hash}.svg`
|
|
530
530
|
);
|
|
531
531
|
}
|
|
532
532
|
options._referencedHashes?.add(result.hash);
|
|
533
533
|
if (jpgPath) {
|
|
534
534
|
await writeJpgFromSvg(result.svgPath, jpgPath);
|
|
535
535
|
console.log(
|
|
536
|
-
`[
|
|
536
|
+
`[astro-latex-compile] ${relFilePath}:${lineNumberStr}: wrote ${jpgPath}`
|
|
537
537
|
);
|
|
538
538
|
}
|
|
539
539
|
return {
|
|
@@ -549,7 +549,7 @@ function remarkLatexCompile(options) {
|
|
|
549
549
|
const match = errorMsg.match(/\n\n([\s\S]+)/);
|
|
550
550
|
const details = match ? match[1] : errorMsg;
|
|
551
551
|
console.error(
|
|
552
|
-
`[
|
|
552
|
+
`[astro-latex-compile] ${relFilePath}:${lineNumberStr}
|
|
553
553
|
${details}`
|
|
554
554
|
);
|
|
555
555
|
if (jpgPath) {
|
|
@@ -578,7 +578,7 @@ ${details}`
|
|
|
578
578
|
const staleHashes = [...oldHashes].filter((h) => !newHashes.has(h));
|
|
579
579
|
for (const staleHash of staleHashes) {
|
|
580
580
|
console.warn(
|
|
581
|
-
`[
|
|
581
|
+
`[astro-latex-compile] Removing orphaned svg: ${staleHash}.svg`
|
|
582
582
|
);
|
|
583
583
|
}
|
|
584
584
|
await Promise.all(
|
|
@@ -596,7 +596,7 @@ ${details}`
|
|
|
596
596
|
const staleJpgPaths = [...oldJpgPaths].filter((p) => !newJpgPaths.has(p));
|
|
597
597
|
for (const stalePath of staleJpgPaths) {
|
|
598
598
|
console.warn(
|
|
599
|
-
`[
|
|
599
|
+
`[astro-latex-compile] Removing orphaned jpg: ${stalePath}`
|
|
600
600
|
);
|
|
601
601
|
}
|
|
602
602
|
await Promise.all(staleJpgPaths.map((p) => rm(p, { force: true })));
|
|
@@ -642,5 +642,5 @@ ${details}`
|
|
|
642
642
|
|
|
643
643
|
export {
|
|
644
644
|
compileLatexToSvg,
|
|
645
|
-
|
|
645
|
+
latexCompileTransformer
|
|
646
646
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { rehypeValidateLinks } from './plugins/rehype-validate-links.js';
|
|
|
6
6
|
export { astroNormalizePaths } from './plugins/astro-normalize-paths.js';
|
|
7
7
|
export { expressiveCodeEmphasis } from './plugins/expressive-code-emphasis.js';
|
|
8
8
|
import { AstroIntegration } from 'astro';
|
|
9
|
-
import {
|
|
9
|
+
import { LatexCompilePluginOptions } from './plugins/astro-latex-compile.js';
|
|
10
10
|
import 'hast';
|
|
11
11
|
import 'vfile';
|
|
12
12
|
import 'expressive-code';
|
|
@@ -66,7 +66,7 @@ declare function starlightIndexSourcedSidebar(options: TOptions): {
|
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
interface LatexCompileOptions extends
|
|
69
|
+
interface LatexCompileOptions extends LatexCompilePluginOptions {
|
|
70
70
|
/**
|
|
71
71
|
* When `true`, SVG files in `svgOutputDir` that are no longer referenced by
|
|
72
72
|
* any `tex compile` block are deleted automatically. In dev mode, stale SVGs
|
package/dist/index.js
CHANGED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
rehypeValidateLinks
|
|
9
9
|
} from "./chunk-3UMY7T6G.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./chunk-
|
|
11
|
+
latexCompileTransformer
|
|
12
|
+
} from "./chunk-RAKGKJJO.js";
|
|
13
13
|
import {
|
|
14
14
|
astroNormalizePaths
|
|
15
15
|
} from "./chunk-TLOFSB33.js";
|
|
@@ -284,7 +284,7 @@ function astroLatexCompile(options) {
|
|
|
284
284
|
await clearContentLayerCache(config);
|
|
285
285
|
}
|
|
286
286
|
const existingPlugins = Array.isArray(config.markdown?.remarkPlugins) ? config.markdown.remarkPlugins.filter(Boolean) : [];
|
|
287
|
-
const
|
|
287
|
+
const pluginOptions = {
|
|
288
288
|
...options,
|
|
289
289
|
_fileHashMap: options.removeOrphanedSvgs ? fileHashMap : void 0,
|
|
290
290
|
_referencedHashes: command === "build" && options.removeOrphanedSvgs ? referencedHashes : void 0,
|
|
@@ -294,7 +294,7 @@ function astroLatexCompile(options) {
|
|
|
294
294
|
markdown: {
|
|
295
295
|
remarkPlugins: [
|
|
296
296
|
...existingPlugins,
|
|
297
|
-
[
|
|
297
|
+
[latexCompileTransformer, pluginOptions]
|
|
298
298
|
]
|
|
299
299
|
}
|
|
300
300
|
});
|
|
@@ -16,7 +16,7 @@ interface CompilationResult {
|
|
|
16
16
|
*/
|
|
17
17
|
declare function compileLatexToSvg(latexCode: string, svgOutputDir: string, texInputDirs?: string[], inputsSalt?: string): Promise<CompilationResult>;
|
|
18
18
|
|
|
19
|
-
interface
|
|
19
|
+
interface LatexCompilePluginOptions {
|
|
20
20
|
/**
|
|
21
21
|
* Directory where SVG files should be written.
|
|
22
22
|
* Must be inside `public/` so Astro serves them as static assets.
|
|
@@ -51,15 +51,15 @@ interface RemarkLatexCompileOptions {
|
|
|
51
51
|
_referencedHashes?: Set<string>;
|
|
52
52
|
/**
|
|
53
53
|
* @internal Maps each file path to the set of hashes it produced on the
|
|
54
|
-
* previous
|
|
54
|
+
* previous run. Used to delete stale SVGs when a block changes.
|
|
55
55
|
*/
|
|
56
56
|
_fileHashMap?: Map<string, Set<string>>;
|
|
57
57
|
/**
|
|
58
58
|
* @internal Maps each file path to the set of JPG paths it produced on the
|
|
59
|
-
* previous
|
|
59
|
+
* previous run. Used to delete stale JPGs when a block changes.
|
|
60
60
|
*/
|
|
61
61
|
_fileJpgPathMap?: Map<string, Set<string>>;
|
|
62
62
|
}
|
|
63
|
-
declare function
|
|
63
|
+
declare function latexCompileTransformer(options: LatexCompilePluginOptions): (tree: Root, file: VFile) => Promise<void>;
|
|
64
64
|
|
|
65
|
-
export { type
|
|
65
|
+
export { type LatexCompilePluginOptions, compileLatexToSvg, latexCompileTransformer };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
compileLatexToSvg,
|
|
3
|
-
|
|
4
|
-
} from "../chunk-
|
|
3
|
+
latexCompileTransformer
|
|
4
|
+
} from "../chunk-RAKGKJJO.js";
|
|
5
5
|
import "../chunk-C2VXRQOK.js";
|
|
6
6
|
import "../chunk-4VNS5WPM.js";
|
|
7
7
|
export {
|
|
8
8
|
compileLatexToSvg,
|
|
9
|
-
|
|
9
|
+
latexCompileTransformer
|
|
10
10
|
};
|
|
@@ -47,6 +47,13 @@ function createActionBar() {
|
|
|
47
47
|
getRawMdUrl().then((url) => fetch(url)).then((resp) => resp.text()).then((text) => navigator.clipboard.writeText(text)).then(() => showBanner("Page source copied to clipboard!", "success")).catch(() => showBanner("Failed to copy page source.", "error")).finally(() => setLoading(false));
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
|
+
{
|
|
51
|
+
label: "Copy raw URL",
|
|
52
|
+
action: () => {
|
|
53
|
+
setLoading(true);
|
|
54
|
+
getRawMdUrl().then((url) => navigator.clipboard.writeText(url)).then(() => showBanner("Raw URL copied to clipboard!", "success")).catch(() => showBanner("Failed to copy raw URL.", "error")).finally(() => setLoading(false));
|
|
55
|
+
}
|
|
56
|
+
},
|
|
50
57
|
{
|
|
51
58
|
label: "View raw",
|
|
52
59
|
action: () => {
|
package/package.json
CHANGED