-
Notifications
You must be signed in to change notification settings - Fork 388
Open
Labels
documentationDoc improvements & quarto-webDoc improvements & quarto-web
Description
With QUARTO_EXECUTE_INFO, we now have an approach to conditional execution that works across engines.
For example, for code that should be only executed for HTML formats:
R:
```{r}
execute_info <- jsonlite::read_json(Sys.getenv("QUARTO_EXECUTE_INFO"))
is_html <- execute_info[["format"]][["identifier"]][["base-format"]] == "html"
if (is_html) {
"HTML"
}
```Python:
```{python}
import json
import os
with open(os.getenv("QUARTO_EXECUTE_INFO")) as f:
execute_info = json.load(f)
is_html = execute_info["format"]["identifier"]["base-format"] == "html"
if is_html:
print("HTML")
```Users often want to combine this with conditional content.
This could be documented:
- as a section of
/docs/computations/execution-options.qmd - its own "Conditional Execution" page under Guide > Computations
- as an example wherever the docs for
QUARTO_EXECUTE_INFOend up - as a blog post on "Conditional Execution"
Regardless of where the examples end up, it should be mentioned and linked to from:
- Guide > Computations > Using Python
- Guide > Computations > Using R
- Guide > Computations > Using Julia
- Guide > Authoring > Advanced > Conditional Content
- https://quarto.org/docs/authoring/cross-references-divs.html#conditional-content
- Wherever the docs for
QUARTO_EXECUTE_INFOend up
Some relevant issues and discussions this would resolve:
mcanouil
Metadata
Metadata
Assignees
Labels
documentationDoc improvements & quarto-webDoc improvements & quarto-web