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

ANSI renderer bg color not showing #432

Closed
KevinBatdorf opened this issue Feb 3, 2023 · 7 comments
Closed

ANSI renderer bg color not showing #432

KevinBatdorf opened this issue Feb 3, 2023 · 7 comments
Labels
ansi bug Something isn't working

Comments

@KevinBatdorf
Copy link
Contributor

I was messing around with the ansi renderer and It's not rendering well in some cases (maybe with the background only?). Using the test content too.

Screen Shot 2023-02-03 at 5 26 40 PM

Screen Shot 2023-02-03 at 5 34 07 PM

Screen Shot 2023-02-03 at 5 35 01 PM

@octref
Copy link
Collaborator

octref commented Feb 5, 2023

Can you please include the ANSI sequence in plaintext, the color expected and the color rendered?

@KevinBatdorf
Copy link
Contributor Author

The top section I grabbed it from the test suite here: https://github.com/shikijs/shiki/blob/main/packages/shiki/src/__tests__/ansi.test.ts#L6

It should look like this (dracula terminal theme):

Screen Shot 2023-02-05 at 12 18 21 PM

But looks like this (dracula shiki theme):

Screen Shot 2023-02-05 at 12 20 44 PM

The bg color behind WARN is the issue

Exact snippet from my screenshots:

�[0;32;1m❯�[0m �[0;32mpnpm�[0m install --force�[0m
�[0;30;43m WARN �[0m using --force I sure hope you know what you are doing�[0m
Scope: all 6 workspace projects�[0m
Lockfile is up to date, resolution step is skipped�[0m
Packages: �[0;32m+1038�[0m�[0m
�[0;32m++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++�[0m

@octref
Copy link
Collaborator

octref commented Feb 5, 2023

i'll take a look later but also @muenzpraeger

@octref octref added bug Something isn't working ansi and removed need-more-info labels Feb 5, 2023
@muenzpraeger
Copy link
Collaborator

Just ran a quick test. The tokens are correctly identified.

{
  value: ' WARN ',
  foreground: { type: 'named', name: 'black' },
  background: { type: 'named', name: 'yellow' },
  decorations: Set(0) {}
}

Now the thing is that the ANSI tokenizer returns only a single color property. So the background color doesn't get passed back to the HTML rendering.

@octref
Copy link
Collaborator

octref commented Feb 9, 2023

IThemedToken will have a bgColor in 1.0's API.

@blake-mealey
Copy link
Contributor

Currently shiki's theme token doesn't support background colors so for the ANSI implementation I just left it out. Was thinking about coming back to this. ANSI also supports strikethrough which would be nice to add to shiki at some point.

@octref
Copy link
Collaborator

octref commented Feb 10, 2023

oops, that's right, i meant to mention @blake-mealey not @muenzpraeger, sorry!

@antfu antfu closed this as completed in 194557f Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ansi bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants