Skip to content

Commit 8e2b6c6

Browse files
committed
docs: update README and example with hotfix config and PR #14170 notice
Update configuration examples to use nested `hotfix` key. Add hotfix options table and a dedicated "Temporary Hot-fixes (Typst)" section explaining that code-annotations and skylighting fixes will be removed once quarto-dev/quarto-cli#14170 lands. Add callout note in example.qmd about the temporary nature of Typst code-annotations support.
1 parent b41d14c commit 8e2b6c6

File tree

2 files changed

+115
-14
lines changed

2 files changed

+115
-14
lines changed

README.md

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,30 @@ extensions:
5858
auto-filename: true
5959
style: "macos"
6060
wrapper: "code-window"
61-
skylighting-fix: true
61+
hotfix:
62+
quarto-version: ~
63+
code-annotations: true
64+
skylighting: true
6265
```
6366

6467
### Options
6568

66-
| Option | Type | Default | Description |
67-
| ----------------- | ------- | --------------- | ----------------------------------------------------------------------------------- |
68-
| `enabled` | boolean | `true` | Enable or disable the code-window filter. |
69-
| `auto-filename` | boolean | `true` | Automatically generate filename labels from the code block language. |
70-
| `style` | string | `"macos"` | Window decoration style: `"macos"`, `"windows"`, or `"default"`. |
71-
| `wrapper` | string | `"code-window"` | Typst wrapper function name for code-window rendering. |
72-
| `skylighting-fix` | boolean | `true` | Enable or disable the Skylighting hot-fix for Typst output (block and inline code). |
69+
| Option | Type | Default | Description |
70+
| --------------- | ------- | --------------- | -------------------------------------------------------------------- |
71+
| `enabled` | boolean | `true` | Enable or disable the code-window filter. |
72+
| `auto-filename` | boolean | `true` | Automatically generate filename labels from the code block language. |
73+
| `style` | string | `"macos"` | Window decoration style: `"macos"`, `"windows"`, or `"default"`. |
74+
| `wrapper` | string | `"code-window"` | Typst wrapper function name for code-window rendering. |
75+
76+
### Hotfix Options
77+
78+
These options are **temporary** and will be removed in a future version (see [Temporary hot-fixes](#temporary-hot-fixes-typst)).
79+
80+
| Option | Type | Default | Description |
81+
| ------------------------- | ------- | ------- | ------------------------------------------------------------------------------------------ |
82+
| `hotfix.quarto-version` | string | _unset_ | Quarto version at or above which all hot-fixes are automatically disabled. |
83+
| `hotfix.code-annotations` | boolean | `true` | Enable the code-annotations hot-fix for Typst output. |
84+
| `hotfix.skylighting` | boolean | `true` | Enable the Skylighting hot-fix for Typst output (overrides block styling and inline code). |
7385

7486
### Styles
7587

@@ -87,17 +99,32 @@ print("Windows style for this block only")
8799
```
88100
````
89101

