Giter Club home page Giter Club logo

tty-strings's People

Contributors

luciancooper avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

tty-strings's Issues

Break words per-character for CJK languages

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.