Discourse Solidity syntax highlighting

We don’t have proper syntax highlighting for Solidity code blocks. I tried highlightjs-solidity but for some reason it didn’t work.

Has anyone seen Solidity syntax highlighting in a Discourse forum so we can ask how they set it up?

Have you tried asking around in https://ethereum-magicians.org/?

Good suggestion but there doesn’t seem to be Solidity highlighting there either.

What was the solution as there is some highlighting in the forum?

I didn’t see Solidity as one of the languages in https://highlightjs.org/

pragma solidity ^0.5.0;

contract DoggoToken is ERC20, ERC20Detailed, ERC20Mintable, ERC20Burnable {

        string name,
        string symbol,
        uint8 decimals
        ERC20Detailed(name, symbol, decimals)
1 Like

@abcoathup No solution yet! :disappointed:

The highlighting that you see is a random one that highlightjs is detecting. It seems to be C#.

I would love for us to fix this. We should try highlightjs-solidity again. I may have been doing something wrong.


I asked the creator of highlightjs-solidity https://twitter.com/abcoathup/status/1127827530432385024 but he wasn’t able to advise.

I have asked in the meta discourse. https://meta.discourse.org/t/how-to-get-solidity-syntax-highlighting/117774 the response was to do a PR to highlightjs to get Solidity added as a language and then Discourse would add it to an update.

1 Like

highlightjs-solidity needs an update


It seems like there’s an alternative. (Ignore that the tityle says “Hack”, the link is to the comment with the official way to do it.)

This is what I tried back then but couldn’t get to work. It’s worth trying it once more IMO.

1 Like

I have started on a PR for highlightjs Issue #2047 to add the Solidity language.

According to a maintainer of highlightjs

Solidity should stay in it’s own repo :slight_smile: we are splitting out the languages.

I haven’t found out how to get the https://github.com/highlightjs/highlightjs-solidity/ repo picked up by Discourse.

Discourse support have provided instructions on how to do this:

As an aside haltman-at has updated the syntax highlighting in the hightlightjs-solidity repo https://github.com/highlightjs/highlightjs-solidity/pull/5