Code chunks within lists in quarto

I'm moved most of my document creation to quarto and liking it quite a lot. But I keep running into one thing I can't figure out.

I often include R chunks within lists. In R Markdown, I would do something like this:

0. Set up your SSH key (if you have not already done that).

    You can find instructions at GitHub, but there is also an R package that
will assist you:

```{r indent = "    ", eval = FALSE}
library(credentials)
ssh_key_info()
```

    If you don't have a key set up, you will be prompted to create one.
    Say "Yes".

In Quarto when I do this I end up seeing :::{cell} in the rendered document. Is this a bug? Is there a different way I should be doing this?

Just to be sure this is not specific but in this case where eval = FALSE, you can just use non R chunk

0. Set up your SSH key (if you have not already done that).

    You can find instructions at GitHub, but there is also an R package that
will assist you:

    ```r
    library(credentials)
    ssh_key_info()
    ```

    If you don't have a key set up, you will be prompted to create one.
    Say "Yes".

However, this seems like something like this should work

0. Set up your SSH key (if you have not already done that).

    You can find instructions at GitHub, but there is also an R package that
will assist you:

    ```{r, eval = FALSE}
    library(credentials)
    ssh_key_info()
    ```

    If you don't have a key set up, you will be prompted to create one.
    Say "Yes".

But it is not. I don't think that Quarto supports this unfortunately for now.

Sorry about that - it was in fact an indentation issue

---
format: html
keep-md: true
---

1.  Set up your SSH key (if you have not already done that).\

    You can find instructions at GitHub, but there is also an R package that will assist you:

    ```{r, eval = FALSE}
    library(credentials)
    ssh_key_info()
    ```

    If you don't have a key set up, you will be prompted to create one. Say "Yes".

1.  Another item

If you indent correctly it works

Thanks @cderv. I see a at least two changes:

  1. an additional space after the item number.

  2. actually indenting the R chunk rather than using indent = .

I'll have to do some experimenting to see which of these matters. But I did get it to work.

Interestingly, the original version worked in RMarkdown (I'm converting from bookdown to quarto and cleaning up things that aren't quite right after the switch), so there must be some differences between how knitr and Quarto are processing this.

This was to align the first line with the following. Important is that they are starting at the same alignment. You can do without the aditionnal space by reducing one all the following line

0. Set up your SSH key (if you have not already done that).

   You can find instructions at GitHub, but there is also an R package that
will assist you:

   ```{r, eval = FALSE}
   library(credentials)
   ssh_key_info()
   ```

   If you don't have a key set up, you will be prompted to create one.
   Say "Yes".

indent can be used too, it just feels cleaner to have the code chunk also indented in source but this works (by removing one space in the indent param to align as described before)

0. Set up your SSH key (if you have not already done that).

   You can find instructions at GitHub, but there is also an R package that
will assist you:

```{r indent = "   ", eval = FALSE}
library(credentials)
ssh_key_info()
```

   If you don't have a key set up, you will be prompted to create one.
   Say "Yes".

This is all about indentation and what is expected by Pandoc

Yes Quarto uses more Pandoc features (for example Lua filters and AST elements) like the ::: {.cell} you see in the output. If this is not indented exactly as expected it won't be parsed as it should and seen as text instead of AST Div node.

So correct indentation matters more in Quarto. You can use visual editor to help with catching wrong formatting, or help with formatting as expected.

This topic was automatically closed 21 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.