-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
When multiple spaces are present, label width is computed incorrectly #6510
Comments
Thanks for opening this, could you please update your description to also include the badge urls? Also worth noting explicitly that you're referring to the raster badges here, not the svgs. |
You can click on the badges to navigate to their urls. I can also add the links as plain text if you want. I am not referring specifically to the raster badges. The same thing happens with the svg badges for me, but I included the Edit: done |
What's happening with the consecutive whitespace cases is that we're (correctly) computing all the width/length properties for the badge with the provided number of whitespace characters, but at render time the browsers are dropping all the consecutive spaces resulting in the value of This feels like a rather extreme edge case, and I'm not sure if we've any history on this topic and/or past decisions intentionally driving this behavior. However, certainly worth asking if we could/should tweak the generated xml to preserve whitespace in the text elements. cc @badges/shields-maintainers |
@calebcartwright Non-breaking spaces appear to work fine:
So a workaround could just be to replace spaces in the label with non-breaking spaces instead. Something like:
may suffice. |
Are you experiencing an issue with...
🪲 Description
It seems that the width of the badge label/value text is computed incorrectly for space characters. This leads to the rest of the text getting stretched out.
🔗 Link to the badge
Here are some badges that have their label replaced by
foo
+ N spaces +bar
. Notice that there are no whitespace characters betweenf
,o
ando
as well as betweenb
,a
andr
.https://raster.shields.io/pypi/v/a?label=foo%20bar
:https://raster.shields.io/pypi/v/a?label=foo%20%20bar
:https://raster.shields.io/pypi/v/a?label=foo%20%20%20%20bar
:https://raster.shields.io/pypi/v/a?label=foo%20%20%20%20%20%20%20%20bar
:https://raster.shields.io/pypi/v/a?label=foo%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20bar
:https://raster.shields.io/pypi/v/a?label=foo%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20bar
:Compare with the same badges but with
%20
replaced by_
:https://raster.shields.io/pypi/v/a?label=foo_bar
:https://raster.shields.io/pypi/v/a?label=foo__bar
:https://raster.shields.io/pypi/v/a?label=foo____bar
:https://raster.shields.io/pypi/v/a?label=foo________bar
:https://raster.shields.io/pypi/v/a?label=foo________________bar
:https://raster.shields.io/pypi/v/a?label=foo________________________________bar
:And the svg versions
https://img.shields.io/pypi/v/a?label=foo%20bar
:https://img.shields.io/pypi/v/a?label=foo%20%20bar
:https://img.shields.io/pypi/v/a?label=foo%20%20%20%20bar
:https://img.shields.io/pypi/v/a?label=foo%20%20%20%20%20%20%20%20bar
:https://img.shields.io/pypi/v/a?label=foo%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20bar
:https://img.shields.io/pypi/v/a?label=foo%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20bar
:https://img.shields.io/pypi/v/a?label=foo_bar
:https://img.shields.io/pypi/v/a?label=foo__bar
:https://img.shields.io/pypi/v/a?label=foo____bar
:https://img.shields.io/pypi/v/a?label=foo________bar
:https://img.shields.io/pypi/v/a?label=foo________________bar
:https://img.shields.io/pypi/v/a?label=foo________________________________bar
:The text was updated successfully, but these errors were encountered: