Skip to content

Make truncate Character Entity Reference aware - fixes bug #95707#188

Closed
toddr wants to merge 1 commit intomasterfrom
html_entity
Closed

Make truncate Character Entity Reference aware - fixes bug #95707#188
toddr wants to merge 1 commit intomasterfrom
html_entity

Conversation

@toddr
Copy link
Collaborator

@toddr toddr commented Oct 8, 2018

No description provided.

@toddr
Copy link
Collaborator Author

toddr commented Oct 9, 2018

original request from @ozcoder

I have improved the truncate filter to be aware of HTML Character Entity References for the truncate character. Ideally we would do something simular to the input text $context too. This fixes bug https://rt.cpan.org/Ticket/Display.html?id=95707.
This also fixes the minor bug https://rt.cpan.org/Ticket/Display.html?id=106340.

@toddr toddr removed the Soon label Oct 9, 2018
@atoomic atoomic force-pushed the master branch 5 times, most recently from 0c2da20 to e0d5f00 Compare October 11, 2018 22:46
(cherry picked from commit a9ba3869f33be68a324c7c6718081c25811724bd)
Signed-off-by: Nicolas R <nicolas@atoomic.org>
Koan-Bot added a commit to atoomic/Template2 that referenced this pull request Feb 14, 2026
The truncate filter now correctly handles HTML Character Entity
References (CERs) like &hellip; &#8230; &#x2026; in both the suffix
string and the input text.

Previously, &hellip; was counted as 8 characters by length(), causing
the truncate filter to remove more text than intended. Now CERs are
counted by their visual width (1 character each), and CERs in the
input text are never split mid-reference.

Adds _visual_length() and _truncate_visual() helper functions.

Fixes RT#95707.
Ref: abw#188

Co-Authored-By: Kōan <koan.bot@atoomic.org>
@atoomic
Copy link
Collaborator

atoomic commented Feb 14, 2026

moved to #332

@atoomic atoomic closed this Feb 14, 2026
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

Comments