summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-08-22 19:40:38 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-08-22 19:40:38 +0200
commit923e38b9fd6b04b871125b3feecbc62a4204a464 (patch)
treedf844f53dc6855f1b37a6b421479ded2506d6cc8 /application
parentd87e4e2881d4cfa17dfd0445fae1fa881d5707c0 (diff)
Remove empty line after ansi2html
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application')
-rw-r--r--application/controllers/file.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index 25e283e4b..ef2e87084 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -173,6 +173,7 @@ class File extends MY_Controller {
{
$return_value = 0;
$output = "";
+ $lines_to_remove = 0;
$output .= '<div class="code content table">'."\n";
$output .= '<div class="highlight"><pre>'."\n";
@@ -180,8 +181,12 @@ class File extends MY_Controller {
ob_start();
if ($lexer == "ascii") {
passthru('ansi2html -p < '.escapeshellarg($file), $return_value);
+ // Last line is empty
+ $lines_to_remove = 1;
} else {
passthru('pygmentize -F codetagify -O encoding=guess,outencoding=utf8,stripnl=False -l '.escapeshellarg($lexer).' -f html '.escapeshellarg($file), $return_value);
+ // Last 2 items are "</pre></div>" and ""
+ $lines_to_remove = 2;
}
$buf = ob_get_contents();
ob_end_clean();
@@ -190,10 +195,9 @@ class File extends MY_Controller {
$buf = explode("\n", $buf);
$line_count = count($buf);
- // Last 2 items are just "</pre></div>" and ""
- // We don't need those
- unset($buf[$line_count - 2]);
- unset($buf[$line_count - 1]);
+ for ($i = 1; $i <= $lines_to_remove; $i++) {
+ unset($buf[$line_count - $i]);
+ }
foreach ($buf as $key => $line) {
$line_number = $key + 1;