r-lib / profvis

Visualize R profiling data
https://profvis.r-lib.org/
Other
304 stars 38 forks source link

profvis() messes up syntax highlighting in Quarto and R Markdown code blocks #140

Closed prosoitos closed 1 month ago

prosoitos commented 1 year ago

See issue quarto-dev/quarto-cli#3991 for reproducible example and explanations.

wch commented 1 year ago

It looks like the colors are from textmate.css. Profvis includes a very old version of highlight.js which doesn't do any scoping -- all <span>s are affected by the CSS.

https://github.com/rstudio/profvis/blob/a4ac85ce2fd73f82a3e6deae3989863b2a32db4d/inst/htmlwidgets/lib/highlight/textmate.css

I think this can be fixed by adding .profvis-code to the CSS rules.

wch commented 1 year ago

After taking a closer look, I think highlight.js itself will also need to be upgraded for everything to work properly.

hadley commented 2 months ago

Actual link to underlying issue: https://github.com/quarto-dev/quarto-cli/issues/3991

Minimal reprex:

---
format: html
---

```{r}
f <- function() {
  pause(0.1)
}
profvis::profvis(f())