Cannot get quarto pre-render to work.

I'm trying to get a small R script to be called before rendering in a quarto document, but nothing I do causes the script to be run.

Here's a sample

---
title: "test_pre_render"
format: pdf
editor: source
pre-render: test.R
---
<!-- For the pre-render script -->
<!-- create a file called test.R -->
<!-- and include the following line in it -->
<!-- writeLines(date(), 'test.qmd') -->
<!-- You will need to run this script once to create -->
<!-- the first version of test.qmd to avoid a file -->
<!-- not found error. -->

## Section

This is the date from the current run. (add an extra ` in 2 places below to make this run)
``{r}
#| echo: false
print(date())
``

The next date corresponds to when the test.R script last ran. It should be close to the date of the current run.
\newline
{{< include test.qmd >}}

To recreate this, you'll have to create a test.R file and run it manually once. See the instructions in the example.

Whatever I do, I cannot get the test.R file to be called during a pre-render and this can be seen because the contents of the test.qmd file never change.

I'm running the latest R Studio 2022.07.1 Build 554, R version 4.2.1, quarto version 1.0.36 all on Ubuntu 20.04.

After some research, I found a way by putting the commands in a file called _quarto.yml.

project:
  pre-render: test.R

pre-render is a feature for Quarto project

That is why you need to put this in a _quarto.yml file and not just the YAML header.

If you use VSCODE or RSTUDIO IDE, autocompletion of YAML should help you find the configuration available.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.