Skip to content

Conversation

@aladjadj
Copy link
Contributor

@aladjadj aladjadj commented May 3, 2021

Match [_9m color to reset color with inherit css attribute

Fixes: #1

Match [_9m color to reset color with inherit css attribute
@TristanCacqueray
Copy link
Contributor

I don't know yet what this 9 value means, but it does not looks like a 4bit color code.

Then using inherit does not seems to work in nested context, for example running this command:

$ echo -e "\x1b[32;1m  Green  \x1b[39;1m   inherited   \x1b[0m"

Display Green in green, and inherited in white. But the html encoding will be:

<span style="color: green">Green<span style="color: inherit">inherited</span></span>

... which does not make the inherited field white.

@TristanCacqueray
Copy link
Contributor

So according to the first paragraph of https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit , 9 is used to reset the color: To reset colors to their defaults, use ESC[39;49m (not supported on some terminals)

Co-authored-by: Tristan de Cacqueray <tdecacqu@redhat.com>
@aladjadj
Copy link
Contributor Author

aladjadj commented May 3, 2021

I just want to verify if the value "initial" revert to color asign to a balise type.

Like .myclass span { color:black; } or to initial color of navigator.

in prevision of dark theme or terminal like background

@TristanCacqueray
Copy link
Contributor

Initial does not seems to use the class style, e.g.:

<html>
  <head>
  <style>
.myclass {
  color: pink;
}
  </style>
  </head>
  <body>
    <span style="color: green">
      Green
      <span class=myclass style="color: initial">inherited</span>
    </span>
  </body>
</html>

... display inherited in black instead of pink

@TristanCacqueray
Copy link
Contributor

TristanCacqueray commented May 3, 2021

Alternatively, it seems like we could use a new AnsiCode constructor to combine Clear and Style, and we could adapt the render function to terminate the previous style in

re-ansi/src/Ansi.re

Lines 257 to 262 in 4d94ab3

switch (code) {
| Clear => (pos, [prevElem]->Some)
| EraseLine => pos->go(pos)
| CarriageReturn => (pos, [prevElem, LineBreak]->Some)
| HRef(link) => (pos, [prevElem, link->Link]->Some)
| Style(style) =>
.

Though that would be a significant change, so it would be good to look for a simpler css trick first.

@aladjadj
Copy link
Contributor Author

aladjadj commented May 4, 2021

I'm ok with you for "initial" value.
In the futur, it's maybe possible to add un "primary" and "secondary" colors like "black" and "white" and replace "initial" by the primary variable. It's may be more intuitive to customize style on top of app

@aladjadj aladjadj requested a review from TristanCacqueray May 4, 2021 09:36
@TristanCacqueray TristanCacqueray merged commit c22166d into softwarefactory-project:master May 4, 2021
@TristanCacqueray
Copy link
Contributor

Alright, then let's go with the initial value for now. Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] escape unsuported ANSI attributes

2 participants