blogdown icon indicating copy to clipboard operation
blogdown copied to clipboard

Support downlit for syntax highlighting

Open petrbouchal opened this issue 5 years ago • 3 comments

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:

  • [x] searched for an existing feature request to avoid creating duplicate requests? If you find an existing feature request, please give it a thumbs-up reaction, as we'll use these reactions to help prioritize the implementation of these features in the future.

  • [x] provided a clear and concise description of the problem this proposed feature would address? For example, I struggle to do [...] with blogdown.

  • [x] provided a clear and concise description of what you want to happen?

  • [ ] provided a clear and concise description of alternative solutions or workarounds you've considered?

  • [x] added any other context or screenshots about your feature request?

petrbouchal avatar Dec 16 '20 18:12 petrbouchal

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).

yihui avatar Dec 18 '20 15:12 yihui

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.

cderv avatar Dec 18 '20 15:12 cderv

+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?

wjakethompson avatar Oct 14 '21 14:10 wjakethompson