hugo-coder icon indicating copy to clipboard operation
hugo-coder copied to clipboard

[v2] Better support for Custom Code Highlight

Open luizdepra opened this issue 6 years ago • 7 comments

Another tricky one. We need to find a way to support others code highlight settings (other b2/bw). Maybe v0.43 Hugo Piper can help us here.

About the style, maybe we should:

  • [ ] Play with borders
  • [ ] Show language name
  • [ ] Add copy to clipboard button

luizdepra avatar Jul 09 '18 22:07 luizdepra

I volunteer for this one, you can assign it to me.

khos2ow avatar Jul 10 '18 01:07 khos2ow

I think this one is already solved. Needs testing.

luizdepra avatar Sep 14 '18 12:09 luizdepra

@khos2ow, did you find any issues after the SCSS refactor? Can we close this one?

luizdepra avatar Sep 30 '18 22:09 luizdepra

I have an override of this on my own site, and try to send a PR sometime soon. The thing is this essentially will become a personal opinion of which one to choose and I don't think it makes sense to make this configurable (may be only a wiki on how to override it).

khos2ow avatar Oct 09 '18 16:10 khos2ow

Ok. Need to test ti again. But I think this problem is already solved.

luizdepra avatar Oct 09 '18 19:10 luizdepra

I think we s till need a styling refactor. I want something like code boxes from this site. Maybe we should test with a border, but I really want to show the language name.

luizdepra avatar Sep 28 '20 14:09 luizdepra

Hi @luizdepra, I've been testing some implementations. I still have issues with colors with dark mode and styles used, but here is an example:

image

To do this I overrided the default highlight shortcode and added an element to show the language. Hugo now uses Chroma so I removed the default Pygments configs but added this one pygmentsUseClasses=true because I need to generate the stylesheet for the styles in order to use these classes to style the language element. The only problem, we need to load the stylesheet file with the customCss config property to work by default.

One more problem, overriding the highlight shortcode don't work when using code fences :/

clement-pannetier avatar Oct 26 '20 15:10 clement-pannetier