Quarto's built-in option for folding code only covers executable cell output. This extension allows non-executable fenced code blocks to be wrapped in a <details> toggle.
Requires Quarto >= 1.4.0.
quarto add beck-chan/quarto-foldcodeAdd the filter to the YAML frontmatter on a .qmd file or your top-level _quarto.yml:
filters:
- fold-codeAdd fold=true or .fold to a fenced code block to collapse it:
```{.yaml fold=true}
key: value
``````{.yaml .fold}
key: value
```Start expanded with a custom summary label:
```{.yaml fold=false summary="Show config"}
key: value
```{.fold} on the block is the same as fold=true.
| Attribute | Values | Default |
|---|---|---|
fold |
true — collapsed; false — expanded |
off |
summary |
summary label text | show code |
If you liked this extension and found it useful, please consider donating via Ko-fi: https://ko-fi.com/beckchan