Discussion:
highlight_file suggestion
Jeffry Killen
2014-04-06 22:15:47 UTC
Permalink
Hello;

I have a suggestion for output from highlight_file(<file>, true);

I am trying to format the string for display in <pre> tags:

if((file_exists('php/runner.php') && $_done) || $_show)
{
print "<pre class=\"norm\">\n".$_showStr."</pre>\n";
$_lines = highlight_file('php/runner.php', true);
$_lines = str_replace("<code>", "<code>\n", $_lines);
$_lines = str_replace("&nbsp;", " ", $_lines);
$_lines = str_replace("<br /></span>", "</span><br />", $_lines);
$_linesRed = explode("\n", $_lines);
$_lineNum = explode('<br />', $_linesRed[2]);
$_display = $_linesRed[0].$_linesRed[1]."\n";
for($_itr = 0; $_itr < count($_lineNum); $_itr++)
{
$_display .= $_itr." ".$_lineNum[$_itr]."\n";
}
$_display .= $_linesRed[3].$_linesRed[4];
print "\n<pre>\n".$_display."</pre>\n";
}

which produces (browser view source )
I have to include a unix formated plain text file
because the e-mail client will not preserver the formatting
so you can see what I am talking about:

Loading...