Event history: format script text and output correctly

 - Use <pre> instead of <code> to preserve line-endings
 - Use StringEscapeUtils.escapeHtml instead of StringUtil.htmlifyText to prevent XSS attacks