starlight-cannoli-plugins 2.12.1 → 2.13.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
@@ -121,7 +121,6 @@ Automatically compiles fenced `tex compile` and `latex compile` code blocks to S
121
121
  - Compiles LaTeX/TikZ code blocks to SVG automatically
122
122
  - Caches compiled SVGs by content hash (no recompilation if unchanged)
123
123
  - Comprehensive error reporting with line numbers and formatted LaTeX source
124
- - Supports custom preamble via `% ===` separator in code blocks
125
124
  - Works with Starlight and plain Astro projects
126
125
  - Requires `svgOutputDir` configuration (no defaults)
127
126
 
@@ -178,46 +177,22 @@ Use either ` ```tex compile ` or ` ```latex compile ` — both work identically:
178
177
 
179
178
  ````markdown
180
179
  ```tex compile
180
+ \documentclass[border=5pt]{standalone}
181
+ \usepackage{tikz}
182
+ \begin{document}
183
+ \Large
181
184
  \begin{tikzpicture}
182
185
  \node (A) at (0,0) {A};
183
186
  \node (B) at (2,0) {B};
184
187
  \draw (A) -- (B);
185
188
  \end{tikzpicture}
186
- ```
187
- ````
188
-
189
- **Minimal approach:**
190
-
191
- Use `% ===` to separate an optional custom preamble from your diagram content. The plugin wraps everything in the following document structure:
192
-
193
- ```latex
194
- \documentclass[border=5pt]{standalone}
195
- {your preamble}
196
- \begin{document}
197
- \Large
198
- {your content}
199
189
  \end{document}
200
190
  ```
201
-
202
- Example **minimal** tex code block:
203
-
204
- ````markdown
205
- ```tex compile
206
- \usepackage{tikz-3dplot}
207
-
208
- % ===
209
-
210
- \begin{tikzpicture}
211
- % diagram code here
212
- \end{tikzpicture}
213
- ```
214
191
  ````
215
192
 
216
- If no `% ===` separator is present, the entire block is treated as content and wrapped in the same default document structure (with an empty preamble).
193
+ **Document structure:**
217
194
 
218
- **Complete Document Control:**
219
-
220
- 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:
195
+ Each code block must be a complete, self-contained LaTeX document:
221
196
 
222
197
  ````markdown
223
198
  ```tex compile
@@ -244,9 +219,14 @@ The following attributes can be added to the opening fence:
244
219
 
245
220
  ````markdown
246
221
  ```tex compile class="bg-white rounded-1" alt="A commutative diagram"
222
+ \documentclass[border=5pt]{standalone}
223
+ \usepackage{tikz}
224
+ \begin{document}
225
+ \Large
247
226
  \begin{tikzpicture}
248
227
  \node {Custom styled diagram};
249
228
  \end{tikzpicture}
229
+ \end{document}
250
230
  ```
251
231
  ````
252
232
 
@@ -425,6 +405,50 @@ export default defineConfig({
425
405
  });
426
406
  ```
427
407
 
408
+ ### Expressive Code Emphasis
409
+
410
+ An Expressive Code plugin that highlights specific terms inside code blocks using the `emph` meta attribute. Matched terms are wrapped in a `<span class="fw-supreme">` for custom styling.
411
+
412
+ **Features:**
413
+
414
+ - Comma-separated list of terms to emphasize per code block
415
+ - Exact-word matching: terms surrounded by word boundaries or whitespace/string edges are matched; partial substrings are not
416
+ - Supports non-word characters (e.g. `(`, `]`, `;`) as well as identifiers
417
+
418
+ **Usage:**
419
+
420
+ Register the plugin with Expressive Code:
421
+
422
+ ```ts
423
+ // astro.config.mjs
424
+ import { defineConfig } from "astro/config";
425
+ import starlight from "@astrojs/starlight";
426
+ import { expressiveCodeEmphasis } from "starlight-cannoli-plugins";
427
+
428
+ export default defineConfig({
429
+ integrations: [
430
+ starlight({
431
+ title: "My Docs",
432
+ expressiveCode: {
433
+ plugins: [expressiveCodeEmphasis()],
434
+ },
435
+ }),
436
+ ],
437
+ });
438
+ ```
439
+
440
+ Then use the `emph` meta attribute on any code block:
441
+
442
+ ````markdown
443
+ ```js emph="foo,bar,()"
444
+ function foo() {
445
+ return bar() || ();
446
+ }
447
+ ```
448
+ ````
449
+
450
+ Multiple terms are separated by commas. Each term is matched as a whole unit — it must be surrounded by whitespace, start/end of line, or (for terms that start/end with word characters) word boundaries.
451
+
428
452
  ## CLI Utilities
429
453
 
430
454
  ### cannoli-latex-cleanup