quarto-dev / quarto-dev/quarto-cli

[knitr] custom engine setting asis output does not remove all divs

Open
#9,184 1 comment 0 reactions 1 assignee View on GitHub

@cderv is already working on this.

Since Mar 25, 2024.

bug engines-knitr
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

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.