-
-
Notifications
You must be signed in to change notification settings - Fork 626
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
Fix split when a nbsp character is present #1073
Fix split when a nbsp character is present #1073
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
minReadableWidth
of a cell, the code does not account for non-breaking space characters (also known asnbsp
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.