knitr::read_chunks and knitr::purl for other languages #9112
Replies: 2 comments 14 replies
-
I would like to have this feature, too. My use-case are What I ended up doing is to implement a conversion from Jupyter notebook to Matlab script in Matlab, called from a code cell with But such a conversion could be implemented in Quarto itself, activated e.g. via a YAML header format:
html: default
script: default and offered for download as an "other format". Somewhat related: #7411. |
Beta Was this translation helpful? Give feedback.
-
For reference: |
Beta Was this translation helpful? Give feedback.
-
Description
I'm a big fan of knitr's code externalisation: it lets me tinker with the code in a self-contained document, reuse it in other files (e.g.
source('funs.R')
) etc. while focusing more on the text/narrative in the Rmd/qmd file, but still benefit from the reproducibility of literate programming (namely: the code is the actual code, and all artefacts have resulted from it).Unfortunately, I believe this only exists for the knitr+R combination, not for other languages or engines?
As a workaround, I've resorted to a reverse strategy, where all the code is in a qmd file, and I use
knitr::purl
to extract it to a standalone source file.Note the R code at the end is not in a chunk, lest it be included in the julia script (and would cause errors). It's a bit awkward, I think it'd be nice if quarto had such an option to "dump" all code into a script at the user's request? (and ideally this script could be listed as "other formats" in a quarto webpage). (So I guess this is 3 feature requests into one)
Beta Was this translation helpful? Give feedback.
All reactions