Holochain Forum

Discourse forum: Rust syntax highlighting

Currently, Rust syntax highlighting doesn’t seem to be available on this forum. I would suggest that not only this be made available, but that it become the default since that is what new Holochain apps are usually written in.

Here is a piece of Rust code using the default highlighting:

struct Foo;

impl Foo {
    pub fn bar(self) { }
}

Here is a piece of Rust code using ```rust:

struct Foo;

impl Foo {
    pub fn bar(self) { }
}

To show that ```language-name should matter, here’s a piece of code highlighted with ```python

# comment
// not a comment
"""
multi-line string
"""
struct NotHighlighted;

For admins trying to implement this, here are a few resources I found when researching this:

3 Likes

Thank you @timotree3 for the feedback. We’ll discuss this at our team meeting. We’ll turn it into an issue and/or a create a Trello card to make sure we implement this suggestion. Once implemented/addressed, we’ll update this thread. Hope all is well!

2 Likes

BTW, as an alternative which you have probably seen @timotree3 , you can write in Rust playground and post a link to the code there. It will not only show the syntax, but be runnable!

use std::path::Path;

let path = Path::new("/tmp/foo.rs");

println!("{}", path.display());

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7ddec0625d17bbb25f69cdba4614e9ad

3 Likes

Whoops, I forgot to indent the code. I’ve also added your examples:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7ddec0625d17bbb25f69cdba4614e9ad

Hey @timotree3 Rust highlighting is now enabled. Thanks for the suggestion and resources. Any problems, let us know.

FYI @dhtnetwork

4 Likes

@Holochain Fantastic! Thank you for implementing.

Timo - let us know if you have additional suggestions/feedback for the Forum.

1 Like