Closed crocket closed 4 years ago
<
, >
, and "
aren't converted because they are used as part of <span>
tags which allow you to specifically colorize parts of the module's text.
I think i3pystatus shouldn't convert &
to &
because I want to insert <
and so on.
That's fair, I think that the replace code can be altered to skip replacing that text when the &
is part of an html escape.
@crocket https://github.com/enkore/i3pystatus/pull/795 should fix this, I just tested this on my install.
I think it's better and simpler to not expand &
.
It is only expanded when the text is processed by pango, because if it is not the processing fails.
I think it's better for users to handle HTML escape codes... because expanding only &
is confusing, and this behavior is not even documented.
expanding only
&
is confusing
Maybe that's the case for you, but I don't think you're considering the fact that not everyone understands HTML escapes. Many people will simply enable pango for a module because it enables specific colorization effects. For these users, adding a &
to the format string will make the entire module's text disappear due to a failure of pango to process the text.
The pull request that I opened:
&
to prevent confusion for those who don't have a more thorough understanding of pango / HTML escapes&
is expanded when part of an HTML escape code&
, <
, >
, or "
I'm not convinced that it's a great idea to make i3pystatus less intuitive for less-knowledgeable users, but it would be worth it IMO if there were good reasons for &
not being expanded (such as it being needed as part of an HTML tag, like <
, >
, and "
). I'm not aware of any such uses, but HTML and CSS are not my strong points. Are ampersands perhaps valid within, for example, a style
attribute?
@enkore thoughts?
We're not using something like markupsafe, so we can't easily distinguish what came from the format string and what is e.g. the title of a song that's now playing (and happens to contain a &
). I think escaping & when it is not part of an HTML entity is reasonable in this situation.
Oh yeah, I was so focused on the format string itself that I hadn't considered the module output (which is harder to control for).
Whatever. If it works, I'm okay.
&
is converted to&
.<
is not converted to<
.<
is converted to&lt;
.Refer to https://www.freeformatter.com/html-escape.html for details.