Fix split when a nbsp character is present#1073
Fix split when a nbsp character is present#1073simonbengtsson merged 3 commits intosimonbengtsson:masterfrom
Conversation
|
How times do I need to unsubscribe from this website, thread and
conversation?
Thanks
…On Mon, 14 Oct 2024, 3:38 pm Frederic Tregon, ***@***.***> wrote:
When computing the minReadableWidth of a cell, the code does not account
for non-breaking space characters (also known as nbsp or \u00A0).
nbsp characters should be treated as non-space characters when calculating
the string length, as this is the intended function of such characters.
Failing to do so results in suboptimal output, particularly for languages
like French, where punctuation marks such as colons (:) are always preceded
by a space and should remain on the same line as the preceding word.
This PR fixes that issue.
------------------------------
You can view, comment on, or merge this pull request online at:
#1073
Commit Summary
- 5657768
<5657768>
fix(split): when computing longest word, nbsp should be considered a
character
File Changes
(1 file
<https://github.com/simonbengtsson/jsPDF-AutoTable/pull/1073/files>)
- *M* src/widthCalculator.ts
<https://github.com/simonbengtsson/jsPDF-AutoTable/pull/1073/files#diff-0aff2bfd71ecbb850b40ffe226854fd5421dc8aec1515a784c8d76e48e153f9a>
(2)
Patch Links:
- https://github.com/simonbengtsson/jsPDF-AutoTable/pull/1073.patch
- https://github.com/simonbengtsson/jsPDF-AutoTable/pull/1073.diff
—
Reply to this email directly, view it on GitHub
<#1073>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADSU6DPBFLPVETFACP7TYDDZ3OJ23AVCNFSM6AAAAABP4UOYXGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU4DKNJQHA2DOMY>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
Interesting! Based on my very limited understanding shouldn't a cell with the content |
|
This is exactly the goal of this fix, the French would be pre-processed as |
|
Got it! I thought since \s does not match non breaking spaces as far as I understand it would work with this. But I'll try it tomorrow considering you have experienced issues with it. |
I do not know about that, I did the following on the Chrome console: So it does split on |
|
You are right. I tried with a regex tester yesterday, but apparently incorrectly. Can you add a comment or a named variable for the regex? Then I'll merge promptly. |
|
Done! |
|
Thanks! Merged and released in v3.8.4 |
|
Thank you, and thanks for making it easy to contribute. |
When computing the
minReadableWidthof a cell, the code does not account for non-breaking space characters (also known asnbspor\u00A0).nbsp characters should be treated as non-space characters when calculating the string length, as this is the intended function of such characters.
Failing to do so results in suboptimal output, particularly for languages like French, where punctuation marks such as colons (:) are always preceded by a space and should remain on the same line as the preceding word.
This PR fixes that issue.