HTML tag-safe string truncation