r-lib / prettycode

Syntax highlight R code in the terminal
https://r-lib.github.io/prettycode/
Other
101 stars 9 forks source link

how to use this package to highlight on web? #13

Closed mrchypark closed 4 years ago

mrchypark commented 4 years ago

highlight.js for R is not good.

do you have any plan to this package for web?

thank you in advance.

gaborcsardi commented 4 years ago

It goes like this:

ansi <- prettycode::ahighlight(format(prettycode::highlight))
html <- fansi::sgr_to_html(ansi)
writeLines(c("<pre>", html, "</pre>"), tmp <- tempfile(fileext = ".html"))
browseURL(tmp)