Add an option to preserve the input space characters
This potentially changes the output in two ways:
-
We now match (on line 107) any space character rather than just a tab or a space. The test case as it stands continues to pass, and the output remains separated by space characters.
-
There’s a new boolean parameter called
preserve_space_charactersthat changes the output to use the space characters that were passed in. This is more accurate, but an obvious change to the existing behaviour hence the gating behind a default-Falseparameter.
I’ve also included a couple of commits here that tidy up comment mistakes found when I was initially going through the code.
While I see your point re preserving existing behavior, my instinct is that preserving specialty spaces in the input string would actually be the better default behavior — if source text used a special space character, it was likely for good reason.
I suspect this isn't the only change of this flavor that will come in the larger list of improvements from your other issue. I'd be inclined to shift towards 'better defaults' and pushing a new major release once everything is merged.
I looks like all the test cases check the 'strip special spaces' mode; can you add test cases for both sides of that flag?
I think the extra test cases, and inverting the default behavior, and this should be good to go!
Pushed up an inversion to make this the default behaviour with an opt-out switch. I think the new tests were testing everything already (there are two assertEquals per test) but let me know if you want any other tests.