Skip to content

Instantly share code, notes, and snippets.

@chasemc
Created November 7, 2021 16:04
Show Gist options
  • Save chasemc/60cd93de61ea2f7f2ae6c77cfde0f92a to your computer and use it in GitHub Desktop.
Save chasemc/60cd93de61ea2f7f2ae6c77cfde0f92a to your computer and use it in GitHub Desktop.
Display code language in Rmarkdown
---
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