highlightjs / highlightjs/highlight.js

[Request] __emitTokens to report relevance score

Open
#4,392 3 comments 0 reactions 0 assignees View on GitHub
enhancement parser
Dominant language
JavaScript
Stars
25k
Forks
3.8k
Avg merge
11h 35m
Merged PRs (30d)
3

Description

**Is your request related to a specific problem you're having?**
I'm developing a syntax definition using `__emitTokens` API, and this API doesn't allow me to report relevance, so my syntax couldn't be autodetected.

**The solution you'd prefer / feature you'd like to see added...**
The `emitter` object or some other argument passed to `__emitToken` should expose a function for reporting relevance.

**Any alternative solutions you considered...**
I studied HLJS implementation trying to find some way to directly reach the `relevance` variable, but didn't find such a way.

**Additional context...**
Also, it would be great to permit `__emitTokens` at `Mode` level. In such a scenario `__emitToken` could consume input up to certain point, where the current mode should end, and return the index of that point, so the core engine knew where to proceed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.