starlight-cannoli-plugins 2.12.0 → 2.12.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.
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/plugins/astro-latex-compile/index.ts
|
|
2
|
-
import { existsSync as existsSync2 } from "fs";
|
|
3
2
|
import { rm } from "fs/promises";
|
|
4
3
|
import { join as join2, resolve as resolve2 } from "path";
|
|
5
4
|
import { visit, SKIP } from "unist-util-visit";
|
|
@@ -190,13 +189,13 @@ function execProcess(command, args, options) {
|
|
|
190
189
|
|
|
191
190
|
// src/plugins/astro-latex-compile/utils.ts
|
|
192
191
|
var CONTENT_ROOT = "src/content/docs/";
|
|
193
|
-
function computeJpgPath(tempOutputDir, filePath, blockId
|
|
192
|
+
function computeJpgPath(tempOutputDir, filePath, blockId) {
|
|
194
193
|
const normalized = filePath.replace(/\\/g, "/");
|
|
195
194
|
const idx = normalized.indexOf(CONTENT_ROOT);
|
|
196
195
|
const relativePath = idx !== -1 ? normalized.slice(idx + CONTENT_ROOT.length) : basename(normalized);
|
|
197
196
|
const dir = dirname(relativePath);
|
|
198
197
|
const filename = basename(relativePath);
|
|
199
|
-
const jpgFilename = `${filename}--${blockId}
|
|
198
|
+
const jpgFilename = `${filename}--${blockId}.jpg`;
|
|
200
199
|
const base = resolve(tempOutputDir);
|
|
201
200
|
return dir === "." ? join(base, jpgFilename) : join(base, dir, jpgFilename);
|
|
202
201
|
}
|
|
@@ -368,8 +367,7 @@ function remarkLatexCompile(options) {
|
|
|
368
367
|
nodes.map(async ({ node, index, parent }) => {
|
|
369
368
|
const lineNumberStr = node.position?.start.line ?? "?";
|
|
370
369
|
const blockId = new MetaOptions(node.meta ?? "").getInteger("blockid");
|
|
371
|
-
const
|
|
372
|
-
const canWriteJpg = !!options.tempOutputDir && blockId !== void 0;
|
|
370
|
+
const jpgPath = options.tempOutputDir && blockId !== void 0 ? computeJpgPath(options.tempOutputDir, filePath, blockId) : null;
|
|
373
371
|
try {
|
|
374
372
|
const result = await compileLatexToSvg(
|
|
375
373
|
node.value,
|
|
@@ -382,8 +380,7 @@ function remarkLatexCompile(options) {
|
|
|
382
380
|
);
|
|
383
381
|
}
|
|
384
382
|
options._referencedHashes?.add(result.hash);
|
|
385
|
-
|
|
386
|
-
if (jpgPath && !existsSync2(jpgPath)) {
|
|
383
|
+
if (jpgPath) {
|
|
387
384
|
await writeJpgFromSvg(result.svgPath, jpgPath);
|
|
388
385
|
console.log(
|
|
389
386
|
`[remark-latex-compile] ${filePath}:${lineNumberStr}: wrote ${jpgPath}`
|
|
@@ -405,8 +402,7 @@ function remarkLatexCompile(options) {
|
|
|
405
402
|
`[remark-latex-compile] ${filePath}:${lineNumberStr}
|
|
406
403
|
${details}`
|
|
407
404
|
);
|
|
408
|
-
|
|
409
|
-
if (jpgPath && !existsSync2(jpgPath)) {
|
|
405
|
+
if (jpgPath) {
|
|
410
406
|
await writeJpgError(
|
|
411
407
|
jpgPath,
|
|
412
408
|
`${filePath}:${lineNumberStr}`,
|
package/dist/index.js
CHANGED
package/package.json
CHANGED