Highlight and link a code block
This function:
syntax highlights code
links function calls to their documentation (where possible)
in comments, translates ANSI escapes in to HTML equivalents.
highlight(text, classes = classes_chroma(), pre_class = NULL, code = FALSE) classes_pandoc() classes_chroma()
text |
String of code to highlight and link. |
classes |
A mapping between token names and CSS class names.
Bundled |
pre_class |
Class(es) to give output |
code |
If |
If text
is valid R code, an HTML <pre>
tag. Otherwise,
NA
.
A string containing syntax highlighted HTML or NA
(if text
isn't parseable).
cat(highlight("1 + 1")) cat(highlight("base::t(1:3)")) # Unparseable R code returns NA cat(highlight("base::t("))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.