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

widont() function breaking links and files in last word of a paragraph #7074

Open
noegogniat opened this issue Mar 18, 2025 · 0 comments
Open

Comments

@noegogniat
Copy link

Description

Using the widont() function on a textarea / writer field with a link (url, file, email) inserts a   HTML entity within the tag and breaks it.

Expected behavior
The widont() function should only replace the last rendered space with a non-breaking one.

Screenshots

Image Image

To reproduce

  1. Create a textarea or a writer field.
  2. Add a link / email address to the last word of the last paragraph. Or, to reproduce the file issue, add a file at the very end of the last paragraph.
  3. Render the field using widont().
  4.   entity breaks the last link, email, or file.

Your setup

Kirby CSM 4.6.1
PHP 8.4.5

Device, OS, browser, and version agnostic. The regular expression |(\S)\s(\S?)$|u used within the function itself (kirby/src/Toolkit/Str.php:1475) doesn't take HTML tags into account.

Additional context
More generally, the widont() function only prevents widows in the last paragraph of a field, with more lengthy text (textarea / writer), the function becomes obsolete.

@noegogniat noegogniat changed the title widont() function breaking widont() function breaking links and files in last word of a paragraph Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant