starlight-cannoli-plugins 2.13.1 → 2.14.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 +2 -23
- package/dist/{chunk-57RXO5LG.js → chunk-ETBDUEFH.js} +3 -2
- package/dist/index.d.ts +2 -3
- package/dist/index.js +31 -3
- package/dist/plugins/astro-latex-compile.d.ts +6 -0
- package/dist/plugins/astro-latex-compile.js +1 -1
- package/dist/styles/_starlight.scss +0 -23
- package/package.json +1 -1
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
|
|
@@ -230,28 +231,6 @@ The following attributes can be added to the opening fence:
|
|
|
230
231
|
```
|
|
231
232
|
````
|
|
232
233
|
|
|
233
|
-
### Remark LaTeX Compile (low-level)
|
|
234
|
-
|
|
235
|
-
The underlying remark plugin used by `astroLatexCompile`. Use this directly if you need to wire the transformer into a custom pipeline — most users should use `astroLatexCompile` instead.
|
|
236
|
-
|
|
237
|
-
**Usage:**
|
|
238
|
-
|
|
239
|
-
```ts
|
|
240
|
-
// astro.config.mjs
|
|
241
|
-
import { defineConfig } from "astro/config";
|
|
242
|
-
import { remarkLatexCompile } from "starlight-cannoli-plugins/astro-latex-compile";
|
|
243
|
-
|
|
244
|
-
export default defineConfig({
|
|
245
|
-
markdown: {
|
|
246
|
-
remarkPlugins: [
|
|
247
|
-
[remarkLatexCompile, { svgOutputDir: "public/static/tex-svgs" }],
|
|
248
|
-
],
|
|
249
|
-
},
|
|
250
|
-
});
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
Note: when used directly (without `astroLatexCompile`), the Starlight content layer cache is not cleared automatically, so SVGs may not recompile on repeat builds in Starlight projects.
|
|
254
|
-
|
|
255
234
|
### Rehype Validate Links
|
|
256
235
|
|
|
257
236
|
A rehype plugin that validates all internal links in your Markdown/MDX files at build time. Links without matching files will cause the build to fail.
|
|
@@ -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.d.ts
CHANGED
|
@@ -4,14 +4,13 @@ export { DomPatchesOptions, starlightDomPatches } from './plugins/starlight-dom-
|
|
|
4
4
|
export { SyncDocsToPublicOptions, syncDocsToPublic } from './plugins/astro-sync-docs-to-public.js';
|
|
5
5
|
export { rehypeValidateLinks } from './plugins/rehype-validate-links.js';
|
|
6
6
|
export { astroNormalizePaths } from './plugins/astro-normalize-paths.js';
|
|
7
|
-
import { RemarkLatexCompileOptions } from './plugins/astro-latex-compile.js';
|
|
8
|
-
export { remarkLatexCompile } from './plugins/astro-latex-compile.js';
|
|
9
7
|
export { expressiveCodeEmphasis } from './plugins/expressive-code-emphasis.js';
|
|
10
8
|
import { AstroIntegration } from 'astro';
|
|
9
|
+
import { RemarkLatexCompileOptions } from './plugins/astro-latex-compile.js';
|
|
11
10
|
import 'hast';
|
|
12
11
|
import 'vfile';
|
|
13
|
-
import 'mdast';
|
|
14
12
|
import 'expressive-code';
|
|
13
|
+
import 'mdast';
|
|
15
14
|
|
|
16
15
|
type TBadgeVariant = "note" | "danger" | "success" | "caution" | "tip" | "default";
|
|
17
16
|
type TIndexMarker = {
|
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-
|
|
12
|
+
} from "./chunk-ETBDUEFH.js";
|
|
13
13
|
import {
|
|
14
14
|
astroNormalizePaths
|
|
15
15
|
} from "./chunk-TLOFSB33.js";
|
|
@@ -232,6 +232,26 @@ function starlightIndexSourcedSidebar(options) {
|
|
|
232
232
|
import fs2 from "fs";
|
|
233
233
|
import { readdir, rm } from "fs/promises";
|
|
234
234
|
import { join as join3, resolve as resolve2 } from "path";
|
|
235
|
+
var js = String.raw;
|
|
236
|
+
var DARK_MODE_ROTATE = "178deg";
|
|
237
|
+
var INJECTED_CSS = `
|
|
238
|
+
:root {
|
|
239
|
+
--cannoli-error-low: hsl(0, 70%, 94%);
|
|
240
|
+
--cannoli-error: hsl(0, 72%, 42%);
|
|
241
|
+
--cannoli-error-high: hsl(0, 72%, 28%);
|
|
242
|
+
}
|
|
243
|
+
[data-theme="dark"] {
|
|
244
|
+
--cannoli-error-low: hsl(0, 55%, 16%);
|
|
245
|
+
--cannoli-error: hsl(0, 75%, 60%);
|
|
246
|
+
--cannoli-error-high: hsl(0, 80%, 82%);
|
|
247
|
+
}
|
|
248
|
+
.tex-compiled {
|
|
249
|
+
background-color: transparent;
|
|
250
|
+
}
|
|
251
|
+
html[data-theme="dark"] .tex-compiled {
|
|
252
|
+
filter: invert(1) hue-rotate(${DARK_MODE_ROTATE});
|
|
253
|
+
}
|
|
254
|
+
`;
|
|
235
255
|
var DATA_STORE_FILE = "data-store.json";
|
|
236
256
|
function getDataStoreFile(config) {
|
|
237
257
|
return new URL(DATA_STORE_FILE, config.cacheDir);
|
|
@@ -249,8 +269,17 @@ function astroLatexCompile(options) {
|
|
|
249
269
|
return {
|
|
250
270
|
name: "astro-latex-compile",
|
|
251
271
|
hooks: {
|
|
252
|
-
"astro:config:setup": async ({
|
|
272
|
+
"astro:config:setup": async ({
|
|
273
|
+
command,
|
|
274
|
+
config,
|
|
275
|
+
updateConfig,
|
|
276
|
+
injectScript
|
|
277
|
+
}) => {
|
|
253
278
|
if (command !== "build" && command !== "dev") return;
|
|
279
|
+
injectScript(
|
|
280
|
+
"page",
|
|
281
|
+
js`{ const s = document.createElement("style"); s.textContent = ${JSON.stringify(INJECTED_CSS)}; document.head.appendChild(s); }`
|
|
282
|
+
);
|
|
254
283
|
if (command === "build") {
|
|
255
284
|
await clearContentLayerCache(config);
|
|
256
285
|
}
|
|
@@ -299,7 +328,6 @@ export {
|
|
|
299
328
|
astroNormalizePaths,
|
|
300
329
|
expressiveCodeEmphasis,
|
|
301
330
|
rehypeValidateLinks,
|
|
302
|
-
remarkLatexCompile,
|
|
303
331
|
starlightDomPatches,
|
|
304
332
|
starlightIndexOnlySidebar,
|
|
305
333
|
starlightIndexSourcedSidebar,
|
|
@@ -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
|
|
@@ -2,21 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
$DARK_MODE_ROTATE: 178deg;
|
|
4
4
|
|
|
5
|
-
/********** Custom Error Colors **********/
|
|
6
|
-
// Starlight's --sl-color-red-* sit at hsl(349°) which reads as pink/magenta.
|
|
7
|
-
// These replacements use true red (0°) for a more conventional error appearance.
|
|
8
|
-
:root {
|
|
9
|
-
--cannoli-error-low: hsl(0, 70%, 94%);
|
|
10
|
-
--cannoli-error: hsl(0, 72%, 42%);
|
|
11
|
-
--cannoli-error-high: hsl(0, 72%, 28%);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
[data-theme="dark"] {
|
|
15
|
-
--cannoli-error-low: hsl(0, 55%, 16%);
|
|
16
|
-
--cannoli-error: hsl(0, 75%, 60%);
|
|
17
|
-
--cannoli-error-high: hsl(0, 80%, 82%);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
5
|
.sl-container:where(.astro-7nkwcw3z) {
|
|
21
6
|
max-width: 50rem;
|
|
22
7
|
}
|
|
@@ -267,11 +252,3 @@ img.note-svg {
|
|
|
267
252
|
filter: invert(1) hue-rotate($DARK_MODE_ROTATE);
|
|
268
253
|
}
|
|
269
254
|
}
|
|
270
|
-
|
|
271
|
-
.tex-compiled {
|
|
272
|
-
background-color: transparent;
|
|
273
|
-
|
|
274
|
-
html[data-theme="dark"] & {
|
|
275
|
-
filter: invert(1) hue-rotate($DARK_MODE_ROTATE);
|
|
276
|
-
}
|
|
277
|
-
}
|
package/package.json
CHANGED