arendjr/text-clipper

Invalid HTML error if the content contains special characters (<3)

Closed this issue · 2 comments

Hi there,
I tested with the content that contains the heart icon using "<3"
It shows error:
text-clipper.js?v=44260d94:173 Uncaught Error: Invalid HTML: the text <3 <3

0h9zieA

Do you have any idea for fixing this?

Thanks!

I was fixed this by pre-format the content before parse it to clipper.

Yeah, I would say this is by design, since "<3" should be encoded as &lt;3 to be valid HTML. I suppose things could be made a bit more resilient by implementing the fallbacks that HTML5 specifies for invalid HTML, but I'm afraid that would add a huge amount of complexity to the library.

So I'm closing since you found a workaround. Thanks for the report, it's indeed something to be aware of!