How to get gray background in R Markdown for plain text code fences?

1.3k Views Asked by At

In xaringan all code fences for various programming languages display a gray background when I use the default YAML. The code fence background is gray, just like this:

---
title: "Presentation Ninja"
output:
  xaringan::moon_reader:
    lib_dir: libs
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
---

There is an exception however when I insert plain text code fences:

```
Hi. I am plain text.
```

That code fence above renders as black text on a white background in my knitr xaringan output HTML slides. It does render as a code fence in font style, it just doesn't have the gray background. If I specify a syntax highlighting language (eg ```r) it regains the gray background, but brings in R highlighting I don't want (eg bold words, colored numbers, etc).

In R Markdown do I need to specify some type of plain text syntax highlighting, to keep code fence style formatting with gray background? I've tried text, hljs, rtf, and none of those achieve the desired effect (plain text, black color font, gray background, no other highlighting).

1

There are 1 best solutions below

0
On BEST ANSWER

Maybe this?

---
title: "Presentation Ninja"
output:
  xaringan::moon_reader:
    lib_dir: libs
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
---

```
Hi. I am plain text.
```

````markdown
Hi. I am plain text with gray background.
````

enter image description here