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

Option to prevent html entities in result #2

Closed
alcalyn opened this issue Oct 24, 2019 · 2 comments
Closed

Option to prevent html entities in result #2

alcalyn opened this issue Oct 24, 2019 · 2 comments
Assignees
Labels

Comments

@alcalyn
Copy link

alcalyn commented Oct 24, 2019

When displaying a truncated text from this library with Twig, it displaying html entities because Twig safely encodes &.

Actually I expected UTF-8 characters are returned as is:

truncateMarkup('<p>PHP éléphant</p>', 7)

Expected:

PHP élé...

Actually:

PHP &eacute;l&eacute;

I understand this makes sense, but there should be a way to disable html entities, i.e by calling html_entity_decode on truncated text before returning it (which is what we are currently doing on our side).

@mrcgrtz
Copy link
Owner

mrcgrtz commented Oct 24, 2019

Good point, I’ll take a look into it!

@mrcgrtz mrcgrtz self-assigned this Oct 24, 2019
@mrcgrtz mrcgrtz added the bug label Oct 24, 2019
mrcgrtz added a commit that referenced this issue Jun 26, 2020
mrcgrtz added a commit that referenced this issue Jun 26, 2020
@mrcgrtz
Copy link
Owner

mrcgrtz commented Jun 29, 2020

The latest version 3.0 handles UTF-8 characters (even Emoji) and does not convert them to entities.

I added some tests as well.

If you run into further problems feel free to re-open this issue.

@mrcgrtz mrcgrtz closed this as completed Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants