hilight
(Package: highr) :
Syntax highlight an R code fragment
This function parses the R code, fetches the tokens in it (getParseData), and attach syntax highlighting commands onto them. With proper style definitions for these commands (such as colors or font styles), the R code will be syntax highlighted in the LaTeX/HTML output. The two functions hi_latex and hi_html are wrappers of hilight for LaTeX and HTML output, respectively.