Created
November 7, 2021 16:04
-
-
Save chasemc/60cd93de61ea2f7f2ae6c77cfde0f92a to your computer and use it in GitHub Desktop.
Display code language in Rmarkdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Display code language in Rmarkdown" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(eval = TRUE, include = TRUE, python.reticulate=FALSE) | |
``` | |
```{r results="asis", echo=FALSE} | |
css <- paste0(".", | |
tolower(names(knitr::knit_engines$get())), | |
"::before { | |
content: '", | |
tolower(names(knitr::knit_engines$get())), | |
"'; | |
display: block; | |
text-align: right; | |
}", | |
collapse="\n") | |
cat(paste0("<style>", css, "</style>")) | |
``` | |
```{r echo=T} | |
print("Hello, I'm R code") | |
``` | |
```{python, engine.path = '/usr/bin/python', echo=T} | |
print("Hello, I'm Python code") | |
``` | |
```{bash, echo=TRUE, include=TRUE} | |
echo "Hello, I'm Bash code" | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment