Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

Server-side syntax highlighting? #33

Open
zmitchell opened this issue Mar 10, 2017 · 1 comment · May be fixed by #46
Open

Server-side syntax highlighting? #33

zmitchell opened this issue Mar 10, 2017 · 1 comment · May be fixed by #46

Comments

@zmitchell
Copy link

I'd like to use Pygments for server-side highlighting, but I can't seem to get it working properly. I set pygmentsUseClasses = true and pygmentsStyle = "monokai", but the style doesn't seem to be applied.

Here's some example code and a screenshot of the result:

{{< highlight python >}}
class someClass(object):
    def __init__(self):
        self.x = 1
{{< /highlight >}}

syntax-highlighting-error

I've poked around the theme and see that you're using Highlight.js, but since I'm not a web programmer I don't really know what to change to get Pygments to do its thing. Is Highlight.js baked into the theme that it would be impractical for me to try getting Pygments to work, or is there an easy solution that I'm not aware of?

@digitalcraftsman
Copy link
Owner

digitalcraftsman commented Sep 21, 2017

Hello @zmitchell,

it's correct that Highlight.js is backed into the theme. Pygments should work out of the box but I guess that the styling of Pygments in Highlight.js interfere with each other which causes the unintended way syntax highlighting in the code above.

This department of Hugo got some traction in the last days. Chroma is a port of Pygments to Go which is not only faster but should work as a drop-in replacement due to the very similar design. There's already a pull request that will make it the default syntax highlighter.

As I expect that the use of Pygments / Chroma will increase, because no external dependencies are required anymore, it makes even more sense to make Highlight.js optional.

I see two ways to handle this:

  1. Introduce a new option to enable Highlight.js (default is false).
  2. Let users add the JS and CSS files for Highlight.js manually via the customJS and customCSS config options.

Note: both proposals introduce breaking changes that affect every user of this theme.

This was referenced Jan 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants