Skip to content
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

Add an option to preserve the input space characters #97

Merged
merged 3 commits into from
Apr 6, 2024

Conversation

robinwhittleton
Copy link
Contributor

This potentially changes the output in two ways:

  1. 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.

  2. There’s a new boolean parameter called preserve_space_characters that 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-False parameter.

I’ve also included a couple of commits here that tidy up comment mistakes found when I was initially going through the code.

@ppannuto
Copy link
Owner

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!

We now match (on line 107) any space character rather than just a tab or a space. To make sure that a user can choose the older behaviour, we preserve that behind a new boolean parameter called `normalise_space_characters`.
@robinwhittleton
Copy link
Contributor Author

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.

Copy link
Owner

@ppannuto ppannuto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me — thank you!

@ppannuto ppannuto merged commit 42f43e2 into ppannuto:main Apr 6, 2024
24 of 25 checks passed
@robinwhittleton robinwhittleton deleted the nbsp-support branch April 16, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants