Is there a way to configure syntax highlighting in topics?
When posting code excerpts, you can use the “Preformatted text” feature.
But depending on the length of the excerpt it’s not always trivial to read. Can you somehow annotate what kind of syntax highlighting should be used? (i.e. DAML, Java, C#, etc?)
You can add the language name after the triple backticks at the beginning, e.g.,
```java
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, World");
}
}
I believe we do not yet have proper syntax highlighting for DAML code. You can find a list of the language names and aliases at https://github.com/highlightjs/highlight.js/blob/master/SUPPORTED_LANGUAGES.md
Correct, and there is also a way to add custom syntax.
Hack to install a new language for Highlight.JS on a hosted discourse
I’ve just added a hook to our HighlightJS code so now you can use the plugin API to add a custom language for Highlight.JS. Example (using the beancount language from the OP):
Edit: Also we’re currently highlighting for these languages, and DAML gets the haskell highlighting.
