starlight-cannoli-plugins 1.2.2 → 1.2.3
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
|
@@ -99,6 +99,8 @@ export default defineConfig({
|
|
|
99
99
|
|
|
100
100
|
**Markdown Syntax:**
|
|
101
101
|
|
|
102
|
+
Use either ` ```tex compile ` or ` ```latex compile ` — both work identically:
|
|
103
|
+
|
|
102
104
|
````markdown
|
|
103
105
|
```tex compile
|
|
104
106
|
\begin{tikzpicture}
|
|
@@ -125,6 +127,40 @@ Use `%---` to separate custom preamble from diagram content:
|
|
|
125
127
|
```
|
|
126
128
|
````
|
|
127
129
|
|
|
130
|
+
**Complete Document Control:**
|
|
131
|
+
|
|
132
|
+
If your code block contains both `\documentclass` and `\begin{document}`, the plugin treats it as a complete, self-contained LaTeX document and uses it as-is without checking for a `%---` separator for a preamble:
|
|
133
|
+
|
|
134
|
+
````markdown
|
|
135
|
+
```tex compile
|
|
136
|
+
\documentclass[border=10pt]{standalone}
|
|
137
|
+
\usepackage{tikz}
|
|
138
|
+
\usepackage{amsmath}
|
|
139
|
+
|
|
140
|
+
\begin{document}
|
|
141
|
+
|
|
142
|
+
\begin{equation*}
|
|
143
|
+
E = mc^2
|
|
144
|
+
\end{equation*}
|
|
145
|
+
|
|
146
|
+
\end{document}
|
|
147
|
+
```
|
|
148
|
+
````
|
|
149
|
+
|
|
150
|
+
**Custom CSS Classes:**
|
|
151
|
+
|
|
152
|
+
Add custom CSS classes to the generated `<img>` that defines the compiled LaTeX diagram using `class="..."`:
|
|
153
|
+
|
|
154
|
+
````markdown
|
|
155
|
+
```tex compile class="bg-white rounded-1"
|
|
156
|
+
\begin{tikzpicture}
|
|
157
|
+
\node {Custom styled diagram};
|
|
158
|
+
\end{tikzpicture}
|
|
159
|
+
```
|
|
160
|
+
````
|
|
161
|
+
|
|
162
|
+
The img element will have classes: `tex-compiled bg-white rounded-1` (note: the `tex-compiled` class is always included by default).
|
|
163
|
+
|
|
128
164
|
### Remark LaTeX Compile
|
|
129
165
|
|
|
130
166
|
The underlying remark plugin that powers `starlightLatexCompile`. Use this directly in Astro projects that don't use Starlight.
|
|
@@ -241,6 +241,13 @@ Error: ${errorOutput}`
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
// src/plugins/remark-latex-compile/index.ts
|
|
244
|
+
function extractClassesFromMeta(meta) {
|
|
245
|
+
const classMatch = meta.match(/class="([^"]+)"/);
|
|
246
|
+
if (classMatch && classMatch[1]) {
|
|
247
|
+
return classMatch[1].split(/\s+/).filter(Boolean);
|
|
248
|
+
}
|
|
249
|
+
return [];
|
|
250
|
+
}
|
|
244
251
|
function traverseTree(node, svgOutputDir, filePath, depth = 0) {
|
|
245
252
|
if (!node) return;
|
|
246
253
|
const children = node.children;
|
|
@@ -250,6 +257,10 @@ function traverseTree(node, svgOutputDir, filePath, depth = 0) {
|
|
|
250
257
|
if (child.type === "code" && (child.lang === "tex" || child.lang === "latex") && String(child.meta || "").includes("compile")) {
|
|
251
258
|
try {
|
|
252
259
|
const result = compileLatexToSvg(String(child.value), svgOutputDir);
|
|
260
|
+
const customClasses = extractClassesFromMeta(
|
|
261
|
+
String(child.meta || "")
|
|
262
|
+
);
|
|
263
|
+
const allClasses = ["tex-compiled", ...customClasses];
|
|
253
264
|
children[i] = {
|
|
254
265
|
type: "paragraph",
|
|
255
266
|
children: [
|
|
@@ -259,7 +270,7 @@ function traverseTree(node, svgOutputDir, filePath, depth = 0) {
|
|
|
259
270
|
alt: "LaTeX diagram",
|
|
260
271
|
data: {
|
|
261
272
|
hProperties: {
|
|
262
|
-
className:
|
|
273
|
+
className: allClasses
|
|
263
274
|
}
|
|
264
275
|
}
|
|
265
276
|
}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED