Truncate HTML output to a safe length