starlight-cannoli-plugins 2.13.0 → 2.14.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/README.md
CHANGED
|
@@ -142,7 +142,8 @@ dvisvgm --version
|
|
|
142
142
|
|
|
143
143
|
- `svgOutputDir` (required): Directory where compiled SVG files are written. Must be inside `public/` so Astro serves them as static assets.
|
|
144
144
|
- `removeOrphanedSvgs` (optional, default: `false`): When `true`, SVG files that are no longer referenced by any `tex compile` block are deleted automatically. In dev mode, stale SVGs are removed immediately when a block is edited. On build, any remaining orphans are swept at the end.
|
|
145
|
-
- `
|
|
145
|
+
- `svgClassname` (optional): Default CSS class(es) applied to every compiled SVG `<img>` element. Individual blocks can override this with a `class` meta tag value. The `tex-compiled` class is always present and cannot be overridden.
|
|
146
|
+
- `texInputDirs` (optional): Directories added to the TeX input search path (`TEXINPUTS`), allowing `\input{}` and `\include{}` to resolve files from your project. Use a trailing `/` to search only that directory, or `//` to search it recursively. Multiple directories are supported. When any file in these directories changes, all cached SVGs are invalidated and recompiled.
|
|
146
147
|
- `tempOutputDir` (optional): When set, a JPEG copy of each compiled diagram is written to this directory, mirroring the folder structure of `src/content/docs/`. Only blocks that carry a `blockid=<n>` meta tag produce a JPEG — blocks without it are ignored. The filename format is `<originating-file>--<blockid>--<hash>.jpg` (e.g. `tex-test.md--5--abc123.jpg`). JPEGs are deleted automatically when their block is removed, its `blockid` changes, or its content changes. SVG output is unaffected — the JPEG is complementary and intended for local inspection.
|
|
147
148
|
|
|
148
149
|
```ts
|
|
@@ -263,7 +263,7 @@ function computeJpgPath(tempOutputDir, filePath, blockId) {
|
|
|
263
263
|
}
|
|
264
264
|
async function writeJpgFromSvg(svgPath, jpgPath) {
|
|
265
265
|
mkdirSync(dirname(jpgPath), { recursive: true });
|
|
266
|
-
await sharp(svgPath).flatten({ background: { r: 255, g: 255, b: 255 } }).jpeg({ quality: 90 }).toFile(jpgPath);
|
|
266
|
+
await sharp(svgPath, { density: 300 }).flatten({ background: { r: 255, g: 255, b: 255 } }).jpeg({ quality: 90 }).toFile(jpgPath);
|
|
267
267
|
}
|
|
268
268
|
function stripAnsi(text) {
|
|
269
269
|
return text.replace(/\x1b\[[0-9;]*m/g, "");
|
|
@@ -620,14 +620,15 @@ ${details}`
|
|
|
620
620
|
continue;
|
|
621
621
|
}
|
|
622
622
|
const metaOptions = new MetaOptions(node.meta ?? "");
|
|
623
|
-
const
|
|
623
|
+
const blockClass = metaOptions.getString("class");
|
|
624
|
+
const extraClasses = (blockClass !== void 0 ? blockClass : options.svgClassname ?? "").split(/\s+/).filter(Boolean);
|
|
624
625
|
const altText = metaOptions.getString("alt") ?? "LaTeX diagram";
|
|
625
626
|
const imageNode = {
|
|
626
627
|
type: "image",
|
|
627
628
|
url: `/static/tex-svgs/${result.hash}.svg`,
|
|
628
629
|
alt: altText,
|
|
629
630
|
data: {
|
|
630
|
-
hProperties: { className: ["tex-compiled", ...
|
|
631
|
+
hProperties: { className: ["tex-compiled", ...extraClasses] }
|
|
631
632
|
}
|
|
632
633
|
};
|
|
633
634
|
const paragraph = {
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,12 @@ interface RemarkLatexCompileOptions {
|
|
|
22
22
|
* Must be inside `public/` so Astro serves them as static assets.
|
|
23
23
|
*/
|
|
24
24
|
svgOutputDir: string;
|
|
25
|
+
/**
|
|
26
|
+
* Default CSS class(es) applied to every compiled SVG `<img>` element.
|
|
27
|
+
* Individual blocks can override this with a `class` meta tag value.
|
|
28
|
+
* The `tex-compiled` class is always present and cannot be overridden.
|
|
29
|
+
*/
|
|
30
|
+
svgClassname?: string;
|
|
25
31
|
/**
|
|
26
32
|
* Directories added to the TeX input search path via TEXINPUTS, allowing
|
|
27
33
|
* \input{} and \include{} to resolve files from your project. Use a trailing
|
package/package.json
CHANGED