You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does quarto have built-in environmental variables (or similar) during qmd compilation that reflects the output type? Similar to knitr::is_html_output() but cross-language and more specific about the output type?
I’m trying to write single qmd files for books that get compiled in different formats. Any tools (e.g. chunk options etc) that make that easier would be fantastic.
Right, but I still think we should have something that signals uniformly to Jupyter and knitr and future extensions; I think the question was posed in the context of running Python code.
Oh I see. No specific formatting, just passing the object. I forgot about JSON as message format. interesting ! I can submit something with all this information. Cool !
Quarto 1.8 exports QUARTO_EXECUTE_INFO, an env var that points to a JSON file with ample execution information, including format (it's in fact the data in the ExecuteOptions object mentioned above)
I believe this issue was about make something like knitr::is_html_output() available to all engines, and closer to Quarto's format.
Exposing all information in QUARTO_EXECUTE_INFO is really cool because it offers a lot of information to users and developers of tools; however, this means two things to me
QUARTO_EXECUTE_INFO content should be documented properly if we expect users to use it correctly. Just on format specifiers, some fields are Quarto-specific (e.g., base-format vs. target-format). Probably part of our more advanced doc.
Both the quarto R package and the quarto Python module should have helpers functions so users can access relevant information without knowing which fields to retrieve. This is especially useful to really provide an is_html_output() equivalent, or a more generic quarto_to(). quarto-dev/quarto-r#285 tracks this idea.
Activity
dragonstyle commentedon Sep 23, 2022
You can use conditional content at the markdown level: https://quarto.org/docs/authoring/conditional.html
The knitr functions like is_html_output should also still work.
cscheid commentedon Oct 5, 2022
Right, but I still think we should have something that signals uniformly to Jupyter and knitr and future extensions; I think the question was posed in the context of running Python code.
cscheid commentedon Oct 12, 2022
Reference:
notebook.py:88is the place to do this in Jupyter,execute.R:221in Rcderv commentedon Jan 26, 2024
For reference, other mention of this in:
5 remaining items
cderv commentedon Sep 5, 2024
We just need to choose the name of the environment, and which part of the format are we passing.
I mean
pdf,revealjs,html,typst, ...)gfmbeing pandoc'scommonmark+ variants) ?dashboard?email?docusaurus?)Maybe we need to mimic how we split in Typescript ? (in
breakFormatString()? or maybe FormatIdenfierquarto-cli/src/config/types.ts
Lines 391 to 396 in 97ffff5
Once we decide, it is easy to implement. I would do this for 1.6.
cscheid commentedon Sep 5, 2024
I think we should send place exactly the contents of
FormatIdentifierin an env variable. The easiest thing to do is to JSON-encode it.cderv commentedon Sep 5, 2024
Oh I see. No specific formatting, just passing the object. I forgot about JSON as message format. interesting ! I can submit something with all this information. Cool !
cderv commentedon Jul 29, 2025
First step toward this is the base format:
cscheid commentedon Aug 20, 2025
Quarto 1.8 exports QUARTO_EXECUTE_INFO, an env var that points to a JSON file with ample execution information, including format (it's in fact the data in the
ExecuteOptionsobject mentioned above)mcanouil commentedon Aug 21, 2025
This works great!
Also, all the other information such as the
fig-andlanguageswill be very useful.Edit: here is what I had in mind with this (and it works!!!🤯)
cderv commentedon Aug 25, 2025
I believe this issue was about make something like
knitr::is_html_output()available to all engines, and closer to Quarto's format.Exposing all information in
QUARTO_EXECUTE_INFOis really cool because it offers a lot of information to users and developers of tools; however, this means two things to meQUARTO_EXECUTE_INFOcontent should be documented properly if we expect users to use it correctly. Just on format specifiers, some fields are Quarto-specific (e.g.,base-formatvs.target-format). Probably part of our more advanced doc.Both the quarto R package and the quarto Python module should have helpers functions so users can access relevant information without knowing which fields to retrieve. This is especially useful to really provide an
is_html_output()equivalent, or a more genericquarto_to(). quarto-dev/quarto-r#285 tracks this idea.