"wrap" hook is only called on Token, but there is no way to hook a string, which could be a symbol
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 13k
- Forks
- 1.4k
- Avg merge
- 15h 36m
- Merged PRs (30d)
- 3
Description
Motivation
At the moment "wrap" doesn't wrap non-highlighted items.
Description
I'm trying to write a simple plugin that would highlight my own classes and constants that are exported by a C++ library.
I tried to use something like this:
Prism.hooks.add("wrap", function(e) {
if (e.language === "cpp") {
console.log(e.content);
// ... handle the case here ...
}
});
However, the callback is not called on symbols, look at this small program:
void x() {
Result r;
Context ctx;
// ... something else ...
}
The highlighter misses to call wrap with "Result", "r", "Context", and "ctx" tokens, so I cannot really influence how these would be highlighted.
Alternatives
I don't know about any - I followed the keywords highlighter plugin.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing Prism's "wrap" hook during highlighting and compare its behavior on the supplied C++ example, especially the unhighlighted symbols Result, r, Context, and ctx. Define how hook callbacks should represent string symbols, then verify that the requested symbols can be influenced without changing the existing handling of highlighted tokens.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100