starlight-cannoli-plugins 1.2.18 → 2.0.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/README.md +26 -40
- package/dist/chunk-AZPHBHBE.js +71 -0
- package/dist/{chunk-HRUZQZ5L.js → chunk-FQLJMU2J.js} +15 -13
- package/dist/chunk-IX5UFISR.js +149 -0
- package/dist/chunk-JOXQGMUL.js +143 -0
- package/dist/{chunk-KQM5EAEK.js → chunk-TTQY54Q6.js} +53 -28
- package/dist/cli/cannoli-latex-cleanup.js +1 -1
- package/dist/index.d.ts +17 -11
- package/dist/index.js +64 -67
- package/dist/plugins/astro-latex-compile.d.ts +41 -0
- package/dist/plugins/{remark-latex-compile.js → astro-latex-compile.js} +4 -6
- package/dist/plugins/astro-normalize-paths.d.ts +12 -0
- package/dist/plugins/astro-normalize-paths.js +9 -0
- package/dist/plugins/{starlight-sync-docs-to-public.d.ts → astro-sync-docs-to-public.d.ts} +6 -9
- package/dist/plugins/astro-sync-docs-to-public.js +10 -0
- package/dist/plugins/rehype-validate-links.js +1 -1
- package/package.json +7 -11
- package/dist/chunk-DEXMXUQL.js +0 -229
- package/dist/chunk-SBGY6FD3.js +0 -191
- package/dist/index-Ce1VCMrW.d.ts +0 -45
- package/dist/plugins/remark-latex-compile.d.ts +0 -4
- package/dist/plugins/starlight-latex-compile.d.ts +0 -4
- package/dist/plugins/starlight-latex-compile.js +0 -10
- package/dist/plugins/starlight-sync-docs-to-public.js +0 -8
package/dist/chunk-DEXMXUQL.js
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
LATEX_BLOCK_REGEX,
|
|
3
|
-
compileLatexToSvg,
|
|
4
|
-
hashLatexCode
|
|
5
|
-
} from "./chunk-KQM5EAEK.js";
|
|
6
|
-
|
|
7
|
-
// src/plugins/remark-latex-compile/index.ts
|
|
8
|
-
import { resolve } from "path";
|
|
9
|
-
|
|
10
|
-
// src/plugins/remark-latex-compile/rehype-converter.ts
|
|
11
|
-
import { visit } from "unist-util-visit";
|
|
12
|
-
function rehypeLatexCompile() {
|
|
13
|
-
return (tree, _file) => {
|
|
14
|
-
visit(tree, "element", (node, index, parent) => {
|
|
15
|
-
if (node.tagName !== "pre") return;
|
|
16
|
-
const codeChild = node.children?.[0];
|
|
17
|
-
if (!codeChild || codeChild.tagName !== "code") return;
|
|
18
|
-
const classes = Array.isArray(codeChild.properties?.className) ? codeChild.properties.className : [];
|
|
19
|
-
if (!classes.includes("language-tex") && !classes.includes("language-latex")) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const codeContent = codeChild.children?.map((child) => typeof child === "string" ? child : child.value || "").join("").trim();
|
|
23
|
-
if (!codeContent) return;
|
|
24
|
-
const dataAttribute = codeChild.properties?.["data-meta"];
|
|
25
|
-
const isCompileBlock = dataAttribute && dataAttribute.includes("compile") || codeContent.includes("compile");
|
|
26
|
-
if (!isCompileBlock) return;
|
|
27
|
-
try {
|
|
28
|
-
const hash = hashLatexCode(codeContent);
|
|
29
|
-
const svgPath = `/static/tex-svgs/${hash}.svg`;
|
|
30
|
-
const imgElement = {
|
|
31
|
-
type: "element",
|
|
32
|
-
tagName: "img",
|
|
33
|
-
properties: {
|
|
34
|
-
src: svgPath,
|
|
35
|
-
alt: "LaTeX diagram",
|
|
36
|
-
className: ["tex-compiled"]
|
|
37
|
-
},
|
|
38
|
-
children: []
|
|
39
|
-
};
|
|
40
|
-
const paragraphElement = {
|
|
41
|
-
type: "element",
|
|
42
|
-
tagName: "p",
|
|
43
|
-
properties: {},
|
|
44
|
-
children: [imgElement]
|
|
45
|
-
};
|
|
46
|
-
if (parent && typeof index === "number") {
|
|
47
|
-
parent.children[index] = paragraphElement;
|
|
48
|
-
}
|
|
49
|
-
} catch (err) {
|
|
50
|
-
console.error(`[rehype-latex-compile] Error processing code block:`, err);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// src/plugins/remark-latex-compile/index.ts
|
|
57
|
-
function extractClassesFromMeta(meta) {
|
|
58
|
-
const classMatch = meta.match(/class="([^"]+)"/);
|
|
59
|
-
if (classMatch && classMatch[1]) {
|
|
60
|
-
return classMatch[1].split(/\s+/).filter(Boolean);
|
|
61
|
-
}
|
|
62
|
-
return [];
|
|
63
|
-
}
|
|
64
|
-
function traverseTree(node, svgOutputDir, filePath, depth = 0) {
|
|
65
|
-
if (!node) return;
|
|
66
|
-
const children = node.children;
|
|
67
|
-
if (Array.isArray(children)) {
|
|
68
|
-
for (let i = 0; i < children.length; i++) {
|
|
69
|
-
const child = children[i];
|
|
70
|
-
if (child.type === "code" && (child.lang === "tex" || child.lang === "latex") && String(child.meta || "").includes("compile")) {
|
|
71
|
-
const position = child.position;
|
|
72
|
-
const lineNumber = position?.start?.line || "?";
|
|
73
|
-
try {
|
|
74
|
-
const result = compileLatexToSvg(String(child.value), svgOutputDir);
|
|
75
|
-
if (result.wasCompiled) {
|
|
76
|
-
console.log(
|
|
77
|
-
`[remark-latex-compile] ${filePath}:${lineNumber}: compiled ${result.hash}.svg`
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
const customClasses = extractClassesFromMeta(
|
|
81
|
-
String(child.meta || "")
|
|
82
|
-
);
|
|
83
|
-
const allClasses = ["tex-compiled", ...customClasses];
|
|
84
|
-
children[i] = {
|
|
85
|
-
type: "paragraph",
|
|
86
|
-
children: [
|
|
87
|
-
{
|
|
88
|
-
type: "image",
|
|
89
|
-
url: `/static/tex-svgs/${result.hash}.svg`,
|
|
90
|
-
alt: "LaTeX diagram",
|
|
91
|
-
data: {
|
|
92
|
-
hProperties: {
|
|
93
|
-
className: allClasses
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
};
|
|
99
|
-
} catch (err) {
|
|
100
|
-
if (process.env.NODE_ENV !== "production") {
|
|
101
|
-
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
102
|
-
const match = errorMsg.match(/\n\n([\s\S]+)/);
|
|
103
|
-
const details = match ? match[1] : errorMsg;
|
|
104
|
-
console.error(`${filePath}:${lineNumber}
|
|
105
|
-
${details}`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
traverseTree(child, svgOutputDir, filePath, depth + 1);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function remarkLatexCompile(options) {
|
|
115
|
-
const svgOutputDir = resolve(options.svgOutputDir);
|
|
116
|
-
return (tree, file) => {
|
|
117
|
-
const fileObj = file;
|
|
118
|
-
const filePath = String(fileObj?.path || fileObj?.filename || "unknown");
|
|
119
|
-
traverseTree(tree, svgOutputDir, filePath, 0);
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// src/plugins/remark-latex-compile/astro-integration.ts
|
|
124
|
-
import { readdir, readFile, cp } from "fs/promises";
|
|
125
|
-
import { resolve as resolve2, join, extname } from "path";
|
|
126
|
-
function createAstroLatexIntegration(options) {
|
|
127
|
-
const svgOutputDir = resolve2(options.svgOutputDir);
|
|
128
|
-
const contentDir = options?.contentDir ? resolve2(options.contentDir) : resolve2("src/content/docs");
|
|
129
|
-
return {
|
|
130
|
-
name: "astro-latex-compile",
|
|
131
|
-
hooks: {
|
|
132
|
-
"astro:build:start": async () => {
|
|
133
|
-
console.log(
|
|
134
|
-
"[astro-latex-compile] Build start, scanning for tex/latex compile blocks"
|
|
135
|
-
);
|
|
136
|
-
await scanAndCompileLatex(contentDir, svgOutputDir);
|
|
137
|
-
},
|
|
138
|
-
"astro:build:done": async ({ dir }) => {
|
|
139
|
-
const srcSvgDir = resolve2(svgOutputDir);
|
|
140
|
-
const outSvgDir = resolve2(dir.pathname, "static/tex-svgs");
|
|
141
|
-
try {
|
|
142
|
-
await cp(srcSvgDir, outSvgDir, { recursive: true, force: true });
|
|
143
|
-
console.log("[astro-latex-compile] Copied SVGs to build output");
|
|
144
|
-
} catch (err) {
|
|
145
|
-
console.error("[astro-latex-compile] Error copying SVGs:", err);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
async function scanAndCompileLatex(dir, svgOutputDir) {
|
|
152
|
-
const entries = await readdir(dir, { withFileTypes: true });
|
|
153
|
-
for (const entry of entries) {
|
|
154
|
-
const fullPath = join(dir, entry.name);
|
|
155
|
-
if (entry.isDirectory()) {
|
|
156
|
-
await scanAndCompileLatex(fullPath, svgOutputDir);
|
|
157
|
-
} else if (entry.isFile()) {
|
|
158
|
-
const ext = extname(entry.name);
|
|
159
|
-
if (ext === ".md" || ext === ".mdx") {
|
|
160
|
-
console.log(`[astro-latex-compile] Found markdown file: ${fullPath}`);
|
|
161
|
-
await processMarkdownFile(fullPath, svgOutputDir);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
function getLineNumber(content, position) {
|
|
167
|
-
return content.substring(0, position).split("\n").length;
|
|
168
|
-
}
|
|
169
|
-
async function processMarkdownFile(filePath, svgOutputDir) {
|
|
170
|
-
const content = await readFile(filePath, "utf-8");
|
|
171
|
-
const latexBlockRegex = new RegExp(
|
|
172
|
-
LATEX_BLOCK_REGEX.source,
|
|
173
|
-
LATEX_BLOCK_REGEX.flags
|
|
174
|
-
);
|
|
175
|
-
const matches = content.matchAll(latexBlockRegex);
|
|
176
|
-
for (const match of matches) {
|
|
177
|
-
const latexCode = match[1];
|
|
178
|
-
const lineNumber = getLineNumber(content, match.index || 0);
|
|
179
|
-
try {
|
|
180
|
-
const result = compileLatexToSvg(latexCode, svgOutputDir);
|
|
181
|
-
const status = result.wasCompiled ? "compiled" : "used cached";
|
|
182
|
-
console.log(
|
|
183
|
-
`[astro-latex-compile] ${filePath}:${lineNumber}: ${status} ${result.hash}.svg`
|
|
184
|
-
);
|
|
185
|
-
} catch (err) {
|
|
186
|
-
const error = err instanceof Error ? err : new Error(String(err));
|
|
187
|
-
error.message = `${filePath}:${lineNumber}
|
|
188
|
-
${error.message}`;
|
|
189
|
-
throw error;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// src/plugins/remark-latex-compile/starlight-plugin.ts
|
|
195
|
-
function starlightLatexCompile(options) {
|
|
196
|
-
return {
|
|
197
|
-
name: "starlight-latex-compile",
|
|
198
|
-
hooks: {
|
|
199
|
-
"config:setup": (hook) => {
|
|
200
|
-
hook.addIntegration({
|
|
201
|
-
name: "latex-compile-remark-integration",
|
|
202
|
-
hooks: {
|
|
203
|
-
"astro:config:setup": ({ updateConfig, config }) => {
|
|
204
|
-
const existingPlugins = (Array.isArray(config.markdown?.remarkPlugins) ? config.markdown.remarkPlugins : []).filter((p) => p !== void 0 && p !== null);
|
|
205
|
-
updateConfig({
|
|
206
|
-
markdown: {
|
|
207
|
-
remarkPlugins: [...existingPlugins, [remarkLatexCompile, options]]
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
hook.addIntegration(
|
|
214
|
-
createAstroLatexIntegration({
|
|
215
|
-
svgOutputDir: options.svgOutputDir
|
|
216
|
-
})
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
var starlight_plugin_default = starlightLatexCompile;
|
|
223
|
-
|
|
224
|
-
export {
|
|
225
|
-
starlightLatexCompile,
|
|
226
|
-
starlight_plugin_default,
|
|
227
|
-
rehypeLatexCompile,
|
|
228
|
-
remarkLatexCompile
|
|
229
|
-
};
|
package/dist/chunk-SBGY6FD3.js
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
parseFrontmatter
|
|
3
|
-
} from "./chunk-3ATSZG6H.js";
|
|
4
|
-
|
|
5
|
-
// src/plugins/starlight-sync-docs-to-public.ts
|
|
6
|
-
import { cp, mkdir, readdir, readFile, writeFile, rm, stat } from "fs/promises";
|
|
7
|
-
import { resolve, relative } from "path";
|
|
8
|
-
import { minimatch } from "minimatch";
|
|
9
|
-
var DEFAULT_SRC_DIR = "src/content/docs";
|
|
10
|
-
var DEFAULT_PUBLIC_DIR = "public";
|
|
11
|
-
async function fullSync(srcDir, publicDir, preserveDirs, ignorePatterns) {
|
|
12
|
-
await mkdir(publicDir, { recursive: true });
|
|
13
|
-
const items = await readdir(publicDir);
|
|
14
|
-
for (const item of items) {
|
|
15
|
-
const itemPath = resolve(publicDir, item);
|
|
16
|
-
let itemStat;
|
|
17
|
-
try {
|
|
18
|
-
itemStat = await stat(itemPath);
|
|
19
|
-
} catch (err) {
|
|
20
|
-
if (err?.code === "ENOENT") {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
throw err;
|
|
24
|
-
}
|
|
25
|
-
if (preserveDirs.includes(item) || !itemStat.isDirectory()) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
await rm(itemPath, { recursive: true, force: true });
|
|
29
|
-
}
|
|
30
|
-
await copyWithRetry(srcDir, publicDir, ignorePatterns);
|
|
31
|
-
console.log(
|
|
32
|
-
`[starlight-sync-docs-to-public] Synced ${DEFAULT_SRC_DIR}/ \u2192 ${DEFAULT_PUBLIC_DIR}/ (full sync)`
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
async function incrementalSync(changedFilePath, srcDir, publicDir, ignorePatterns) {
|
|
36
|
-
const rel = relative(srcDir, changedFilePath);
|
|
37
|
-
if (ignorePatterns.some((pattern) => minimatch(rel, pattern, { dot: true }))) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (changedFilePath.endsWith(".md") || changedFilePath.endsWith(".mdx")) {
|
|
41
|
-
try {
|
|
42
|
-
const frontmatter = parseFrontmatter(changedFilePath);
|
|
43
|
-
if (frontmatter.draft === true) return;
|
|
44
|
-
} catch {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const destPath = resolve(publicDir, rel);
|
|
49
|
-
let srcStat;
|
|
50
|
-
try {
|
|
51
|
-
srcStat = await stat(changedFilePath);
|
|
52
|
-
} catch (err) {
|
|
53
|
-
if (err?.code === "ENOENT") {
|
|
54
|
-
await rm(destPath, { recursive: true, force: true });
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
throw err;
|
|
58
|
-
}
|
|
59
|
-
if (srcStat.isDirectory()) {
|
|
60
|
-
await mkdir(destPath, { recursive: true });
|
|
61
|
-
const files = await readdir(changedFilePath);
|
|
62
|
-
for (const file of files) {
|
|
63
|
-
await incrementalSync(
|
|
64
|
-
resolve(changedFilePath, file),
|
|
65
|
-
srcDir,
|
|
66
|
-
publicDir,
|
|
67
|
-
ignorePatterns
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
await mkdir(resolve(destPath, ".."), { recursive: true });
|
|
72
|
-
const content = await readFile(changedFilePath);
|
|
73
|
-
await writeFile(destPath, content);
|
|
74
|
-
}
|
|
75
|
-
console.log(
|
|
76
|
-
`[starlight-sync-docs-to-public] Synced ${rel}`
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
async function copyWithRetry(srcDir, publicDir, ignorePatterns) {
|
|
80
|
-
let lastError;
|
|
81
|
-
for (let attempt = 0; attempt < 3; attempt++) {
|
|
82
|
-
try {
|
|
83
|
-
await cp(srcDir, publicDir, {
|
|
84
|
-
recursive: true,
|
|
85
|
-
force: true,
|
|
86
|
-
filter: (src) => {
|
|
87
|
-
const rel = relative(srcDir, src);
|
|
88
|
-
if (rel === "") return true;
|
|
89
|
-
if (ignorePatterns.some((pattern) => minimatch(rel, pattern, { dot: true }))) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
if (src.endsWith(".md") || src.endsWith(".mdx")) {
|
|
93
|
-
try {
|
|
94
|
-
const frontmatter = parseFrontmatter(src);
|
|
95
|
-
if (frontmatter.draft === true) return false;
|
|
96
|
-
} catch {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
return;
|
|
104
|
-
} catch (err) {
|
|
105
|
-
lastError = err;
|
|
106
|
-
const code = err?.code;
|
|
107
|
-
const isRaceCondition = code === "EEXIST" || code === "ENOENT";
|
|
108
|
-
if (!isRaceCondition) {
|
|
109
|
-
throw err;
|
|
110
|
-
}
|
|
111
|
-
if (attempt < 2) {
|
|
112
|
-
await new Promise((resolve2) => setTimeout(resolve2, 10 * (attempt + 1)));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (lastError) {
|
|
117
|
-
const code = lastError?.code;
|
|
118
|
-
if (code === "EEXIST" || code === "ENOENT") {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
throw lastError;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
function starlightSyncDocsToPublic(options) {
|
|
125
|
-
const srcDir = resolve(DEFAULT_SRC_DIR);
|
|
126
|
-
const publicDir = resolve(DEFAULT_PUBLIC_DIR);
|
|
127
|
-
const { preserveDirs, ignorePatterns = [] } = options;
|
|
128
|
-
return {
|
|
129
|
-
name: "starlight-sync-docs-to-public",
|
|
130
|
-
hooks: {
|
|
131
|
-
"config:setup": (hook) => {
|
|
132
|
-
hook.addIntegration({
|
|
133
|
-
name: "astro-sync-docs-to-public",
|
|
134
|
-
hooks: {
|
|
135
|
-
"astro:build:start": async () => {
|
|
136
|
-
await fullSync(srcDir, publicDir, preserveDirs, ignorePatterns);
|
|
137
|
-
},
|
|
138
|
-
"astro:server:setup": ({ server }) => {
|
|
139
|
-
let isSyncing = false;
|
|
140
|
-
let needsResync = false;
|
|
141
|
-
let lastChangedFile;
|
|
142
|
-
const performSync = async () => {
|
|
143
|
-
if (isSyncing) {
|
|
144
|
-
needsResync = true;
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
isSyncing = true;
|
|
148
|
-
try {
|
|
149
|
-
if (lastChangedFile) {
|
|
150
|
-
await incrementalSync(
|
|
151
|
-
lastChangedFile,
|
|
152
|
-
srcDir,
|
|
153
|
-
publicDir,
|
|
154
|
-
ignorePatterns
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
if (needsResync) {
|
|
158
|
-
needsResync = false;
|
|
159
|
-
lastChangedFile = void 0;
|
|
160
|
-
await performSync();
|
|
161
|
-
}
|
|
162
|
-
} catch (err) {
|
|
163
|
-
console.error(err);
|
|
164
|
-
} finally {
|
|
165
|
-
isSyncing = false;
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
fullSync(srcDir, publicDir, preserveDirs, ignorePatterns).catch(
|
|
169
|
-
console.error
|
|
170
|
-
);
|
|
171
|
-
let debounceTimer = null;
|
|
172
|
-
server.watcher.add(srcDir);
|
|
173
|
-
server.watcher.on("all", (_event, filePath) => {
|
|
174
|
-
if (!filePath.startsWith(srcDir)) return;
|
|
175
|
-
lastChangedFile = filePath;
|
|
176
|
-
if (debounceTimer) clearTimeout(debounceTimer);
|
|
177
|
-
debounceTimer = setTimeout(() => {
|
|
178
|
-
performSync();
|
|
179
|
-
}, 100);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export {
|
|
190
|
-
starlightSyncDocsToPublic
|
|
191
|
-
};
|
package/dist/index-Ce1VCMrW.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { HookParameters } from '@astrojs/starlight/types';
|
|
2
|
-
import { Root } from 'hast';
|
|
3
|
-
import { VFile } from 'vfile';
|
|
4
|
-
|
|
5
|
-
interface CompilationResult {
|
|
6
|
-
hash: string;
|
|
7
|
-
svgPath: string;
|
|
8
|
-
wasCompiled: boolean;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Compile LaTeX code to SVG.
|
|
12
|
-
*
|
|
13
|
-
* @param latexCode - The LaTeX code to compile (e.g., TikZ, pgfplots, etc.)
|
|
14
|
-
* @param svgOutputDir - The directory where SVG files should be written
|
|
15
|
-
* @returns Result object with hash, svgPath, and whether compilation occurred
|
|
16
|
-
* @throws Error if compilation fails
|
|
17
|
-
*/
|
|
18
|
-
declare function compileLatexToSvg(latexCode: string, svgOutputDir: string): CompilationResult;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Starlight plugin wrapper for remark-latex-compile.
|
|
22
|
-
*
|
|
23
|
-
* This plugin hooks into Starlight's config:setup to inject the remark-latex-compile
|
|
24
|
-
* plugin and the build-time Astro integration for scanning markdown files.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
type StarlightLatexCompileOptions = RemarkLatexCompileOptions;
|
|
28
|
-
declare function starlightLatexCompile(options: StarlightLatexCompileOptions): {
|
|
29
|
-
name: string;
|
|
30
|
-
hooks: {
|
|
31
|
-
"config:setup": (hook: HookParameters<"config:setup">) => void;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
declare function rehypeLatexCompile(): (tree: Root, _file: VFile) => void;
|
|
36
|
-
|
|
37
|
-
interface RemarkLatexCompileOptions {
|
|
38
|
-
/**
|
|
39
|
-
* Directory where SVG files should be written.
|
|
40
|
-
*/
|
|
41
|
-
svgOutputDir: string;
|
|
42
|
-
}
|
|
43
|
-
declare function remarkLatexCompile(options: RemarkLatexCompileOptions): (tree: Record<string, unknown>, file: unknown) => void;
|
|
44
|
-
|
|
45
|
-
export { type RemarkLatexCompileOptions as R, type StarlightLatexCompileOptions as S, remarkLatexCompile as a, compileLatexToSvg as c, rehypeLatexCompile as r, starlightLatexCompile as s };
|