sopel-irc / sopel-twitter

A Twitter plugin for Sopel
Other
2 stars 5 forks source link

collapse whitespace with 1+ newline to one newline #36

Closed half-duplex closed 2 years ago

half-duplex commented 2 years ago

Example: https://twitter.com/NASAWebb/status/1545413807996129280 Current: < Sopel> [Twitter] NASA Webb Telescope (@NASAWebb): 🎯 Target(s) acquired! ⏎ ⏎ The targets of Webb’s first images have been announced: https://go.nasa.gov/3ysrC73 ⏎ ⏎ ✨ SMACS 0723 ⏎ ⏎ ✨ WASP-96b ⏎ ⏎ ✨ Southern Ring Nebula ⏎ ⏎ ✨ Stephan’s Quintet ⏎ ⏎ ✨ Carina Nebula ⏎ ⏎ Tune in July 12 as we reveal Webb’s first images & #UnfoldTheUniverse. https://pbs.twimg.com/media/FXJpp-XX0AAhLuj.jpg | 2621 RTs | 10159 ? Proposed: < Sopel> [Twitter] NASA Webb Telescope (@NASAWebb): 🎯 Target(s) acquired! ⏎ The targets of Webb’s first images have been announced: https://go.nasa.gov/3ysrC73 ⏎ ✨ SMACS 0723 ⏎ ✨ WASP-96b ⏎ ✨ Southern Ring Nebula ⏎ ✨ Stephan’s Quintet ⏎ ✨ Carina Nebula ⏎ Tune in July 12 as we reveal Webb’s first images & #UnfoldTheUniverse. https://pbs.twimg.com/media/FXJpp-XX0AAhLuj.jpg | 2621 RTs | 10159 ♥s | Posted: 2022-07-08 - 14:25:38UTC

This saves enough bytes (5 for each newline removed: b' \xe2\x8f\x8e ', plus spaces) that the likes and entire post date can now fit too.

half-duplex commented 2 years ago

Should we also collapse runs of spaces to just one space?

dgw commented 2 years ago

Runs of regular spaces are less clear cut, but it's not like squishing tweets onto one line preserves ASCII art or other arrangements. I just can't think of cases where it would matter, but also can't shake the feeling that such cases do exist. Weird math? Hmmm