Spaces in file names are replaced_with_underscores for markdown alt tag
Summary
I often take screenshots and directly name them with a description like: "Popup not aligned with button.png".
When I attach it in GitLab, it embeds it to this, without filename (correct) but with spaces to underscores:
![Popup_not_aligned_with_button](…)
Steps to reproduce
- Open an issue or comment on an issue
- Attach an image with spaces in the filename
- Check the result
![file_name_with_underscores](…)
Example Project
See the difference right here:
This is the filename screenshot:
This is how it looks like in GitLab:
What is the current bug behavior?
When I attach an image with spaces in the filenam in a GitLab issue, it embeds it to this, without file extension (correct) but with spaces to underscores:
![Popup_not_aligned_with_button](…)
What is the expected correct behavior?
GitHub for example does not mess with the filename, just cuts the extension:
![Popup not aligned with button](…)
This is desirable, as it is like the HTML alt="…"
tag which is displayed when the image is still loading, does not load, or is read by screenreaders. Underscores have no place there.
Possible fixes
Do it like GitHub, and don’t replace the spaces in filename with underscores for the alt text. It’s fine to do it for the upload filename, but not for the alt text.