+ $out = <<<EOT
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr">
+<head>
+<title>HTML validation error</title>
+<style>
+.highlight { background-color: #ffc }
+li { white-space: pre }
+</style>
+</head>
+<body>
+<h1>HTML validation error</h1>
+<ul>
+EOT;
+
+ $error = strtok( $errors, "\n" );
+ $badLines = array();
+ while ( $error !== false ) {
+ if ( preg_match( '/^line (\d+)/', $error, $m ) ) {
+ $lineNum = intval( $m[1] );
+ $badLines[$lineNum] = true;
+ $out .= "<li><a href=\"#line-{$lineNum}\">" . htmlspecialchars( $error ) . "</a></li>\n";
+ }
+ $error = strtok( "\n" );
+ }
+
+ $out .= '</ul>';
+ $out .= '<pre>' . htmlspecialchars( $errors ) . '</pre>';
+ $out .= "<ol>\n";
+ $line = strtok( $s, "\n" );
+ $i = 1;
+ while ( $line !== false ) {
+ if ( isset( $badLines[$i] ) ) {
+ $out .= "<li class=\"highlight\" id=\"line-$i\">";
+ } else {
+ $out .= '<li>';
+ }
+ $out .= htmlspecialchars( $line ) . "</li>\n";
+ $line = strtok( "\n" );
+ $i++;
+ }
+ $out .= '</ol></body></html>';
+ return $out;
+}