wbond / packagecontrol.io

The Package Control website
https://packagecontrol.io
Other
111 stars 46 forks source link

Invisible character (`​`) in package names #130

Open darkred opened 3 years ago

darkred commented 3 years ago

I've noticed that there is this invisible character (​) in package names. For reference:

It's the Unicode Character 'ZERO WIDTH SPACE' (U+200B) .

this character is intended for line break control; it has no width, but its presence between two characters does not prevent increased letter spacing in justification

It occurs in words that are "combinations", e.g. SublimeLinter -> Sublime + Linter Examples pages:

Just open the 1st one, rightclick the "SublimeLinter" title and press Inspect :

screenshot ![2021-03-22_184439](https://user-images.githubusercontent.com/723651/112026275-b40e4780-8b3e-11eb-9bce-216eb5a1220a.jpg)

If you select that text in your browser and press Copy (Ctrl+C) then the copied string "Sublime​Linter" contains the hidden character: screenshot. [if you doubleclick the above string you'll notice that you can select only either 'Sublime' or 'Linter'] and that leads to getting no results when using it to search for the package in Sublime Text's Package Control manager.

e.g. I have installed SublimeLinter. If I open ST3 Preferences | Package Control | List Packages and paste the string "Sublime​Linter" (with the hidden character) I'll get no results.

Using ST3 3211 x64 on win10.

wbond commented 3 years ago

This is on purpose, as it allows long package names to wrap on small screens. https://github.com/wbond/packagecontrol.io/blob/master/app/templates/helpers/word_wrap.py

wbond commented 3 years ago

This pattern is used on various online docs by various organizations, since they also run into long identifiers without spaces.

darkred commented 3 years ago

Thanks for replying.

I mentioned this, hoping that maybe it could be possible to remove it without breaking things. I see that's not possible, i.e. that's necessary, so I'm closing this.

PS. For anyone interested, here is a userscript that removes the hidden character from the package title:

// ==UserScript==
// @name         packagecontrol.io - remove invisible character in package name
// @match        https://packagecontrol.io/packages/*
// @grant        none
// ==/UserScript==

var re = /\u200B/g;
var packageTitle = document.querySelector('#content > h1');
packageTitle.innerHTML = packageTitle.innerHTML.replace(re, '');
wbond commented 3 years ago

I haven't checked recently, perhaps there is a more modern CSS method that we can use now in 2021? This was originally added in probably 2014/2015.

darkred commented 3 years ago

That would be great!

FichteFoll commented 3 years ago

Apparently, the <wbr> element should be used to suggest word break locations https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Text/Wrapping_Text#the_wbr_element.