Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

## Unreleased

### New Features

- feat: render a highlighted-lines chip alongside the filename in the code-window title bar (HTML, Reveal.js, and Typst).
Uses Quarto's `code-line-numbers` attribute or a new `code-window-lines` attribute.
The chip can be disabled globally via `lines-label: false`.
- feat: collapsible code windows via a `<details>` wrapper (HTML/Reveal.js).
Per-block opt-in with the `code-window-collapse` attribute (`true`/`false`/`open`/`closed`) or document-wide via the `collapse` option.
- feat: expose CSS custom properties (`--code-window-macos-icon`, `--code-window-windows-icon`, `--code-window-macos-icon-width`, `--code-window-windows-icon-width`, `--code-window-icon-height`) so users can override the window-button icons.

### Documentation

- docs: document `code-line-numbers` integration, the new `collapse` option, and the CSS custom properties for icon overrides.

### Refactoring

- refactor: synchronise shared modules (`html`, `logging`, `metadata`, `pandoc-helpers`, `string`) with canonical versions.

## 1.1.5 (2026-04-21)

### Bug Fixes
Expand Down
74 changes: 62 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ extensions:
auto-filename: true
style: "macos"
wrapper: "code-window"
collapse: false
lines-label: true
hotfix:
code-annotations: true
skylighting: true
Expand All @@ -66,12 +68,14 @@ extensions:

### Options

| Option | Type | Default | Description |
| --------------- | ------- | --------------- | -------------------------------------------------------------------- |
| `enabled` | boolean | `true` | Enable or disable the code-window filter. |
| `auto-filename` | boolean | `true` | Automatically generate filename labels from the code block language. |
| `style` | string | `"macos"` | Window decoration style: `"macos"`, `"windows"`, or `"default"`. |
| `wrapper` | string | `"code-window"` | Typst wrapper function name for code-window rendering. |
| Option | Type | Default | Description |
| --------------- | -------------- | --------------- | -------------------------------------------------------------------------------------------------------- |
| `enabled` | boolean | `true` | Enable or disable the code-window filter. |
| `auto-filename` | boolean | `true` | Automatically generate filename labels from the code block language. Set to `false` to disable globally. |
| `style` | string | `"macos"` | Window decoration style: `"macos"`, `"windows"`, or `"default"`. |
| `wrapper` | string | `"code-window"` | Typst wrapper function name for code-window rendering. |
| `collapse` | boolean/string | `false` | Wrap every code window in a `<details>` element (HTML). Accepts `false`, `true`, `"open"`, `"closed"`. |
| `lines-label` | boolean | `true` | Render a small chip next to the filename showing the highlighted-line spec. |

### Hotfix Options

Expand All @@ -93,20 +97,66 @@ Each hotfix value can be a simple boolean or a map with `enabled` and `quarto-ve

### Block-Level Attributes

Override the style or disable features for a single code block:
Override the style or toggle features for a single code block:

| Attribute | Type | Default | Description |
| ------------------------------- | ------- | ------- | ---------------------------------------------------------------------- |
| `code-window-style` | string | | Override the global style for this block: `"macos"`, `"windows"`, or `"default"`. |
| `code-window-enabled` | boolean | `true` | Set to `false` to disable window chrome while keeping annotations. |
| `code-window-no-auto-filename` | boolean | `false` | Suppress the auto-generated filename for this block. |
| Attribute | Type | Default | Description |
| ------------------------------ | -------------- | ------- | -------------------------------------------------------------------------------------------------------------------- |
| `code-window-style` | string | | Override the global style for this block: `"macos"`, `"windows"`, or `"default"`. |
| `code-window-enabled` | boolean | `true` | Set to `false` to disable window chrome while keeping annotations. |
| `code-window-no-auto-filename` | boolean | `false` | Suppress the auto-generated filename for this block. |
| `code-window-collapse` | boolean/string | | Render this code block inside a `<details>` element (HTML). Accepts `true` (closed), `false`, `"open"`, `"closed"`. |
| `code-window-lines` | string | | Highlighted-lines spec rendered as a chip alongside the filename (e.g. `"1,3-5"`). Falls back to `code-line-numbers`. |

````markdown
```{.python filename="example.py" code-window-style="windows"}
print("Windows style for this block only")
```
````

### Highlighted Lines Chip

When a code block carries Quarto's `code-line-numbers` attribute with a line specification (e.g. `"1,3-5"`), the spec is rendered as a small chip beside the filename in the title bar.

````markdown
```{.python filename="loader.py" code-line-numbers="1,4-5"}
import pandas as pd

