Is it possible to add custom syntax highlighting to our Discourse instance? In the julia zulip chat (please come check it out! https://julialang.zulipchat.com/), we have an additional highlighting option called julia-repl which is designed for displaying code copy-pasted from the REPL to help visually distinguish between inputs and outputs:
Yeah, it looks like it’s working well. I think it’s the themeing that could probably be improved — for example, julia> is tagged as a “prompt_” class but it’s not getting any special formatting.
I just found the documentation using this tag, but to no effect:
Neither Github, nor our documentation highlights anything.
And highlight.js does seem to alias julia-repl to julia, instead of considering it as its own syntax.
Nobody has implemented syntax highlighting for the Pkg REPL mode, so this is not surprising.
It is implemented by nesting regular Julia syntax within the julia> prompt. Other than that, Julia syntax in the REPL is no different from Julia syntax in files or wherever else, so I am not sure what you are missing here.
I just realized there was a theme switcher on the bottom-left corner, and there are a lot of light colored themes. I had only ever seen the dark theme here until today. I picked a new darker green that looks OK to me in both dark and light themes. (I picked green, because the Julia REPL gives me a green julia> prompt by default.)
But why did someone then use the tag julia-repl? I anticipation for an implementation?
Äähm. No matter how small the difference, there is one. And aliasing one to the other, gives no other result. So, calling julia-repl will always call the normal highlighting, as is.
And how does this make any sense? Using a mode, that’s not working? I assume it worked at some point, or the committer thought, it might get supported at some point.
Among other things, it breaks on the prompt.
If I change the highlighting to julia this is the result:
And I don’t know if that is on purpose:
But that is not the point. GitHub, the Documentation, and probably other sources are not applying julia-repl, so this is an issue. It seems to work on Discourse.
And aliasing two different modes is just wrong. It defeats the entire point of having distinct modes in the first place.
Feel free to contribute by removing the language tags.
What do you mean? As demonstrated above it doesn’t break on the prompt, on the contrary, the prompt is detected and classified as a prompt.
GitHub uses a different highlighter, and the documents are not written for GitHub.
Again, they are not just aliased. julia-repl does prompt detection for julia> and then the inner content is highlighted with the regular julia highlighter, as it should. Do you have an example where this doesn’t work?
I would rather care, that julia-repl works. And I was not sure, where this is implemented, so that I could link to it in an issue that I would raise. So I thought I ask here, first.