The if, else, etc. are bolded, once in a while some words are in blue or red.
I find it really hard sometimes to parse quickly what am I looking at.
Discourse is said to have highltight.js support and on its website there is a variety of options.
Is there a setting somewhere that I missed?
Or is this just how code looks on Julia Discourse?
That’s what I’m seeing too… It’s never struck me as particularly bland, in particular since there are other highlights that show up in the other code blocks on the linked page: greenish-blue for numbers, red for strings, gray for comments. Looks fine to me. That being said, I’m not sure that I understand what exactly gets highlighted in blue (like Symbol)… that seems buggy to me (TheStruct should be highlighted the same way).
The specific colors depend on the theme you set in your preferences on Discourse. There could be a few more things that are highlighted (like operators), but there’s just not that much going on in that code snippet. This is how it looks in my text editor:
It’s just highlightjs’s way of rendering Julia code as far as I understand.
StackOverflow is a wholly different matter and will randomly use highlighting for an unrelated language. (Edit: shameless plug to create a meta account and vote for Julia’s support here)
@mbauman It definately is, but when browsing through their website, they don’t seem to fail as much (for anyone looking, Julia is in the premium “misc” category ). Cliking through their styles, most of the works pretty fine.
I have Monokai set up in VSCode, would like to make some tweaks to it, if I had time, but it makes stuff much clearer.
@cormullion and @fredrikekre looks great to me. not sure if there shouldn’t maybe be a vote for a style to put on Discourse. But basically anything would be better then the current minimal highlight.
Does the custom highlight.js schemes work in VSCode? I would be nice to try it out.
To my knowledge, Fredrik’s branch has not (yet) been upstreamed into highlights.js. It’d be great if it could!
Just to be clear, the things we have control over on Discourse are:
The default highlighting language — this is set to julia
The enabled highlighting languages — this is set to 33 languages and we can add more if you find it’d be helpful.
List of currently enabled languages
julia
julia-repl
bash
cpp
cs
css
diff
fortran
go
haskell
http
ini
java
javascript
json
llvm
makefile
markdown
mathematica
matlab
objectivec
perl
php
python
r
ruby
rust
sql
shell
swift
tex
xml
yaml
I think the themes’ CSS should be able to override the default styling of the identifiers. This doesn’t change which identifiers and syntaxes are highlighted, but it changes how they are highlighted. The defaults are here pulled from code_highlighting.scss I believe.
All of this is completely unrelated to how VS Code does its highlighting, which is powered by TextMate grammars.
I was thinking that discourse gives you access to highlight.js options and admins can choose the style to go with etc.
The thing is, I tried other languages that came to my mind and all of them have the same problem.
But from the link it would seem that Discourse in general picks a handful of tokens to highlight for all languages and that’s it.
Do I get it right?
Yeah, I know that it is unrelated to VSC, was just curious if anyone here tried using highlight.js there. (quick googling doesn’t show any extensions for that, so probably not possible).
It has not. The major reason is that lookbehind in JS regular expressions is not supported in Safari so my branch would not be merged upstream. Probably some of the changes can still be merged, but since my branch can be used with Documenter without upstream support this is not something high on my TODO list.