Code Syntax Highlighting using the Prism.js Library (original) (raw)
highlighter is a package used for code syntax highlighting. This package is a wrapper for the Prism.js library implemented using htmlwidgets.
Installation
- From CRAN
- Using remotes
- Using renv
# From CRAN
renv::install("highlighter")
# Development version from github
renv::install("federiva/highlighter")
Usage
See the vignettes for more examples.
Using highlighter
We can use the highglighter
function in order to render and highlight code. By default the function will highlight the syntax of R code.
If we want we can specify the language using the language
parameter.
highlighter("const someVariable = 3;", language = "js")
Using highlight_file
We can pass the path to a local file using the highlight_file
function