-
-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Details breaks code formatting #333
Comments
I guess you can't mix Markdown code into raw HTML tags. You have to use pure Markdown syntax like the examples in #219. |
I think this is indeed not supported by remark.js (gnab/remark#531) and we have encounter this already I think (but I can't find the related issue). You would need to either produce pure markdown as mentioned. You may need to adapt the JS code to make it work in your case though. You could also produce HTML code directly but that maybe trickier because I am not sure what the html code could exactly be: ---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
institute: "RStudio, PBC"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
xaringan::moon_reader:
nature:
highlightStyle: github
highlightLines: true
---
```{r, include = FALSE}
library(htmltools)
```
```{r, echo = FALSE}
tags$details(
tags$summary("Details"),
"Code in details:",
tags$pre(tags$code(
'if (!requireNamespace("package", quiet = TRUE)) {
stop("We need this package")
}
package::function()',
class = "r"
)))
``` I would have advice the details R package to help (https://github.com/yonicd/details) but it will produce some fenced div code block. The JS solution could be the better IMO. Just need a bit of adaptation It is a fun JS exercice ! and not too hard if you start from #219 solution. One solution if you don't want to try...---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
institute: "RStudio, PBC"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
xaringan::moon_reader:
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
```{js, echo = FALSE}
(function() {
var details = document.querySelectorAll(".details");
details.forEach(function (e) {
e.outerHTML = "<details><summary>Details</summary>" +
e.innerHTML + "</details>";
})
})();
```
.details[
Code in details:
```r
if (!requireNamespace("package", quiet = TRUE)) {
stop("We need this package")
}
package::function()
```
] |
I thought that |
Yes, |
To add a little more background: the underlying issue here is that remarkjs sets the markedjs option
which is, incidentally, at odds with remarkjs setting Regardless, the short version of this story is that the
And since the details element is a block-level tag, the markdown content within it is not processed. |
Many thanks for maintaining and developing this package! It has been very useful for my presentations and workshops.
I would like to use details for my slides to show code people could run but not evaluate it. When I use it the code block inside slides it breaks the code formatting and seems to be formatted as latex.
I'm not sure why this happens (sorry don't know how to check and debug this) and #219 doesn't work on this as I don't evaluate the code and the code block is displayed directly.
Example of the output:
I'm tied to R 3.6.3 for the project so I haven't tested it on newer versions of R.
By filing an issue to this repo, I promise that
xfun::session_info('xaringan')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/xaringan')
.I understand that my issue may be closed if I don't fulfill my promises.
The text was updated successfully, but these errors were encountered: