I don't think we have the information stored and available from within Quarto - Maybe we could make this available in Variables system (Quarto – Variables)
The idea is tracked in
There is a Lua workaround there.
For current workaround, I am thinking of two thinks R specific
- knitr has
knitr::current_input()
function. This will return the filename of the input being knitted. You won't get the original filename because it gets processed by Quarto and an intermediate file is passed to knitr but it is just a matter for extension so this would give you the filename
This is written in test2.qmd
---
format: html
---
The input `.qmd` file for this output is `` `r xfun::with_ext(knitr::current_input(), "qmd")` ``
It returns this
- Using
quarto::quarto_render()
and leveraging parameters
test.qmd document
---
format: html
params:
input_file: ""
---
The input `.qmd` file for this output is `` `r params$input_file` ``
rendered using
input <- "test2.qmd"
quarto::quarto_render(input, execute_params = list(input_file = input))
You see the idea I believe on how using params can help you pass information from R to knitr.
Hope it helps