quarto-dev / quarto-r

R interface to quarto-cli
https://quarto-dev.github.io/quarto-r/
145 stars 24 forks source link

Using `quarto_render(evaluate = FALSE)` in a document on that document (bootstrapping) returns error #147

Open stefanocoretta opened 9 months ago

stefanocoretta commented 9 months ago

Hello! I have been trying to bootstrap a Quarto document using quarto_render() but the render process stops after the md file is created.

For example, a document called test.qmd

---
format: html
---

```{r}
library(quarto)
quarto_render("test.qmd", evaluate=FALSE)

Gives this error:

processing file: test.qmd

output file: test.knit.md

Error in readLines(con, warn = FALSE) : cannot open the connection Calls: .main ... partition_yaml_front_matter -> grep -> is.factor -> read_utf8 -> readLines In addition: Warning message: In readLines(con, warn = FALSE) : cannot open file 'test.qmd': No such file or directory Execution halted



If I render the generated `test.qmd.md`, that renders fine.
cderv commented 9 months ago

First, evaluate is not an argument of the quarto_render() function (https://quarto-dev.github.io/quarto-r/reference/quarto_render.html), so I am surprised you don't get an error on this.

Then, regarding bootstrapping, that is not something that is ideal.

Calling quarto render twice on the same file will have side effects and I am surprise this would work. There could be file access problem, or naming problem.

What is the real usecase exactly that drive you to try that ?

stefanocoretta commented 9 months ago

Sorry I meant execute not evaluate. :)

The use case is the application of this lua filter: https://github.com/stefanocoretta/lmt

It tangles code from a quarto document and outputs the scripts. Bootstrapping would allow one to write a single quarto document with the code to be tangled and code that runs those tangled scripts.

I can provide you with an example repo if it helps. :)

cderv commented 9 months ago

Example repo would be nice, but calling nested quarto render call doesn't seem something quite good 🤔

Quarto does a lot of things apart for executing code. Setting execute = FALSE won't help with prevent name conflict and intermediary content problem.

Is this necessary for the workflow? Can it be called in a two step process ? a post-render step maybe ?

I really don't think nesting calls to quarto render will be safe.

stefanocoretta commented 9 months ago

I am open to go a different way, but not sure how because I couldn't seem to find a way of converting Quarto markdown to pandoc markdown (then run the filter) then run quarto.

I will set up a repo and add the link here. Thanks for the help!

cderv commented 9 months ago

I couldn't seem to find a way of converting Quarto markdown to pandoc markdown (then run the filter) then run quarto.

Not sure to follow why you need the conversion here... You can open an issue in your repo maybe (or several) and ping me there, I'll be happy to try help