Code Syntax Highlighting using the 'Prism.js' Library

Code Syntax Highlighting made easy for code snippets or complete files. Whether you're documenting your data analysis or creating interactive 'shiny' apps.


highlighter

R-CMD-check CRAN status

highlighter is a package used for code syntax highlighting. This package is a wrapper for the Prism.js library implemented using htmlwidgets.

Installation

  • Using remotes
remotes::install_github("federiva/highlighter")
  • Using renv
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.

highlighter("some_variable <- 3")

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

highlight_file("<path_to_your_file>", language = "r")

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("highlighter")

0.1 by Federico Rivadeneira, 3 years ago


https://federiva.github.io/highlighter/


Browse source code at https://github.com/cran/highlighter


Authors: Federico Rivadeneira [aut, cre, cph]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports cli, glue, htmltools, htmlwidgets, rlang

Suggests knitr, lintr, rmarkdown, spelling


See at CRAN