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, hash) {
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}--${hash}.jpg`;
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 contentHash = hashLatexCode(node.value);
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
- const jpgPath = canWriteJpg ? computeJpgPath(options.tempOutputDir, filePath, blockId, contentHash) : null;
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
- const jpgPath = canWriteJpg ? computeJpgPath(options.tempOutputDir, filePath, blockId, `${contentHash}--error`) : null;
409
- if (jpgPath && !existsSync2(jpgPath)) {
405
+ if (jpgPath) {
410
406
  await writeJpgError(
411
407
  jpgPath,
412
408
  `${filePath}:${lineNumberStr}`,
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-3UMY7T6G.js";
10
10
  import {
11
11
  remarkLatexCompile
12
- } from "./chunk-G2PJENXJ.js";
12
+ } from "./chunk-OLF3SRCP.js";
13
13
  import {
14
14
  astroNormalizePaths
15
15
  } from "./chunk-TLOFSB33.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  compileLatexToSvg,
3
3
  remarkLatexCompile
4
- } from "../chunk-G2PJENXJ.js";
4
+ } from "../chunk-OLF3SRCP.js";
5
5
  import "../chunk-4VNS5WPM.js";
6
6
  export {
7
7
  compileLatexToSvg,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "starlight-cannoli-plugins",
3
3
  "type": "module",
4
- "version": "2.12.0",
4
+ "version": "2.12.1",
5
5
  "description": "Starlight plugins for automatic sidebar generation and link validation",
6
6
  "license": "ISC",
7
7
  "main": "./dist/index.js",