quarto-dev / quarto-dev/quarto-cli
[knitr] custom engine setting asis output does not remove all divs
@cderv is already working on this.
Since Mar 25, 2024.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Here is a demo of using a custom engine in knitr which is meant to output raw content. (More details at https://github.com/quarto-dev/quarto-cli/discussions/9163).
So the engine sets output: asis internally (results: asis in knitr context)
---
title: "Test"
format:
typst:
keep-typ: true
keep-md: true
---
```{r, echo=FALSE}
knitr::knit_engines$set(demo = function(options) {
options[["results"]] <- "asis"
knitr::engine_output(
options,
options$code,
out = "Should be `asis` content."
)
})
```
## Quarto
Quarto enables you to weave together content and executable code into a finished document.
```{demo}
Do no matter
```
This is the intermediate .md
::: {.cell}
```{.demo .cell-code}
Do no matter
```
Should be `asis` content.
:::
The output wrapping is correctly removed (i.e ::: {.cell-output .cell-output-stdout} and fenced code block.
However ::: {.cell} is still there.
In code base, we decide to add the wrapping div on condition
https://github.com/quarto-dev/quarto-cli/blob/f43107222f70ca3579a520d496597b75b5bd0097/src/resources/rmd/hooks.R#L400-L415
But this is done in the chunk hook - and in fact knitr does not get the modified options from cell at this point. It could be an issue from knitr itself.
For now, it means that output: asis needs to explicitly be set on a cell that should not have the output div.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.