[Forum] Incomplete or no syntax highlighting support for some languages in code blocks

The markdown support for this forum does not seem to support syntax highlighting for all language, or is partial for blocks of code.

It would be nice to have the same support as on GitHub, where you can specify the language name after the triple back-quotes.

Ignore the trailing | in the examples below, I was not able to escape the triple back-quotes !

Partial syntax hilighting

Java and Python seem to have basic support:

Java

|  ```java
|  public class HelloWorld {
|     public static void main(String[] args) {
|         // Prints "Hello, World" to the terminal window.
|         System.out.println("Hello, World");
|     }
|  }
|  ```

I get some coloring.

public class HelloWorld {
   public static void main(String[] args) {
       // Prints "Hello, World" to the terminal window.
       System.out.println("Hello, World");
   }
}

If I omit java, now the HelloWorld is red, but out it bold (?)

public class HelloWorld {
   public static void main(String[] args) {
       // Prints "Hello, World" to the terminal window.
       System.out.println("Hello, World");
   }
}

Python

Looks like python is reversed: adding the language identifier disable most highlighting, while no identifier at all seems to give the best results. Is python the default language for code blocks, by any chance?

With:

x = 1
if x == 1:
    # indented four spaces
    print("x is 1.")

Without:

x = 1
if x == 1:
    # indented four spaces
    print("x is 1.")

No highlithing

Other languages like C# or Go don’t have any support it seems:

C#

No changes in color with or without the identifier:

With ```csharp or ```c#:

public class HelloWorld
{
   public static void Main(string[] args) {
       // Prints "Hello, World" to the terminal window.
       Console.WriteLine("Hello, World");
   }
}

With ```:

public class HelloWorld
{
   public static void Main(string[] args) {
       // Prints "Hello, World" to the terminal window.
       Console.WriteLine("Hello, World");
   }
}

Go

No difference for go either:

With ```go:

package main
import "fmt"
func main() {
    fmt.Println("hello world")
}

With ```:

package main
import "fmt"
func main() {
    fmt.Println("hello world")
}
1 Like

Thanks for the detailed feedback. The forums run on Discourse, so I believe this would have to be a feature request directly to that project in order to make such a change.

I was able to add go, csharp, and swift as languages where syntax highlight applies. However, beyond the default highlighting behavior Discourse provides I’m not sure this is something we could change.