Highlight identifier after 'impl' keyword in Rust language definition
See original GitHub issueHi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch highlight.js@9.18.3
for the project I’m working on.
It looks as if the identifier after the impl
keyword is not being highlighted. I’ve added an extra element to the class definition to include impl
.
Here is the diff that solved my problem:
diff --git a/node_modules/highlight.js/lib/languages/rust.js b/node_modules/highlight.js/lib/languages/rust.js
index 5e2af44..590dc15 100644
--- a/node_modules/highlight.js/lib/languages/rust.js
+++ b/node_modules/highlight.js/lib/languages/rust.js
@@ -89,7 +89,7 @@ module.exports = function(hljs) {
},
{
className: 'class',
- beginKeywords: 'trait enum struct union', end: '{',
+ beginKeywords: 'trait enum struct union impl', end: '{',
contains: [
hljs.inherit(hljs.UNDERSCORE_TITLE_MODE, {endsParent: true})
],
This issue body was partially generated by patch-package.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Generic Data Types - The Rust Programming Language
We use generics to create definitions for items like function signatures or structs, which we can then use with many different concrete data...
Read more >Syntax Highlighting Improvements · Issue #284 - GitHub
I've done a survey of syntax issues of some things I think can be highlighted better. Syntax highlighting can be subjective so it's...
Read more >Rust Language Cheat Sheet
Define a method, e.g., within an impl S {} . struct S (T);, More arcanely, also ...
Read more >2457-non-ascii-idents - The Rust RFC Book
in Rust identifiers. Motivation. Writing code using domain-specific terminology simplifies implementation and discussion as opposed to translating words from ...
Read more >Rust - Nova Extensions - Panic Inc.
Rust language support for Nova featuring Rust Analyzer, ... Right click an identifier and select Jump to Definition from the menu to be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, it is. Sorry for being clear here. I meant that it would strange that in
impl Trait for Foo {}
onlyTrait
would be highlighted as a class name even thoughFoo
obviously is one as well.I’ve made a lot of other changes a cleanups in the simpler struct PR: https://github.com/highlightjs/highlight.js/pull/3078/commits/9d6befcd93ac334b62502c86efb5214f8eaa1eac