luciancooper / tty-strings Goto Github PK
View Code? Open in Web Editor NEWTools for working with strings displayed in the terminal
License: MIT License
Tools for working with strings displayed in the terminal
License: MIT License
Hi there. This is a really nice looking library and it looks to work well. I've got a suggestion that might be of use: in the wordWrap()
function, it might be nice to support CJK language wrapping rules.
Basically, languages using CJK characters don't really have word wrapping, and words are split up across multiple lines if they happen to be at the end of a line. This is because they basically don't have spaces like Latin text does. (Hangul/Korean is slightly different because it does have spaces, but words are normally still broken up per-character mid-word.)
So if we take this sentence containing both Latin and Japanese text:
Lorem ipsum dolor sit amet 7月には七夕がある。お願いだから泣かないで, non maximus magna urna maximus massa.
It should be wrapped like this (note: width 22 columns, doesn't quite look correct on Github):
----------------------
Lorem ipsum dolor sit
amet 7月には七夕があ
る。お願いだから泣かな
いで, non maximus
magna urna maximus
massa.
----------------------
At the moment, using this package, it's wrapped like this:
----------------------
Lorem ipsum dolor sit
amet
7月には七夕がある。お願いだから泣かないで,
non maximus magna urna
maximus massa.
----------------------
There might be other languages that have similar rules. I'm not entirely sure. I do know that emoji get a similar treatment in the browser—if you put a bunch of emoji next to one another they get wrapped per-character instead of per-word. I don't know if it applies to all characters of width=2.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.