The Substrate StackExchange is primarily a developer community which involves lots of code, primarily Rust and JavaScript.

It seems the syntax highlighting on the Rust programming language is basically non-existent.

See this example from this answer:

/// Use this filter to block users from calling any functions in the Balances pallet.
pub struct DontAllowBalances;
impl Contains<Call> for DontAllowBalances {
    fn contains(c: &Call) -> bool {
        // This will match against any call from the Balances pallet.
        !matches!(c, Call::Balances(..)

Additionally, we do not seem to have support to write and execute simple JavaScript samples like StackOverflow has:

console.log("Hello, Stack Snippets!");

Can we enable these fuctionalities on this site?

  • 2
    It looks like syntax highlighting is not enabled on the site at all. It doesn't look like a rust specific issue. When inspecting the HTML elements, all code markdown is formatted with just <pre><code></code></pre> (no highlight.js classes) regardless of if a language is specified or even when using the full lang- specifier notation. Feb 15, 2022 at 19:28
  • 1
    Yes, it appears to be a bug. Posting code with ````rust` should highlight rust syntax.
    – q9f
    Feb 16, 2022 at 16:43

3 Answers 3


I've enabled syntax highlighting on Substrate's main site. Please refer to Glorfindel's answer or this MSE post for some basic guidance on how to use it.

  • How can I associate the [rust] tag with lang-rust, so that users can put ```rust rather than ```lang-rust ?
    – Shawn Tabrizi Mod
    Mar 18, 2022 at 13:51
  • Specifically, I don't see this feature: When should the code language associated with a tag changed from "none" to "default"?
    – Shawn Tabrizi Mod
    Mar 18, 2022 at 14:00
  • 4
    That is a tool only moderators have access to. I've enabled it for the rust tag.
    – JNat StaffMod
    Mar 18, 2022 at 14:06
  • Thank's JNat that's much better!
    – Squirrel
    Apr 5, 2022 at 17:45
  • So to be clear, rust snippets only are highlighted if they are tagged rust? This all code related questions must be tagged with this to get highlights? IMHO that is a be silly, as almost all questions will have this, and those without it very likely contain no snippets at all. The exception being JS primarily.
    – Nuke Mod
    Apr 17, 2022 at 22:29
  • 1
    Can we also enable this for javascript / js? That should be the main two languages of this community.
    – Shawn Tabrizi Mod
    Apr 30, 2022 at 7:35
  • 1
    @DanShields No that is not correct. You can tag code with rust, even if the rust tag is not present in that question.
    – Shawn Tabrizi Mod
    Apr 30, 2022 at 7:36
  • also json and typescript/ts -- edit: json seems supported already :)
    – Nuke Mod
    May 2, 2022 at 21:52

ooh. If it could just default to ```rust if no other lang was specified that would be a ma zing.


Syntax highlighting can be enabled by staff, but you have to tell the system which one (Rust, JavaScript, or something else) needs to be applied. That can be done in two ways:

  • explicit specification with e.g. ```lang-rust
  • implicit specification via one of the question's tags – these need to be specified by moderators or staff. For an example, see the bottom of the rust tag page on Stack Overflow

I'm not sure if it's possible to set a default syntax highlighting; code blocks can also be used for other purposes (e.g. console output) for which syntax highlighting would be confusing.

  • 2
    Well if any staff sees this, I would love to have syntax highlighting enabled on this site. I expect there will be a lot of code.
    – Shawn Tabrizi Mod
    Feb 21, 2022 at 5:04
  • +1 I would really love the syntax highlighting, ideally on par with github using rust and other keywords, ideally not lang-rust if possible for brevity. Already there are snippets of many languages, so I would opt for more is better now over trying to cherry pick specific langs.
    – Nuke Mod
    Mar 5, 2022 at 3:41
  • I see ```rust seems to work. Nice!
    – Squirrel
    Apr 5, 2022 at 17:44
  • 1
    @Squirrel that's because staff (apparently) associated the rust tag with the rust language.
    – Glorfindel
    Apr 5, 2022 at 17:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .