gadenbuie / xaringanExtra

:ferris_wheel: A playground of enhancements and extensions for xaringan slides.
https://pkg.garrickadenbuie.com/xaringanExtra
Other
448 stars 36 forks source link

Panelset reading code chunk content as markdown #71

Closed spcanelon closed 3 years ago

spcanelon commented 3 years ago

Hi again @gadenbuie 👋

I'm having some trouble using code chunks with panelset and haven't run into this issue before. For some reason anything that even resembles markdown gets turned into markdown inside panels. Any suggestions you have would be much appreciated 😃

These screenshots come from an RStudio Cloud project, and the code chunk content for both is:

---
class: title-slide, left, bottom

# `r rmarkdown::metadata$title`
----
## **`r rmarkdown::metadata$subtitle`**
### `r rmarkdown::metadata$author`
### `r rmarkdown::metadata$date`
---

image image

gadenbuie commented 3 years ago

Can you share the source code for the slides with the panelset?

spcanelon commented 3 years ago

Here are the files exported from the Cloud project:

rstudio-export-panelset.zip

gadenbuie commented 3 years ago

I think this is a problem with the markdown parser in remarkjs, since I get the same results without including panelset.

You can get the markdown parser to skip the code chunk processing by using <pre><code> in html rather than markdown:

.panelset[
.panel[.panel-name[Example]
<pre><code>---
class: title-slide, left, bottom

# `r '\x60r rmarkdown::metadata$title\x60'`
----
## **`r '\x60r rmarkdown::metadata$subtitle\x60'`**
### `r '\x60r rmarkdown::metadata$author\x60'`
### `r '\x60r rmarkdown::metadata$date\x60'`
---</code></pre>

]
]

I think you might be wanting to show the rmarkdown::metadata$title as verbatim inline code, i.e. including the backtick + r, so I used this trick from Yihui.

image

spcanelon commented 3 years ago

I wish I could "undo" that last comment with the embarrassing typo! 🤦‍♀️ I promise I actually do know your name.

Thanks for all of your help Garrick! It's much appreciated.

gadenbuie commented 3 years ago

You're welcome! And no worries 😄