quarto-dev / quarto-dev/quarto-cli

Format-resources behavior

Open
#12,898 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement extensions
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

So I am trying to to package my "solution" to Global TeX macros.

For this I wanted to use format-resources to provide the file _macros.qmd with the content

::: {.content-hidden}
```{r, echo=FALSE, results='asis'}
if (knitr::is_html_output()) {
	system("latexpand macros.tex -o _macros.tex")
	macros <- readLines('_macros.tex')
	system("rm _macros.tex")
	writeLines(macros)
}
```
:::

I ran into two issues:

  1. Quarto seems to process the template.qmd file first, if I use the header
     {{< include _macros.qmd >}}
    
    to include the _macros.qmd file from the extension, then this file is reported as missing
  2. After the template is rendered the _macros.qmd file is not deleted. Funnily, the include directive therefore works on second render.

My expectation was, that format-resources would be treated as follows:

copy the format-resources -> render -> delete the format-resources

This was clearly wrong. I think this should work like this, but if there is a reason this does not work like this, then this behavior should probably be documented.

Sidenote: I also dislike the fact that the rendering happens in the root directory to some degree, as the directory always blows up with all the tex auxillary files when rendering to pdf before being deleted again. If something fails the tex files stay around and litter the root directory. Could the rendering of the project not happen in the output directory? I.e. copy the source files to the output directory, render, delete source files

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two cases with template.qmd and the extension-provided _macros.qmd, using the format-resources entry described in the issue. Trace the render order and resource cleanup, then verify that resources are available before the template include and are removed afterward, or that the documented behavior matches the implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
latex, r
Domain
build-system, documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.