Support Mojo syntax highlighting on this forum

I know this forum is brand new, but would we be able to get Mojo syntax highlighting supported on this forum?

4 Likes

@Caroline That seems like a major omission, is this something that Modular could upstream from existing tooling?

2 Likes

Welcome @tristanbiesecker . I do think that this is an important request not just for Discourse but Discord and Github. As I understand it, the supported language list in the config file is

default: "bash|c|cpp|csharp|css|diff|go|graphql|ini|java|javascript|json|kotlin|lua|makefile|markdown|objectivec|perl|php|php-template|plaintext|python|python-repl|r|ruby|rust|scss|shell|sql|swift|typescript|xml|yaml|wasm"

Adding mojo would be nice though I’m under the impression that it invokes Highlightjs and it does not currently support mojo

https://highlightjs.readthedocs.io/en/latest/supported-languages.html

Like most markdown platforms, Discourse does support the triple tick + language in order to invoke the language formatting.

(Partly this is explanation, partly this is breadcrumbs for Caroline and/or whoever chooses to take this on.)

1 Like

lets check the manual language specification.

struct Shell:
    var path: String  # shell path
    var args: String  # additional arguments passed to the shell
    var env: List[String]
    var shellrc: String  # shellrc file path

    fn __init__(
        inout self,
        path: Optional[String],
        args: Optional[String],
        env: List[String],
        shellrc: Optional[String],
    ) -> None:
        self.path = path.value() if path is not None else ""
        self.args = args.value() if args is not None else ""
        self.env = List(str(""))  # env
        self.shellrc = shellrc.value() if shellrc is not None else ""

    fn __copyinit__(inout self, existing: Self) -> None:
        self.path = existing.path
        self.args = existing.args
        self.env = existing.env
        self.shellrc = existing.shellrc

    fn dump(self) -> None:
        print("Shell struct")
        print("Path: ", self.path)
        print("Args: ", self.args)

As we can see here, although i specified the language manually, no linting yet :frowning:

I’m not sure what language you asked for, this is your code that I started with

```python

struct Shell:
    var path: String  # shell path
    var args: String  # additional arguments passed to the shell
    var env: List[String]
    var shellrc: String  # shellrc file path

    fn __init__(
        inout self,
        path: Optional[String],
        args: Optional[String],
        env: List[String],
        shellrc: Optional[String],
    ) -> None:
        self.path = path.value() if path is not None else ""
        self.args = args.value() if args is not None else ""
        self.env = List(str(""))  # env
        self.shellrc = shellrc.value() if shellrc is not None else ""

    fn __copyinit__(inout self, existing: Self) -> None:
        self.path = existing.path
        self.args = existing.args
        self.env = existing.env
        self.shellrc = existing.shellrc

    fn dump(self) -> None:
        print("Shell struct")
        print("Path: ", self.path)
        print("Args: ", self.args)

So Discourse and Highlightsjs are active as seen by the color coordination. What output were you expecting and what language did you specify?

Sheesh. Is there a linter and code formatting tool for Mojo in the works.

The VSCode extension does code formatting and is wonderful. This is Discourse. It does not have a compiler attached to it. As stated above, the highlightjs backend that does the code formatting for Discourse does not have mojo support.

Since mojo is a compiled language, linting would an organizational “idea”. For example, Google has guidelines for how python, a scripted language, should look.