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

crayon/cli output in vignettes when comment="" #1965

Closed
jeroen opened this issue Dec 11, 2021 · 6 comments
Closed

crayon/cli output in vignettes when comment="" #1965

jeroen opened this issue Dec 11, 2021 · 6 comments
Labels
feature a feature request or enhancement front end 🌷 General HTML, CSS, and JS issues

Comments

@jeroen
Copy link
Member

jeroen commented Dec 11, 2021

Follow up on: #1858.
Vignettes that set a custom output prefix (instead of ##) for example the empty string:

knitr::opts_chunk$set(comment = "")

This has the unexpected side-effect that ansi codes do not get escaped anymore. A tibble will print a lot of escape sequences:

tibble::as_tibble(iris)
[38;5;246m# A tibble: 150 × 5
[39m
   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
          
[3m
[38;5;246m<dbl>
[39m
[23m       
[3m
[38;5;246m<dbl>
[39m
[23m        
[3m
[38;5;246m<dbl>
[39m
[23m       
[3m
[38;5;246m<dbl>
[39m
[23m 
[3m
[38;5;246m<fct>
[39m
[23m  

[38;5;250m 1
[39m          5.1         3.5          1.4         0.2 setosa 

[38;5;250m 2
[39m          4.9         3            1.4         0.2 setosa 

[38;5;250m 3
[39m          4.7         3.2          1.3         0.2 setosa 

[38;5;250m 4
[39m          4.6         3.1          1.5         0.2 setosa 

[38;5;250m 5
[39m          5           3.6          1.4         0.2 setosa 

[38;5;250m 6
[39m          5.4         3.9          1.7         0.4 setosa 

[38;5;250m 7
[39m          4.6         3.4          1.4         0.3 setosa 

[38;5;250m 8
[39m          5           3.4          1.5         0.2 setosa 

[38;5;250m 9
[39m          4.4         2.9          1.4         0.2 setosa 

[38;5;250m10
[39m          4.9         3.1          1.5         0.1 setosa 

[38;5;246m# … with 140 more rows
[39m
@maelle
Copy link
Collaborator

maelle commented Dec 13, 2021

downlit only escapes comments so any custom output prefix that doesn't start with # will get this.

Wasn't there some discussion of whether rmarkdown itself could run downlit via a hook? 🤔

@maelle
Copy link
Collaborator

maelle commented Dec 13, 2021

For reference rstudio/rmarkdown#1881

@hadley hadley changed the title Setting custom comment leadsa Setting custom comments Dec 13, 2021
@hadley
Copy link
Member

hadley commented Dec 13, 2021

Yeah, we had to use a regexp for this, so you'll need to deliberately suppress crayon in your vignette.

@maelle
Copy link
Collaborator

maelle commented Dec 13, 2021

But if rmarkdown supported downlit, could the regexp become useless? I.e. the highlighting & escaping would be done as a knitr output hook or so?

@hadley
Copy link
Member

hadley commented Dec 13, 2021

@maelle right, but I think we're some distance from that.

@hadley hadley added feature a feature request or enhancement front end 🌷 General HTML, CSS, and JS issues labels Jan 6, 2022
@maelle maelle changed the title Setting custom comments crayon/cli output in vignettes when comment="" Nov 25, 2022
@hadley
Copy link
Member

hadley commented Apr 17, 2024

I'm closing this since supporting arbitrary comment prefixes is still a long way away, still a lot of work, and still not requested by that many people.

@hadley hadley closed this as completed Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement front end 🌷 General HTML, CSS, and JS issues
Projects
None yet
Development

No branches or pull requests

3 participants