-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How could I use newline characters? #9
Comments
How is the output supposed to look? |
I am writing V3 at the moment. This sounds like a breaking change. Therefore, it would be a good time to contribute thoughts about newline character support. |
I was thinking more of this and I cannot see a valid use case for a newline character in the context of a tabular data. If you can provide an example, I will add this for future consideration. |
Thanks for your concern @gajus . What I really need is to have multiple line in one cell for some reason. A bad code was like
As you can see, in the variable
|
There is no way to force a new line other than restricting the column width. As a simple workaround, I suggest to simply replace all instances of newline with a custom character that would visually indicate a line break, e.g. literal |
Since @shellscape has brought this up again: I don't remember the reason for not supporting a new line character. As far as I remember, my reasoning was that this is a fairly edge case requirement and it would introduce a considerable level of code complexity to support it without running into edge cases. |
haha "hellscape" that sounds ominous. I don't think it's as edge-casey as it might seem. Aside from text-table, nearly every other table-printing module out there supports it. I was drawn in by the simple use and setup of |
Sorry, copy-paste failure. :-) I am certainly open to a PR. |
Another use case would be pretty-printing json schema into one of the columns, eg:
In my case the schema is more complex with custom syntax highlighting. It does not make sense to transform it into another table. |
I will second a feature request for this. Lack of this feature is a deal breaker for me.
Well it might turn out that your users have different use cases than you can imagine. In my case, I want to show structured complex data in each cell (lists of strings => newline separated strings, JSON => pretty-printed JSON). You might want to put a disclaimer at the top of the description that is this library is explicitly not intended for use cases where you want to show something more than single scalar value in a cell. |
Please contribute if this feature is important for you. |
Fair enough request. I notice myself sounding like an entitled internet person, sorry for that. In the mean time I've found a different library that does what I want, so I'm good :). Thanks for the response though. |
Ha, turns out I settled on |
Glad you found whats working for you though. |
I want to start a new line in a single cell, so I tried to add '\r\n' or '\n' at the end of the line. But it seems like it will be forbidden because of the regex test in validateData.js line 58:
/[\x01-\x1A]/.test(cell)
. So is there any way to have a new line?The text was updated successfully, but these errors were encountered: