truncate a html string without messing up tags