-
Notifications
You must be signed in to change notification settings - Fork 1
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
Split without word-breaking #1
Comments
Hi @alexthekid07 No worries, it's not been touched but actively used, it does what it says on the tin (so far). |
@janpieterz SplitWithWordWrap sounds like it would work perfectly fine. The only oddball scenario I see with my request is if someone tries to split an elongated URL like this where word-wrap couldn't come into play: I assume that could be taken care by my ignoring word wrap on strings with a length greater than 1 message length... Also to my knowledge there aren't any other .NET libraries here on GitHub that offer this, hence why I was poking around to see if it was doable 👍 |
Interesting use case example as well. |
If you go with SplitWithWordWrap() it might make sense to just have an optional boolean parameter to decide whether or not to throw an exception if the string can't be split. If we keep following my example of how to handle a long URL (not that anyone should be texting that long of a URL), I suppose the individual "word" would have to be evaluated to determine if it could be split, not just the overall message itself. Imagine if your string was: If you tried to push the URL to a new part, the Part #1 would end up only "Hello how are you" and Part #2 would end up the entire URL, or even split into a Part #3. I think ideally in that scenario, it would be better to use this libraries existing/default implementation, where Part #1 = "Hello how are you" + the first chunk of the URL, and Part #2 = the second chunk of the URL. Just because the URL would be too long to fit into a single message. Even despite that, however, I'd still want it to "try" to word-wrap if the URL was small enough to fit into a single text. For example:
Despite the long URL, it fits in one message, but "antidisestablishmentarianism" gets cut in half into a second message, where ideally Part #1 = URL, Part #2 = "antidisestablishmentarianism" Hopefully I didn't make that sound too convoluted |
That makes total sense. Not sure about the boolean for throwing an exception, I'd almost want there to be a WordWrap parameter with different settings, maybe one original one (like it currently does), one where it simply cuts it off into two/three, one where it throws if it can't fit a whole section into one part etc. This way new settings can be created. We'll have to, obviously, add some unit tests for these too. |
I know this may be out of nowhere and this hasn't been touched in a couple years, but is there any easy way to modify this to optionally not break up words (or URLs) unless it has to?
The text was updated successfully, but these errors were encountered: