-
Notifications
You must be signed in to change notification settings - Fork 45
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
Support not squeezing whitespace #28
Comments
Hi, I kind of stole your example and benchmarks. I hope that's ok, if not let me know. I can also add attribution if you would like. Haven't done that yet. Having the same benchmarks allows comparing performance and thus, unicode-wrap is 10 times slower than textwrap on my system. ps: currently there is no documentation... greets, |
Hey @najamelan -- feel free to use the code if you can, just make sure to keep the license and the copyright notices intact. For example, you should probably not put it under public domain since it is MIT licensed right now. I took a brief look at your crate and it seems you have built an algorithm that is much more fancy than what I did :-) So I can imagine it will be slower, but with the filters you can get overall better results. The points about respecting non-breaking spaces is great -- I should double check how they're handled by textwrap and fix any problems. |
With this option, whitespace between words can be significant. That is, whitespace added for alignment purposes can be kept in the output. This means that wrapping strings like -v: be very verbose and output lots of messages --foo: inject extra foos in the output --foobar: enable the foobar optimization (if possible) can end up looking like -v: be very verbose and output lots of messages --foo: inject extra foos in the output --foobar: enable the foobar optimization (if possible) Fixes #28. Related to clap-rs/clap#617.
We currently split the input string by whitespace and process the words one by one. This implies that we squeeze runs of whitespace to a single space.
We could instead have a mode where whitespace is significant and kept in the output. This would make it possible to wrap text like this line by line:
Lines that wrap would still line up somewhat:
In Python's textwrap this option is called
replace_whitespace
, but I think I'll call itsqueeze_whitespace
instead. The option should come in handy to support the output wanted in clap-rs/clap#617.The text was updated successfully, but these errors were encountered: