Increase token granularity for improved syntax highlighting
See original GitHub issueIt would be cool to add more tokens so different parts of the code can be highlighted differently. Prism seems more granular than CodeMirror, but it’s still missing some nice tokens compared to Atom and VS Code.
For JavaScript, it would be nice to have these:
token parameter
function add(a, b) { // <-- `a` and `b` receive `parameter`
return a + b;
}
token property definition
andtoken property access
const obj = {
example: true // <-- `example` receives `property` and `definition`
};
obj.example; // <-- `example` receives `property` and `access`
token function method
this.func(); // `func` receives `method` if being called on an object
token keyword module
All keywords here should receive the module
token.
import { thing as thingy } from 'thing';
export default thingy;
token keyword special
“special”(?) keywords like this
token variable dom
window
document
navigator
performance
localStorage
token console
console.log('hello'); // <-- `console` receives this token
token operator spread
const copy = [...arr]; // <- `...` receives this token
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:17 (9 by maintainers)
Top Results From Across the Web
Optimizations in Syntax Highlighting, a Visual Studio Code Story
A tokenizer can store some state at the end of a tokenized line, which will be passed back when tokenizing the next line....
Read more >New npm features for secure publishing and safe consumption
We are excited to announce two new features for a safer npm package ecosystem experience: granular access tokens and the npm code explorer....
Read more >T6471 Replace zsh-syntax-highlighting with fast-syntax ...
Faster, better optimized and increased granularity with highlighting syntax. Is it open source? - Yes. Uses exactly the same license as the current...
Read more >Custom syntax highlighting for certain keywords (i.e. access ...
IDEABKL-63 Improved control over syntax highlighting for keywords ... Yes but that's just how they decided to colorize the Java language tokens, ...
Read more >User Manual - rust-analyzer
rust-analyzer: building a better Rust IDE. ... Semantic Syntax Highlighting; Show Syntax Tree; Shuffle Crate Graph; Status; Structural Search and Replace ...
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
This will come soon to CSS Extras with #1638 and #1671. The only difference is that I highlight your
"value"
not asstring
but asvalue
(that’s the token name).Insert this code into
prism-javascript.js
in line 37 and you will have most of the features.The code
But let me warn you:
Keep in mind that if you want to use the minified file, you will have to rebuild Prism (refer to
README.md
).