Skip to content
Closed
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions docs/authoring/conditional.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ You can also set conditions on non-executable code blocks:
```
````

When using the `knitr` engine, if you want to have a code chunk being excecuted/evaluated only when the output is being rendered to HTML or LaTeX you can use the `is_html_output()` and `is_latex_output()` respectively (see [this reply to quarto-cli issue 11724](https://github.com/quarto-dev/quarto-cli/issues/11724#issuecomment-2557635192)).

```` markdown
``` {r .content-visible when-format="html"}
#| eval = !expr knitr::is_html_output()
# code is shown AND evaluated only in HTML
2+2
```
````

To apply a condition only to a part of a paragraph, use a span (`[]{}`):

``` markdown
Expand Down