90-
### Typst Skylighting Hot-fix (Integrated)
102+
### Temporary Hot-fixes (Typst)
103+
104+
The extension includes two temporary hot-fixes for Typst output that compensate for missing Quarto/Pandoc features.
105+
Both will be removed once [quarto-dev/quarto-cli#14170](https://github.com/quarto-dev/quarto-cli/pull/14170) is released.
106+
After that, the extension will focus solely on **auto-filename** and **code-window-style** features.
107+
108+
- **`hotfix.code-annotations`**: processes code annotation markers for Typst, since Quarto does not yet support `code-annotations` in Typst output.
109+
The `filename` attribute for code blocks will also become natively supported.
110+
- **`hotfix.skylighting`**: overrides Pandoc's Skylighting output for Typst to fix block and inline code styling.
91111

92-
`code-window` loads its Typst skylighting hot-fix internally from `_extensions/code-window/skylighting-typst-fix.lua`, so no second filter entry is required.
93-
Set `skylighting-fix: false` to disable the hot-fix without removing the file.
112+
Set `hotfix.quarto-version` to automatically disable both hot-fixes once you update Quarto to the version that includes native support:
94113

95-
This keeps the hot-fix separated from `code-window.lua` for easy future removal while preserving combined behaviour.
114+
```yaml
115+
extensions:
116+
code-window:
117+
hotfix:
118+
quarto-version: "1.10.0"
119+
```
96120

97121
Future removal playbook:
98122

99-
1. Remove the skylighting loader call in `_extensions/code-window/code-window.lua`.
100-
2. Delete `_extensions/code-window/skylighting-typst-fix.lua`.
123+
1. Delete `hotfix` parsing from `code-window.lua` (`HOTFIX_DEFAULTS`, hotfix section in `Meta`).
124+
2. Remove the `hotfix` section from `_schema.yml`.
125+
3. Remove the skylighting guard and loader in `main.lua`.
126+
4. Remove annotation processing from `code-window.lua`.
127+
5. Delete `_modules/hotfix/` directory entirely.
101128

102129
## Example
103130

example.qmd

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ filters:
99
- at: pre-quarto
1010
path: code-window
1111
syntax-highlighting: github-dark
12+
code-annotations: below
1213
format:
1314
html:
1415
output-file: index
@@ -116,6 +117,75 @@ Plain filename on the left, no window decorations.
116117
print("Default style window")
117118
```
118119

120+
## Code Annotations
121+
122+
::: {.callout-note}
123+
Typst code-annotations support and `filename` attribute handling are temporary hot-fixes.
124+
They will be removed once Quarto natively supports these features (see [quarto-dev/quarto-cli#14170](https://github.com/quarto-dev/quarto-cli/pull/14170)).
125+
The extension will then focus on **auto-filename** and **code-window-style** features.
126+
:::
127+
128+
Code annotations work standalone and together with code-window styling.
129+
130+
### Annotations with Explicit Filename
131+
132+
```{.python filename="annotated.py"}
133+
import pandas as pd # <1>
134+
135+
df = pd.read_csv("data.csv") # <2>
136+
summary = df.describe() # <3>
137+
```
138+
139+
1. Import the pandas library.
140+
2. Load data from a CSV file.
141+
3. Generate summary statistics.
142+
143+
### Annotations with Auto-Filename
144+
145+
```python
146+
def greet(name: str) -> str: # <1>
147+
return f"Hello, {name}!" # <2>
148+
149+
result = greet("World") # <3>
150+
```
151+
152+
1. Define a function with type hints.
153+
2. Use an f-string for interpolation.
154+
3. Call the function and store the result.
155+
156+
### Annotations Spanning Multiple Lines
157+
158+
A single annotation number can appear on several consecutive lines.
159+
Only the first occurrence receives a back-label to avoid duplicates.
160+
161+
```{.python filename="pipeline.py"}
162+
def process(data): # <1>
163+
cleaned = clean(data) # <1>
164+
validated = validate(cleaned) # <1>
165+
result = transform(validated) # <2>
166+
return result # <3>
167+
```
168+
169+
1. Multi-step input preparation (cleaning and validation).
170+
2. Apply the main transformation.
171+
3. Return the final result.
172+
173+
### Annotations without Window Chrome
174+
175+
Set `code-window-enabled="false"` on a block to disable window chrome while keeping annotations.
176+
177+
```{.r code-window-enabled="false"}
178+
library(ggplot2) # <1>
179+
ggplot(mtcars) + # <2>
180+
aes(x = mpg, y = hp) + # <3>
181+
geom_point() # <4>
182+
```
183+
184+
1. Load the ggplot2 package.
185+
2. Initialise a plot with the mtcars dataset.
186+
3. Map aesthetics.
187+
4. Add a point geometry layer.
188+
119189
### Configuration
120190

121191
Set the global style in the document front matter:
@@ -124,6 +194,10 @@ Set the global style in the document front matter:
124194
extensions:
125195
code-window:
126196
style: "macos"
197+
hotfix:
198+
quarto-version: ~
199+
code-annotations: true
200+
skylighting: true
127201
```
128202
129203
Override per block with the `code-window-style` attribute:

0 commit comments

Comments
 (0)