rstudio / blogdown

Create Blogs and Websites with R Markdown
https://pkgs.rstudio.com/blogdown/
1.73k stars 334 forks source link

Support downlit for syntax highlighting #535

Open petrbouchal opened 3 years ago

petrbouchal commented 3 years ago

With the recent developments in blogdown, one area where a difference remains between {hugodown} and {distill} on one side and {blogdown} on the other is syntax highlighting.

The approach taken by {distill} and {hugodown} via {downlit} seems to me quite effective - in terms of ease of setup as well as output (esp. linking and better sensitivity to R-specific syntax). A useful way of implementing presumably would be to allow opting in or out (depending on what a safe default is) to accommodate those using other syntax highlighting tools.

I haven't seen this discussed anywhere with respect to {blogdown}, so: would a {downlit} integration in {blogdown} be feasible and is it perhaps being considered? (I noticed syntax highlighting mentioned briefly under the v0.21 wishlist but no followup there.)

Checklist

When filing a feature request, please check the boxes below to confirm that you have provided us with the information we need. Have you:

yihui commented 3 years ago

This might become possible after the upstream support rstudio/rmarkdown#1941 (I haven't looked at the PR yet, so I'm not totally sure).

cderv commented 3 years ago

I'll take it into account.

blogdown support would require more work because of the different formats .Rmd and .Rmarkdown but I see how we could do. Not sure the rmarkdown PR alone would be enough but I'll check it.

wjakethompson commented 2 years ago

+1 for downlit support in blogdown. This would be especially helpful when writing about packages that have custom print methods. For example, see here, where color palettes have a special print method that display the color with the hex code. But when used in blogdown, the custom printing breaks (see here).

Maybe r-lib/pkgdown#1556 is helpful, which solved this issue in pkgdown?