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

Handling of ANSI foreground/background inversion is incorrect #2487

Open
tecosaur opened this issue Apr 1, 2024 · 3 comments · Fixed by JuliaDocs/ANSIColoredPrinters.jl#19
Labels
Format: HTML Related to the default HTML output Type: Bug Type: Upstream

Comments

@tecosaur
Copy link

tecosaur commented Apr 1, 2024

As I've been doing a round of improvements to the StyledStrings docs, it occurred to me that it would be good to show some styled content. One of the examples I showed was with background colour. Documenter could obtain HTML representations of AnnotatedStrings with the show(::IO, ::MIME"text/html", ::AnnotatedString) method provided by StyledStrings (and I will make another issue on this), but for now I've tried using @repl; ansicolor=true blocks.

When used with styled"{magenta:some {inverse:inverse} text}", Documenter using an IO with :color would see \e[35msome \e[7minverse\e[27m text\e[39m and produces:

image

However, this is not correct. In the terminal one sees this:

image

and StyledStrings produces the following HTML:

<span style="color: #803d9b;">some </span><span style="background-color: #803d9b;">inverse</span><span style="color: #803d9b;"> text</span>
@tecosaur tecosaur changed the title Handling of ANSI background codes is incorrect. Handling of ANSI foreground/background inversion is incorrect Apr 1, 2024
@mortenpi mortenpi added Type: Upstream Type: Bug Format: HTML Related to the default HTML output labels Apr 1, 2024
@mortenpi
Copy link
Member

mortenpi commented Apr 1, 2024

The conversion to HTML is handled by https://github.com/JuliaDocs/ANSIColoredPrinters.jl I believe. cc @kimikage

@kimikage
Copy link
Contributor

kimikage commented Apr 3, 2024

This is essentially due to the problem that default background and foreground colors (i.e., default inverse colors) are not known at the time the escape codes are interpreted in ANSIColoredPrinters.jl. The actual colors vary with the CSS of the container.
https://juliadocs.org/ANSIColoredPrinters.jl/dev/supported-codes/#Invert

I would like to examine ways to make it easier to solve this problem with CSS.

@tecosaur
Copy link
Author

tecosaur commented Apr 3, 2024

Linking to #2488 too, something that might be of interest to ANSIColoredPrinters in the future is refactoring to work via applying Faces to the new Base.AnnotatedString type, a 'la (and using) StyledStrings.

BTW, it seems that ANSIColoredPrinters has a parser error when it encounters OSC 8 links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Format: HTML Related to the default HTML output Type: Bug Type: Upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants