Skip to content
Discussions/App Development/Is there a way to configure syntax highlighting in topics?Forum ↗

Is there a way to configure syntax highlighting in topics?

App Development3 posts475 views6 likesLast activity Apr 2020
DA
DarkoOP
Apr 2020

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?)

CO
cocreature
Apr 2020

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

AN
anthony
Apr 2020

Correct, and there is also a way to add custom syntax.

Discourse Meta – 3 Jan 19

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.

← Back to Discussions