Could we change the forum's CSS for displaying rust code?

Hi everyone,

I love the forum and find a lot of kind help for my learning purposes. Yet the syntax highlight for rust code is a bit tad and grey:

    pub fn run(&mut self) {

        let mut last_tick = std::time::SystemTime::now();

        loop {
            // takes user input and move the shape accordingly
            self.take_directions();

            // check if we reached time to tick again, then tick
            if last_tick.elapsed().unwrap().as_millis() >= self.speed {
                self.game_over(); // checks if game is over
                self.tick();
                self.clear_full_rows(); //
                last_tick = std::time::SystemTime::now();
            }
        }
    }

Compared with, for instance, what Atom shows:

Capture%20du%202019-06-27%2016-26-44

Is there something we could do about it ?

2 Likes

Please don't! On my Mac the Atom example is a black blob with overlays of red, yellow, blue and gray that is very hard to read. The gray comments are virtually unreadable.

4 Likes

There is a dark theme for the site as a whole available at https://users.rust-lang.org/u/YOUR_USERNAME_HERE/preferences/interface - still doesn't make the code quite as colorful as your average editor, but it's something.

1 Like

Pro tip: You can install browser extensions to apply your own CSS rules to any website. For example, Stylish is available for Firefox and Chrome: Website Themes & Skins by Stylish | Userstyles.org

And if you need additional language parsing, you can do that with Greasemonkey/Tampermonkey and your favorite language parser.

1 Like

The style could be changed by an URL query, say

https://users.rust-lang.org/?style=dark

It would then be placed in a session storage.

Advantages:

  • It does not affect people who don't want to use it.
  • People don't need to write/apply alternative style sheets by themself.
  • People don't need to do configurations by themself.
  • People can quickly change configurations, or say enter into.
  • People who only read don't need an account.
1 Like

As @17cupsofcoffee already mentioned above, the forum software already has the ability to switch themes through https://users.rust-lang.org/my/preferences/interface. There's even a dark theme already there.

It does not allow you to configure it without registering an account, but that's a minor inconvenience compared the the expense of installing server-side customization to the forum software.

Fair enough, thanks for you feedback!

My main gripe with the code highlighting is the color of comments. Comments tend to be documentation so I like themes that make them colorful and stand out instead of dulling them into the background (your atom example does the same though).

TIL, thank you !

1 Like

@vmedea: Absolutely ! The S tylish plugin has a gorgeous dark theme for GitHub by the way, the comments stands out in a beautiful way:

Capture%20du%202019-06-30%2021-36-42

I was thinking of such a theme when I wrote my post by the way. Should have precised.

Update on the other answers : in my first post I already display the forum's native dark theme. I'll have to look into what you tell me about, and I'll come back with better questions.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.