What syntax highlighter do you use for web projects

I am currently writing documentation. I have been using highlight.js but the result isn’t very satisfying particularly for EEx templates. I don’t think EEx is supported and choosing HTML instead is not much better.

What are people using for syntax highlighting that I can try out? I want something that is JavaScript based so I can simply drop it into a page.

I use highlight.js too, with EEx templates treated as ERB.

I’m getting odd highlighting of the embed tags, this was highlighted as erb.

The error in hightlighting seems to be caused by the presence of the script tag.

Adding this line to other EEx sample breaks the highlighting of the embed tags

<script type="text/javascript"></script>

I use highlight.js as well. I’ve seen but not used Prism JS so I’d be interested in knowing if this is any better.

Semi-related: Swift has a package called Splash which lets you convert Swift code into HTML which you can then use CSS to style with no JS required. I think this approach is very cool and would love to see something like this for multiple languages.

There’s GitHub - elixir-makeup/makeup: Syntax highlighter for Elixir inspired by Pygments for that in elixir. It’s what ex_doc is using for the last few versions.

4 Likes

Ah nice! I’ll check it out.

I used highlight.js for slickbit. It gets the job done! I tried a few others but once I got highlight.js configured how I wanted its been very easy to work with.

Not what you are looking for, but if anyone sees this thread and goes to it looking for server side highlighting, I’ve been using https://github.com/alecthomas/chroma as a successor to pygments. Chroma comes with Hugo and is how https://adoptingerlang.org/ highlighting is done, originally this was overriden to use Pygments while a bug in Chroma for Erlang was fixed but now it works well.

6 Likes