Can we use PrismJS instead of highlight.js for code syntax?

I want to know if there is a way that we can replace the highlight.js to use PrismJS instead. PrismJS seems a bit more complete now than highlight.js, that is the reason of the request.

Is there a way we can do it directly in Discourse hosted version? Or there is any plugin to support it?

Thank you!

2 Likes

Can you expand a bit, what edge cases are you coming across?

@sam thanks for checking my message.

Let me show you one example using Kotlin.

  • highlight.js
    image

  • PrismJS
    image

As you can see the PrismJS looks better on this case.

I think the best thing to do here would be for someone to build a theme component that wires prism js in. It is technically feasible and would allow communities to experiment.

I am sure there are areas where prism outperforms highlight and the opposite.

5 Likes

I took a quick look at this today, and due to the fact that PrismJS doesn’t have automatic detection of the language code it would be a downgrade of a replacement for most communities.

4 Likes