Requesting visual editor support for <details> blocks

While teaching (e.g., creating assignments), I like to include <details> blocks in my RMarkdown documents. This creates the hidden/collapsible chunks for things like hints and answer keys. This works well in the source editor, but when I try to move between the code editor and the new visual editor, it keeps breaking my lines up. Example:

In source editor, I type:

<p><details><summary>Hint</summary>Here is a hint</details></p>

Then I go to the visual editor view and then back again to the source editor and it shows:

<p>

<details>

<summary>

Hint

</summary>

Here is a hint

</details>

</p>

As a result of these extra linebreaks, the display in my knit document is wrong:
image
Instead of what it should be:
image

1 Like

With visual editor you need to include a raw HTML block when you want to use directly HTML in your document. With visual editor, it is in the command palette or menu

This is documented here: Visual R Markdown

If you use source editor you need to know the syntax.

```{=html}
<p><details><summary>Hint</summary>Here is a hint</details></p>
```
2 Likes

If I want the hint to include an R chunk, is it possible to embed that within the HTML chunk?

For example, this works in the source editor and is a great feature:

<p><details><summary>Hint</summary>
```{r}
pi * 180
```
</details></p>

You need to mark each inline char or block as Raw. Examples:


```{=html}
<p><details><summary>Hint</summary>
```
```{r}
pi * 180
```

```{=html}
</details></p>
```

You could be interested in this package also:

Hope it helps

2 Likes

That package looks perfect, thank you!

1 Like

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.