Hello everyone, I made some improvements to the Julia syntax highlighter in highlight.js. This library is used by Documenter.jl, Franklin.jl, this discourse forum and many other tools to highlight Julia code, so hopefully it will be useful. I wrote a post about it for anyone interested:
Great work! I would love to see these changes one day added to Chroma, which is used by Hugo. Its Julia highlighting is really underwhelming compared to this.
Thanks, I knew I read about some forum switching, but couldn’t find which one when trying to find it. I did include StackOverflow in the post, just didn’t know it was so recent.
It would be great to get this on stackoverflow, since right now the syntax highlighting isn’t just bad – it’s worse than nothing. It’s probably using a highlighter from a completely different language, Matlab perhaps.
It is an improvement; highlight.js it is used by many tools for julia code already, just doesn’t tag as much. I don’t know why it isn’t on that list though, probably just an oversight.
If I understand correctly it has to be on that list to be deployed by stackoverflow
If your post doesn’t have the correct highlighting, it’s possible it’s not supported. Please look at the list of supported languages. If your language is not on the list, it needs to be created within the highlight.js project before it can be deployed by Stack Exchange.
Yeah, the last I heard Stack Overflow was just using the default, language agnostic highlighter for Julia code. There were some posts on Meta about it.
EDIT: Of course that was before they switched to highlight.js.
The Julia REPL highlighting is particularly bad right now on Stack Overflow.
In the C example, the function arguments are colored differently than the types, is it possible to also get that in Julia (with your improvements arguments and types have the same color)?
That is because the C highlighter mark int and char as keyword. If you look at the Julia example you see that the argument is tagged with params and the argument types as type. The fact that they look the same in my improved example is just that the specific color scheme assigns the same color to params and type.
How can one add this to a Franklin.jl site now? Is it more realistic to just wait until highlight.js tags a new version or should I add this manually to the page (I saw that the default version pulls it in via node)
It is very easy; replace the file _libs/highlight/highlight.js with the one I provided and either make sure you use optimize(...; prerender=false) such that this new version is used when you deploy too, or you tell Franklin to prerender with the new file by setting Franklin.HIGHLIGHTJS[] = "/path/to/new/highlight.js".