Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting messed up by profvis::profvis() #3991

Closed
3 of 4 tasks
prosoitos opened this issue Jan 17, 2023 · 7 comments
Closed
3 of 4 tasks

Syntax highlighting messed up by profvis::profvis() #3991

prosoitos opened this issue Jan 17, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@prosoitos
Copy link

prosoitos commented Jan 17, 2023

Bug description

The function profvis::profvis(), somehow, messes up the syntax highlighting of R code blocks.

Example

File:

---
format: html
---

```{r}
library(profvis)

f <- function() {
  pause(0.1)
}

# profvis(f())
```

Normal syntax highlighting:

2023-01-16_22-30_1

With profvis::profvis():

---
format: html
---

```{r}
library(profvis)

f <- function() {
  pause(0.1)
}

profvis(f())
```

Syntax highlighting totally messed up:

2023-01-16_22-30_2

Context

Same behaviour with any highlight style, with format: revealjs and format: html, within a website or outside.

Note: this might be something weird that the function is doing and may not be a Quarto bug per se.

OS

Arch Linux (6.1.6-arch1-1)

Checklist

  • Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.
@prosoitos prosoitos added the bug Something isn't working label Jan 17, 2023
@prosoitos
Copy link
Author

Note that it might not seem like a big deal with the default theme as the messed up version is readable. But in my website, I use the monokai highlight theme and instead of the normal great looking code blocks I get:

2023-01-16_22-50

@prosoitos
Copy link
Author

Also: as the function, somehow, seems to interfere with the CSS section that has to do with syntax highlighting in <head> of the rendered html file, it is of course all the R code blocks that are messed up. Not just the one with the function.

Of note, I have some Bash blocks on the same file and those are not affected. If I add some {.python} or {.julia} blocks, those are also not affected. So only the CSS part of the R blocks gets messed up.

@prosoitos
Copy link
Author

For comparison, if I don't run the profvis() line (here I am putting it in a {.r} block), the normal highlighting looks like this:

2023-01-16_22-59

@cderv
Copy link
Collaborator

cderv commented Jan 17, 2023

@prosoitos if you look at the HTML code with and without profvis() activated, you'll see that the <head> in HTML will contain some specific content introduced by profvis dependencies.

profvis::profvis() returns an HTMLWIDGETS which brings some JS dependencies, among which highlight.js

Quarto is using Pandoc syntax highlighting with HTML, and use some CSS theme accordingly. Using profvis will bring highlight.js, run it and bring a theme texmate.css. This will mess up the Quarto syntax highligting procesing, and overwrite the theme.

I am surprised that profvis actions are not scoped and applies also on other code blocks (looking at the HTML on the code blocks, it seems they get process by highlight.js functions too).

So I would say this is an issue with profvis directly.

For comparison, if I don't run the profvis() line (here I am putting it in a {.r} block), the normal highlighting looks like this:

By not running profvis(), highlight.js is not added with the CSS theme and so Quarto syntax highlighting applies.

BTW this is the same with R Markdown as with Quarto - Same behavior when you tell R Markdown to highlight using Pandoc but it gets messed up by Profvis

Example Rmd
---
title: "R Notebook"
output:
  html_document: 
    highlight: arrow
---

```{r}
library(profvis)

f <- function() {
  pause(0.1)
}

profvis(f())
```

@prosoitos
Copy link
Author

Right. Thank you.

Should I then open an issue in the profvis project? Since the package is also developed by Posit, maybe it is fine to keep it here??

@cderv
Copy link
Collaborator

cderv commented Jan 17, 2023

Should I then open an issue in the profvis project? Since the package is also developed by Posit, maybe it is fine to keep it here??

It is not develop by the same team, and the maintainer of profvis does not track in Quarto. I can't migrate the issue between Quarto org and RStudio org. So if possible, it is best to open an issue in Profvis as it affect also R Markdown.

Thank you !

@prosoitos
Copy link
Author

OK, will do and I guess I should close this issue here.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants