truncates a html string without messing up the tags