The classes described in the R Markdown Cookbook, e.g. applied by using
```{r class.source="bg-danger", class.output="bg-warning"}
mtcars[1:5, "mpg"]
```
are Bootstrap helper classes. Using bookdown, e.g. with bookdown::gitbook
, does not carry any Bootstrap style sheet and so applying these classes will not have an effect (This is maybe different with other book types like bs4_book
). I would also not include a Bootstrap style sheet in a GitBook because this can have several side effects (GitBook has its own styles).
However, as an alternative one could use custom CSS and your approach to define this for certain classes is already a good start. In order to make it work, it is necessary to define more specific selectors because otherwise your CSS gets overwritten (or you use !important
, but this is in general not the best approach). As an example,
```{r class.source = "python-output"}
mtcars[1:5, "mpg"]
```
could be supplied with a yellow background color by defining
.book .book-body .page-wrapper .page-inner section.normal pre.python-output {
background-color: yellow;
}
in style.css
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4