We might be able to improve support for Clojure code formatting

In a recent discussion it was indirectly pointed out that Clojure code isn’t being colored/highlighted correctly. I did some digging and Discourse appears to use highlight.js to handle highlighting, and it does appear to support Clojure. To make that work, though, you have to “turn it on” in your Discourse install. They don’t have “all” the languages turned on by default because that apparently slows things down, but given the considerable amount of Clojure code posted here, it would make sense to have that one turned on.

It looks like this is an admin setting sort of thing (highlighted languages) so maybe @lspector could look into it?


I doubt we have enough traffic in this Discourse to count a bit of js as “slowing” it :slight_smile:

1 Like

We also don’t have a ton of CoffeeScript code being posted here, or C or C++ or C#, so we could make some strategic trades if necessary. :stuck_out_tongue_winking_eye:

I looked around in the settings (there are lots of them) and the google machine (which leads to lots of wandering conversations) but didn’t find it… Do you have any info on where to do this?

I don’t have a Discourse install that I’m admin on, so I’m not 100% sure. This post is an example of something I had run across that made me think it would be “easy”. I wonder if this admin panel is “outside Discourse looking in” instead of just “inside” Discourse, but I don’t really know.

Aha – got it! Admin -> Settings -> Posting.

Now we can get Clojure highlighting by starting with a line that’s just “clojure" and ending with a line that's just "”.

;; colors here?
(defn myfn [x]
  (if (odd? x) "how odd!" (inc x)))



Huzzah! (I had to reload this page in my browser to get the colors to show – I suspect I had to reload/re-evaluate) the JS.

1 Like
{:testing-keywords (hey :they :work [:too])}