Skip to content
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

Add syntax highlighting support for lines #14

Open
patriksvensson opened this issue Sep 11, 2022 · 1 comment
Open

Add syntax highlighting support for lines #14

patriksvensson opened this issue Sep 11, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@patriksvensson
Copy link
Contributor

No description provided.

@patriksvensson patriksvensson added the enhancement New feature or request label Sep 11, 2022
@LPeter1997
Copy link

We have got a project that we would love to use the library for and would like to have some syntax coloring. I also don't mind contributing this.

Having fairly minimal Spectre knowledge, peeking around in the library it looks like the source lines are rendered here. The actual highlighter API could be exposed in the ReportSettings, I do not see any other public API that's already present for the renderer. Something simple could be exposed for the user:

readonly record struct Token(int Start, int Width, string Type);

interface ISourceTokenizer
{
    public IEnumerable<Token> TokenizeLine(string sourceId, int line, string line);
}

So render text could be driven based off of this (or something similar). Color coding could be done by mapping string Types to colors. For a CLI renderer, even just having a fixed set of token types could be fine, in which case the type could be an enum instead.

What kind of API did you imagine for this? Have you planned to pick this issue up yourself, or should we consider contributing this ourselves? If this is the case, do you have any pointers/suggestions for us?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants