highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.3k stars 3.52k forks source link

(Rust) Mismatched brackets in complex attribute #4032

Open notriddle opened 2 months ago

notriddle commented 2 months ago

Describe the issue On an attribute with nested brackets, the ending brackets aren't highlighted the same as the starting brackets.

Which language seems to have the issue? Rust

Are you using highlight or highlightAuto? Discourse seems to use highlight.

Sample Code to Reproduce image

Expected behavior

#[derive(Parser)]
pub struct Arg {
  #[arg(short, long, default_values_t = [66,77])] // here, the brackets (don't) seem mismatched.
  pub(crate) arg1: Vec<u32>
}

GitHub highlights this correctly, but highlight.js doesn't.

Additional context

https://users.rust-lang.org/t/a-display-error-of-the-forum/109255

https://meta.discourse.org/t/bad-rust-syntax-highlighting/302236