def load(path):
df = pd.read_csv(path)
return df.dropna()
```
````

Override the displayed text with `code-window-lines="..."` or disable the chip globally with `lines-label: false`.

### Collapsible Code Windows (HTML)

Set `code-window-collapse` on a block, or `collapse` at the document level, to wrap the code window in a `<details>` element.
The title bar becomes the `<summary>`.

````markdown
```{.python filename="long.py" code-window-collapse="closed"}
# Long block hidden behind a clickable title bar.
print("Click the title bar to expand.")
```
````

This feature applies to HTML and Reveal.js output only.

### Customising Window-Button Icons (HTML)

The macOS and Windows window-button icons are exposed as CSS custom properties so you can override them in your own stylesheet:

```css
:root {
--code-window-macos-icon: url("data:image/svg+xml,...");
--code-window-windows-icon: url("data:image/svg+xml,...");
--code-window-macos-icon-width: 3.4em;
--code-window-windows-icon-width: 3.6em;
--code-window-icon-height: 0.85em;
}
```

### Temporary Hot-fixes (Typst)

The extension includes three temporary hot-fixes for Typst output that compensate for missing Quarto/Pandoc features.
Expand Down
2 changes: 1 addition & 1 deletion _extensions/code-window/_modules/html.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- MC HTML - HTML generation and dependency management for Quarto Lua filters and shortcodes
--- @module html
--- @module "html"
--- @license MIT
--- @copyright 2026 Mickaël Canouil
--- @author Mickaël Canouil
Expand Down
2 changes: 1 addition & 1 deletion _extensions/code-window/_modules/logging.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- MC Logging - Formatted log output for Quarto Lua filters and shortcodes
--- @module logging
--- @module "logging"
--- @license MIT
--- @copyright 2026 Mickaël Canouil
--- @author Mickaël Canouil
Expand Down
2 changes: 1 addition & 1 deletion _extensions/code-window/_modules/metadata.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- MC Metadata - Extension configuration and metadata access for Quarto Lua filters and shortcodes
--- @module metadata
--- @module "metadata"
--- @license MIT
--- @copyright 2026 Mickaël Canouil
--- @author Mickaël Canouil
Expand Down
2 changes: 1 addition & 1 deletion _extensions/code-window/_modules/pandoc-helpers.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- MC Pandoc Helpers - Pandoc element construction and format detection for Quarto Lua filters and shortcodes
--- @module pandoc_helpers
--- @module "pandoc_helpers"
--- @license MIT
--- @copyright 2026 Mickaël Canouil
--- @author Mickaël Canouil
Expand Down
2 changes: 1 addition & 1 deletion _extensions/code-window/_modules/string.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- MC String - String manipulation and escaping for Quarto Lua filters and shortcodes
--- @module string
--- @module "string"
--- @license MIT
--- @copyright 2026 Mickaël Canouil
--- @author Mickaël Canouil
Expand Down
16 changes: 16 additions & 0 deletions _extensions/code-window/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ options:
type: string
default: "code-window"
description: "Typst wrapper function name for code-window rendering."
collapse:
type: [boolean, string]
enum: [true, false, "open", "closed"]
default: false
description: "Wrap every code-window block in a collapsible <details> element (HTML only). Use 'open' to render expanded by default, 'closed' or true to render collapsed by default, false to disable. Per-block overrides use the 'code-window-collapse' attribute."
lines-label:
type: boolean
default: true
description: "Render a small chip next to the filename showing the highlighted-line spec for blocks that set 'code-line-numbers' or 'code-window-lines'."
hotfix:
type: object
description: "Temporary hot-fixes for Typst output. These will be removed when Quarto natively supports the corresponding features (see quarto-dev/quarto-cli#14170)."
Expand Down Expand Up @@ -70,3 +79,10 @@ attributes:
type: string
enum: ["default", "macos", "windows"]
description: "Override the global window decoration style for this specific code block."
code-window-collapse:
type: [boolean, string]
enum: [true, false, "open", "closed"]
description: "Wrap this code block in a collapsible <details> element (HTML only). Use 'open' to render expanded, 'closed' or true to render collapsed, false to disable."
code-window-lines:
type: string
description: "Highlighted-lines spec rendered as a chip alongside the filename (e.g. '1,3-5'). When omitted, Quarto's 'code-line-numbers' attribute is used."
Loading