Important to defeat Twitter wrongly auto-guessing of URLs (and assuming anything with @ or # is a mention or hashtag) is Nelson’s Weblog: tech / zero-width-space
Posted by jpluimers on 2024/07/11
Quoting in full from [Wayback/Archive] Nelson’s Weblog: tech / zero-width-space to demonstrate a zero-width-space problem with WordPress too.
[Wayback/Archive] Zero width space
The zero width space is a useful Unicode character. It’s white space but renders with zero width. Useful for hinting where a line break could go if a browser needs to wrap a long line. It’s also good for faking out Twitter’s annoying URL rewriter; if you stick a ZWS in the middle of a domain name then Twitter won’t rewrite your text with a t.co redirect.
The zero width space is Unicode character [Wayback/Archive] U+200B. (HTML
). It’s remarkably hard to type. [Wayback/Archive] On Windows you can typeAlt–8203. On Linux you apparently can typeCtrl–Shift–U 8203. On a Mac you need [Wayback/Archive] Character Viewer; search for “zero” and double click the invisible character on row 4, column 1 to insert a ZWS.ZWS >< ZWS
Or you can just cut and paste it. I put one up there for you, between the left and right angle brackets. Of course being zero width you can’t easily select it; best bet is to copy the angle brackets too, all 3 characters. Then paste and delete the brackets. You can verify the ZWS is still there by using the arrow keys to move the cursor; it should get “stuck” on the ZWS and require two movements to pass.
When posting this in either the Gutenberg editor or classic editor, the zero-width space inside ZWS >< ZWS is gone which you can verify in WordPress itself by viewing the page as “Text” or in a web-browser by viewing the page source: there is no .
Since copying and representing zero-width-space is a pain in so many tools, below are some tips on automating things all via [Wayback/Archive] bookmarklet twitter zero width space – Recherche Google.
The show you both how hard it is on a normal system to access something simple as a Zero Width Space, and how easy it is to write a Bookmarklet in JavaScript.
- [Wayback/Archive] Axel Rauschmayer on Twitter: “Zero-width Unicode spaces are useful for “escaping” things from Twitter. For example: @rauschma”
- [Wayback/Archive] Axel Rauschmayer on Twitter: “Bookmarklet helper (alas,
copy()or similar are not available to bookmarklets):javascript:prompt('Command:', "copy('\\u{200B}')")“ - [Wayback/Archive] extinguished engineer on Twitter: “@rauschma A bit easier way:
javascript:prompt("Press Ctrl+C", "\u200b")Second argument of prompt is always used as input’s default value and preselected, so Ctrl+C on the opened popup is enough.” - [Wayback/Archive] Šime (ˈshe-meh) on Twitter: “@rauschma I still copy-paste it from a website (
somebits.com/weblog/tech/zero-width-space.html). Is the a better (faster) way? 😅” - [Wayback/Archive] extinguished engineer on Twitter: “@simevidas @rauschma Obviously! 😄”
It also made me find [Wayback/Archive] Stop Twitter from Adding Links in your Tweets – YouTube which directs to [Wayback/Archive] Prevent Twitter from Converting @Mentions into Links – Digital Inspiration which shows an HTML fragment that automatically copies the content of an input to a span automatically appending a Zero-Width Space after each dot (.), at (@) or hash (#) character. Should be easily converted to a HTML page that converts from a multi-line input to a multi-line output.
Query that led me to all this: [Wayback/Archive] zero width space – Google Search
–jeroen
Rate this:
Share this:
- Click to share on Mastodon (Opens in new window) Mastodon
- Click to share on Bluesky (Opens in new window) Bluesky
- Share on Tumblr
- Click to share on Reddit (Opens in new window) Reddit
- Click to share on Threads (Opens in new window) Threads
- Tweet
- Click to share on Telegram (Opens in new window) Telegram
- Click to share on Nextdoor (Opens in new window) Nextdoor
- Click to share on WhatsApp (Opens in new window) WhatsApp
- Click to print (Opens in new window) Print
- Click to email a link to a friend (Opens in new window) Email
Related
This entry was posted on 2024/07/11 at 12:00 and is filed under Bookmarklet, Classic editor, Development, Gutenberg editor, JavaScript/ECMAScript, Power User, Scripting, SocialMedia, Software Development, Twitter, Web Browsers, Web Development, WordPress. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
This site uses Akismet to reduce spam. Learn how your comment data is processed.







Leave a comment