Javascript truncate HTML text

Francisc picture Francisc · Sep 29, 2010 · Viewed 11.7k times · Source

Does JavaScript have a way of truncating HTML text without all the headaches of matching tags etc etc?

Thank you.

Answer

arendjr picture arendjr · Sep 28, 2016

I know this question is old, but I recently had the same problem. I wrote the following library, which truncates valid HTML safely: https://github.com/arendjr/text-clipper