', highlight_file($info->file, TRUE));
end($source);
$numWidth = strlen((string) key($source));
unset($prevColor);
$tags = '';
foreach ($source as $n => $line) {
if (isset($info->lines[$n + 1]) && isset($classes[$info->lines[$n + 1]])) {
$color = $classes[$info->lines[$n + 1]];
} else {
$color = ''; // not executable
}
if (!isset($prevColor)) {
$prevColor = $color;
}
$line = sprintf("
%{$numWidth}s: ", $n + 1) . $line;
if ($prevColor !== $color || $n === count($source) - 1) {
echo '
', str_replace(' />', '>', $tags);
$openTags = array();
preg_match_all('#<([^>]+)#', $tags, $matches);
foreach ($matches[1] as $m) {
if ($m[0] === '/') {
array_pop($openTags);
} elseif (substr($m, -1) !== '/') {
$openTags[] = $m;
}
}
foreach (array_reverse($openTags) as $tag) {
echo '' . preg_replace('# .*#', '', $tag) . '>';
}
echo "
\n";
$tags = ($openTags ? '<' . implode('><', $openTags) . '>' : '');
$prevColor = $color;
}
$tags .= "$line
\n";
}
?>