}
$class = 'meta';
- $lines = array(0, 0);
+ $lines = array(0, 0);
$first = false;
$in_meta = false;
$lines[1]++;
}
+
if ($in_meta) {
$class = 'meta';
}
+ $cls = $class;
-
- $row = "<tr class='$class";
if ($first) {
- $row .= ' first';
- }
+ $cls .= ' first';
+ } else
if ($class != 'meta' && $first) {
$first = false;
}
- $row .= "'>";
+
$anchor = $abase . '.' . $nlines;
- $anchor_row = "<td class='linelink'><a name='$anchor'></a>".
- "<a href='#$anchor' title='link to this line'>#</a></td>";
-
- $txt_data = '<td class="line" width="100%">'.
- htmlspecialchars(substr($line, 1), ENT_QUOTES, 'utf-8') .
- "</td></tr>\n";
-
-
-
- switch ($class) {
-
- case 'meta':
- $row .= '<td colspan="4" class="line" width="100%">' .
- htmlspecialchars($line, ENT_QUOTES, 'utf-8') . "</td></tr>\n";
- $html .= $row;
- break;
+ $add = (object)array(
- case 'added':
- $row .= "<td class='lineno'></td><td class='lineno'>" .
- $lines[1] . "</td>" .
- $anchor_row . $txt_data ;
- $html .= $row;
-
- break;
-
- case 'removed':
- $row .= "<td class='lineno'>" . $lines[0] .
- "</td><td class='lineno'></td>" .
- $anchor_row . $txt_data ;
- $html .= $row;
-
- break;
-
- default:
- $row .= "<td class='lineno'>" . $lines[0] .
- "</td><td class='lineno'>" . $lines[1] . "</td>" .
- $anchor_row . $txt_data ;
- $html .= $row;
- }
+ 'line' => $class == 'meta' ? $line : substr($line, 1),
+ 'meta' => $class == 'meta',
+ 'cls' => $cls,
+ 'anchor' => $class == 'meta' ? $anchor : false
+ );
+
+ $add->$class = true;
+ $ret[] = $add;
if (!count($input)) {
}
if ($nlines == 0) {
- return null;
+ return null;
}
- $html .= "</table>";
- return $html;
+ return $ret;
}
}