Skip to content

Instantly share code, notes, and snippets.

@gadenbuie
Last active February 26, 2020 19:00
Show Gist options
  • Save gadenbuie/a88cc315130d2ef564dc229576084cdf to your computer and use it in GitHub Desktop.
Save gadenbuie/a88cc315130d2ef564dc229576084cdf to your computer and use it in GitHub Desktop.
styled code output in xaringan slides
---
output:
xaringan::moon_reader:
lib_dir: libs
chakra: "https://cdnjs.cloudflare.com/ajax/libs/remark/0.14.0/remark.min.js"
seal: false
nature:
slideNumberFormat: ""
highlightStyle: github
ratio: "16:9"
---
.bg-danger[
```{r, error=TRUE}
stop("Danger, Will Robinson")
```
]
```{css echo=FALSE}
.bg-danger pre + pre {
color: red;
background-color: #FEE;
padding: 1em;
border-radius: 5px;
}
```
@gadenbuie
Copy link
Author

image

@mattwarkentin
Copy link

Ah okay, thats what I thought you meant. Seems like the downside of this is how manual it is, and also you would need to know ahead of time what code will produce an output, message, warning, or error. And I guess you can only apply one CSS style to any of the above outputs produced by a single piece of code (versus different styles per type of output), right?

@gadenbuie
Copy link
Author

Unfortunately there's not really any way around this other than re-writing the kntir r chunk engine specifically for xaringan (not a recommended solution).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment