Syntax highlighting for Markdown code blocks works for every language except R

I am composing blog articles in plain Markdown (i.e. .md files, but the same applies for R Markdown or .Rmd) and have noticed that the RStudio editor will add syntax highlighting for every kind of code block except R.

That is, a fenced block with ```scala (for example) at the start will have syntax highlighting in the editor. But a chunk with ```r will have no highlighting at all, as if I did not add a language prefix at all and was just writing a plain fenced code block.

I have looked all through the documentation and can't find any explanation for this. If any language was meant to be supported, I would expect it to be R.

The behaviour is the same whether I am writing an .Rmd or a .md but it only applies to non-evaluated fenced blocks (the ones without the curly brackets, i.e. not functionally evaluated chunks like ```{r}, ```{python}).

Screenshot in case my explanation was unclear:

try placing the r within curly brackets like

```{r}

Tried that. In an .md file it makes no difference. In an .Rmd file it upgrades the block to a functional chunk, which I don't want (I know I can set eval = FALSE but that's a workaround, not a solution).

[P.S. I am using RStudio 1.4.1010 but I'm not aware of this having ever worked.]

I can reproduce this. This is related to RStudio IDE and not any R package.

I would look into

to see if there is already mention of that, and if not I would suggest to open an issue.

Thanks. I searched for an equivalent issue but couldn't find one, so have filed a new one here: https://github.com/rstudio/rstudio/issues/8680

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.