Comments (5)
Hey @Marak. This sounds like a feature that should be implemented in colors.js
IMO. It sounds like you should be altering the String.prototype.length
getter in order to subtract the length of the ANSI color codes. This would fix the problem here, and any other potential lib that depends on String#length
(which are probably out there).
Plus, if I do: 'Hello World!'.blue.length
I would always expect it's length to be 12, and not 22. So this really does seem like a colors.js
bug to me...
Just food for thought...
from cli-table.
Of course, the above it assuming that you're actually using colors.js
. You never verified that in the OP, so I'm not sure...
from cli-table.
I thought about messing with String.prototype.length
but my javascript spider sense told me not to do it.
I'll try it anyway and see what happens.
Actual library is kinda irrelevant, problem applies to ANSI escape codes in strings meant for terminal output.
Thanks for the advice!
from cli-table.
I'd think String.prototype.length
would be doable, so long as you're safe about it. And ya, I get that the ANSI codes in general are the problem, but your colors.js
aims to be a convenience wrapper around those escape codes, so continuing to abstract them away from the String interface (i.e. also abstracting them out of String#length
) would be a good thing IMO.
This way, cli-table
doesn't need to even know about the ANSI escape code, which I think it shouldn't...
from cli-table.
Fixed with #6. Thanks!
from cli-table.
Related Issues (20)
- Breaking change in non-major version HOT 2
- Prototype Pollution HOT 3
- `colors` package update would improve webpack compatibility HOT 2
- Width calculations are off when table contains terminal hyperlink control characters HOT 3
- `node examples/revs.js` gives errors
- 0.3.7 is broken HOT 6
- 0.3.7 crashes when creating tables without options HOT 2
- 0.3.7 node version HOT 2
- Breaking change to utils.strlen in 0.3.7 HOT 1
- v0.3.7 has a breaking change HOT 10
- I have a little visibility problem
- colors package is corrupted HOT 1
- Consider adding documentation of the package
- emoji gives wrong padding
- colAlign value to center text is "middle" and not "center"
- Output to file?
- Chinese causes table overflow HOT 2
- error [90mx in bot telegram
- Colors package
- .toString() throws error when new Table was instanciated with "head" prop as undefined.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli-table.