Reference

Every option the code-window extension accepts.

The complete code-window configuration: the document options, the per-block attributes, the window styles, and the Typst hot-fixes.

Enabling the filter

filters:
  - code-window

Options

extensions:
  code-window:
    style: macos
    auto-filename: true
    cell-output: false
    collapse: false
    lines-label: true
Document and project options.
Option Type Default Description
enabled boolean true Whether the filter runs at all.
style string macos The window chrome: macos for traffic lights, windows for title-bar buttons, default for a plain filename.
auto-filename boolean true Use the block’s language as the filename when none is given.
cell-output boolean false Frame the output of an executed cell as well as its source.
collapse boolean or string false Wrap every block in a <details>. open renders it expanded, closed or true collapsed. HTML only.
lines-label boolean true Show a chip beside the filename with the highlighted-line spec.
wrapper string code-window The Typst function used to draw the chrome.
hotfix object all on The Typst hot-fixes below.

Per-block attributes

```{.yaml filename="_quarto.yml" code-window-style="windows"}
```
Attributes accepted on a code block.
Attribute Type Description
code-window-enabled boolean Whether this block gets chrome. Annotations still render when it does not.
code-window-no-auto-filename boolean Suppress the derived filename for this block alone.
code-window-style string Override the style for this block: macos, windows, default.
code-window-collapse boolean or string Fold this block: open, closed, true, or false. HTML only.
code-window-lines string The line spec shown in the chip, such as 1,3-5. Defaults to Quarto’s code-line-numbers.

Quarto’s own filename attribute names the window.

Note

A derived filename is applied later than an author-set one. Quarto builds its own wrapper before this filter runs, so a block with no filename leaves the filter carrying a data-filename attribute and a marker class instead, and the injected script builds the wrapper at page load. The result is the same window; it needs JavaScript, as the rest of the HTML chrome does. Typst frames derived and author-set filenames alike, without a script.

Executed cells

Quarto writes the output of an executed cell as a code block with no language. That block keeps the shape Quarto gives it: no chrome, and no derived filename. Only the source of the cell is framed.

Set cell-output to true to frame the output as well.

extensions:
  code-window:
    cell-output: true

An engine can put a filename on the output block, through knitr’s attr-output for example. Output named that way is always framed, whatever this option says.

How the chrome is applied

In HTML the extension marks blocks and injects a stylesheet and a script. The script runs at page load and builds the title bar, the fold, and the line chip from those marks, so all three need JavaScript.

In Typst the chrome is a call to the wrapper function, emitted into the document, and needs nothing at read time.

Hot-fixes

Typst output needs a few corrections that Quarto does not yet make itself. Each is on by default and each can be given a version at which it switches itself off, so an upgrade retires it without a code change.

The Typst hot-fixes.
Hot-fix What it corrects
code-annotations Code annotations in Typst output.
skylighting Block styling and inline code backgrounds in Typst output.
typst-title Theorem title strings, evaluated as markup.
extensions:
  code-window:
    hotfix:
      skylighting:
        enabled: true
        quarto-version: "1.9.0"

They exist for quarto-dev/quarto-cli#14170 and will be removed once Quarto covers the same ground.

Interactions

Caution

This filter claims code blocks at pre-quarto, which puts it ahead of anything else that wants them.

Two extensions in this family are affected: typst-render never sees its ```{typst} blocks when this one runs, so no figure is produced; and language-cell-decorator, which this extension supersedes, decorates the same blocks a second time.

Limitations

  • HTML formats and Typst. Elsewhere the code block is left as it is.
  • Folding is HTML only; Typst has no equivalent.
  • The HTML chrome is built by script at page load, so a reader with JavaScript off sees plain code blocks.
  • A block with a derived filename is framed by the script rather than by the wrapper Quarto builds, so it needs JavaScript in HTML like the rest of the chrome.
Back to top