You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was playing around some more and I noticed that if you use pandoc-style code fences but mark them as R code, then they do not get the same syntax hightlighting as R Markdown R code chunks. I suppose this makes sense since downlit is only used on an R Markdown code chunk that has the "R" engine (if (downlit && options$engine == "R")), and any code contained in code fences are handed off to pandoc for syntax highlighting.
Seems like this could be a bit tricky to handle, perhaps using a regex, but not impossible. Perhaps the recommendation should just be to use proper R Markdown chunks and set eval = FALSE to get consistent highlighting for documents using downlit (@hadley thoughts?).
Just thought I would share this observation, feel free to close the issue if you think it's not worth acting on. This issue can at least serve as a reminder of why this may crop up in some cases.
In the example below, chunk 1 has default pandoc highlighting, while chunk 2 and 3 are formatted the same using downlit.
---
title: "My Website"
description: |
Welcome to the website. I hope you enjoy it!
site: distill::distill_website
---
```r
1 + 2
```
```{r eval=FALSE}
1 + 2
```
```{r}
1 + 2
```
The text was updated successfully, but these errors were encountered:
This could maybe change in the future when support in rmarkdown is done not by a knitr hook in a way it could be used by other formats based on the html_document format. Related to rstudio/rmarkdown#1941
Still working on it as some challenges still needs to be dealt with
Hi,
I was playing around some more and I noticed that if you use pandoc-style code fences but mark them as
R
code, then they do not get the same syntax hightlighting as R MarkdownR
code chunks. I suppose this makes sense sincedownlit
is only used on an R Markdown code chunk that has the"R"
engine (if (downlit && options$engine == "R")
), and any code contained in code fences are handed off to pandoc for syntax highlighting.Seems like this could be a bit tricky to handle, perhaps using a regex, but not impossible. Perhaps the recommendation should just be to use proper R Markdown chunks and set
eval = FALSE
to get consistent highlighting for documents usingdownlit
(@hadley thoughts?).Just thought I would share this observation, feel free to close the issue if you think it's not worth acting on. This issue can at least serve as a reminder of why this may crop up in some cases.
In the example below, chunk 1 has default pandoc highlighting, while chunk 2 and 3 are formatted the same using
downlit
.The text was updated successfully, but these errors were encountered: