highlight.js
highlight.js copied to clipboard
(Rust) Escaped double quotations in string at attribute are not highlighted properly
Describe the issue
Escaped double quotations in string at attributes are not treated as a escaped character but a normal quotation.
Which language seems to have the issue?
Rust
Sample Code to Reproduce
#[derive(ThisError)]
enum MyError {
#[error("\" appears in a string")]
UnexpectedDoubleQuote
}
fn main() {}
Expected behavior
The escaped double quotation \"
shouldn't be treated as a normal double quotation.
Confirm. Looks like a good first issue, probably need to reuse the full string rules inside meta
... can ALL the syntactic features of strings be used in a #[]
block?
{ className: 'string', variants: [ { begin: /b?r(#)"(.|\n)?"\1(?!#)/ }, // Handles raw strings with escaped double quotes { begin: /b?'\?(x\w{2}|u\w{4}|U\w{8}|.)'/ } // Handles character literals with escaped double quotes ] ] }
we should add (.|\")*? to the first variant to match any character or an escaped double quote within the string. we should add (\") to the second variant to allow for escaped double quotation marks within character literals.
update code snippet :
{ className: 'string', variants: [ { begin: /b?r(#)"(.|\")?"\1(?!#)/ }, // Handles raw strings with escaped double quotes { begin: /b?'\?(x\w{2}|u\w{4}|U\w{8}|.|\")'/ } // Handles character literals with escaped double quotes ] }
please correct me if i am wrong.
Very hard to review code here when just thrown in as regular text, but if you'd be game to make a PR I'd be happy to review.