Repository navigation
Introduce UAX #14 Line breaking into wrap() - #322
Conversation
Merging this PR will improve performance by ×3.33 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #322 +/- ##
==========================================
+ Coverage 88.74% 90.07% +1.32%
==========================================
Files 41 44 +3
Lines 5677 6447 +770
Branches 1526 1810 +284
==========================================
+ Hits 5038 5807 +769
+ Misses 254 241 -13
- Partials 385 399 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
f4ec14e to
614a8cf
Compare
It seems only proper, as a unicode library, that our
wrap()functions implement the UAX #14 line breaking algorithm.This is on by default, with new default wrap(..., line_break='unicode') argument. Use line_break='ascii' to match original std python behavior.
UAX #14 is often criticized for its complexity, which can be seen through our implementation, and that some of the special unicode points like SOFT HYPHEN are very infrequently implemented correctly in text viewers, editors, etc., that it usually "stuffs up" rather than helps, these are sometimes used in web content, and people can sometimes copy and paste them into files and terminals where they are hidden (zero width) with sometimes strange or disastrous effects, or UnicodeDecodeError, for what appears to the human eye to contain only ASCII.
These codes have provided a lot of folks a lot of grief. Only to say, this might induce surprising word wrap behavior to downstream users because of these strange unicode codepoints, many people are unaware of their presence