specify language based on engine
authorFrançois Michonneau <francois.michonneau@gmail.com>
Fri, 21 Jun 2019 13:57:37 +0000 (15:57 +0200)
committerFrançois Michonneau <francois.michonneau@gmail.com>
Fri, 21 Jun 2019 14:00:37 +0000 (16:00 +0200)
- fix swcarpentry/r-novice-inflammation#436

bin/chunk-options.R

index 6bd4aefaeb72ba14d2765e8dfffc8fa5592d91c9..b0559cbe8330cf8ec77ead8083f6584faed0f541 100644 (file)
@@ -37,9 +37,12 @@ opts_chunk$set(tidy = FALSE, results = "markup", comment = NA,
 # are properly formatted when the site is built.
 
 hook_in <- function(x, options) {
+  lg <- tolower(options$engine)
+  style <- paste0(".language-", lg)
+
   stringr::str_c("\n\n~~~\n",
-                 paste0(x, collapse="\n"),
-                 "\n~~~\n{: .language-r}\n\n")
+    paste0(x, collapse="\n"),
+    "\n~~~\n{: ", style, "}\n\n")
 }
 
 hook_out <- function(x, options) {