Syntax Highlighting on `revealjs` slides incrementally?
rleyvasal opened this issue · 4 comments
Is there a way to create syntax highlight on slides with rmarkdown
?
According to the revealjs website the following chunk code should highlight the syntax; however, it does not work in rmarkdown
<section data-markdown>
<textarea data-template>
```js [1-2|3|4]
let a = 1;
let b = 2;
let c = x => 1 + 2 + x;
c(3);
```
</textarea>
</section>
revealjs R package currently does not use the revealHighlight
plugin from the documentation of reveal.js you are referring too. Pandoc does not use it and it would be a new feature to add in the R package. There is an issue to track this #118
Currently, highlighting is based on Pandoc feature as with other formats (html_document()
, pdf_document()
, ...).
So you can just use fenced backticks with attributes as you would do in other documents with R Markdown.
```js
let a = 1;
let b = 2;
let c = x => 1 + 2 + x;
c(3);
```
Pandoc docs: https://pandoc.org/MANUAL.html#syntax-highlighting
It is also mentioned R Markdown Definitive guide for revealjs: https://bookdown.org/yihui/rmarkdown/appearance-and-style-1.html#appearance-and-style-1
Did you try that already ?
I already tried using the three backticks and it works as intended(highlights the code)
The behavior I am referring to is about highlighting lines of code one step at a time - similar to incremental option.
```js [1-2|3|4]
```
The above code highlights the first two lines of code and after that line 3 then line 4.
This is not yet available. This feature is part of revealHighlight
plugin which is currently not supported.
We are upgrading to reveal version 4 - this will probably help support more features in the futures.
I'll close this issue as it is a duplicate of #92 which specifically target this incremental highlight feature.
We'll track progress and interest there for this new feature request.
Thank you for your suggestion !