-
Notifications
You must be signed in to change notification settings - Fork 745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Null coalesce breaks highlighting in template string (Javascript/Typescript) #1516
Comments
@Kcazer Thanks for the report. Will take a look! |
The same problem occurs for the optional chaining operator const test = { }
console.log(`something ${test?.value}`);
const description = "Highlighting is broken now"; |
@Kcazer I've submitted a PR to the TypeScript lexer that fixes the use of In terms of the JavaScript lexer, our approach with proposals to the JavaScript spec is to wait until they are accepted before incorporating them into the lexer. This is the reason optional chaining is only supported in the TypeScript lexer at this stage (see #1420). |
Hi @pyrmont I was referring to Typescript for the optional chaining operator but I was mistaken, it is only broken in tsx (which is also called "Typescript") in the rouge preview site. See a broken example of optional chaining in tsx |
@donocode Ah, fair point about the TSX lexer (coincidentally, the next release of Rouge will fix the name :D). Will get the optional chaining working there, too! |
@Kcazer This has been added to the TypeScript lexer. Furthermore, it's been done in a way so that the TSX lexer will also recognise the operator. @donocode I've moved the code prepending the optional chaining operator to the TypeScript common module and so now works in both the TypeScript and TSX lexers. This is also the case for the nullish coalescing operator. A version of Rouge with these changes, v3.20.0, is scheduled for release on Tuesday 9 June. Thanks for the bug reports! This helps make Rouge better 👍 |
Hi, @pyrmont sample: const optional = `code${window?.console ?? true}`;
const java = 12;
const classes = `header ${ isLargeScreen() ? '' :
`icon-${item.isCollapsed ? 'expander' : 'collapser'}` }`; Same code on rouge.jneen.net Related Links |
@Hxuhao233 I'm no longer a maintainer on this project so I'm afraid I'm not the right person to ask any more. I'm sorry :( Oh, and given the age of the earlier issue, I'd suggest opening a new one for this. |
Thanks for the reply, I will open a new issue |
Name of the lexer
Typescript and Javascript lexers
The lexer fails when using the null coalesce operator
??
inside a template string.All of the code after the end of the string is colored as if it was part of a giant string.
Code sample
Same code on rouge.jneen.net :
The text was updated successfully, but these errors were encountered: