Attribute formatting in Rust code blocks is wrong

I've noticed recently that attributes in code blocks here on the forum are being highlighted identically to comments (gray and italic):

/// hello
#[hello]
fn hello() {}

Screenshot:

image

This seems not ideal, since it deemphasizes them, and might even mislead a newcomer into thinking an attribute is some kind of comment parsed by another tool and not part of the language syntax.

This doesn't seem to happen on other sites using highlight-js, either, only here, so I'm posting to meta hoping that someone knows how to fix this site-specific problem.

3 Likes

In this css file there's the .hljs-meta class (applied to the #[hello] attribute) defined exactly like the .hljs-comment class (applied to the /// hello comment from your example). The color is set to var(--hljs-comment), concretely #998. Looks to me like one could update the highlight.js theme with five lines of css code to make .hljs-meta distinct from .hljs-comment. As to what the best way to implement such a change would be (like raising an issue with discourse, asking the admins of URLO to host a modified version of the theme or use a different theme entirely), I don't know.

5 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.