From 92c84158677f30edb8872754d92832a35420952d Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 14 Aug 2013 16:56:14 +0200 Subject: Use python-ansi2html instead of cpan module Way, way, way, way faster. Did I mention it is faster? Also we now have line numbers because we can. Signed-off-by: Florian Pritz --- application/controllers/file.php | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'application/controllers/file.php') diff --git a/application/controllers/file.php b/application/controllers/file.php index 573d1a5b3..2d6a8ecc4 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -165,24 +165,14 @@ class File extends CI_Controller { echo ''."\n"; passthru('perl '.FCPATH.'scripts/Markdown.pl '.escapeshellarg($file), $cached["return_value"]); - $cached["output"] = ob_get_contents(); - ob_end_clean(); - } elseif ($lexer == "ascii") { - ob_start(); - - echo ''; - echo '
'."\n";
-				passthru('perl '.FCPATH.'scripts/ansi2html '.escapeshellarg($file), $cached["return_value"]);
-				echo "
\n"; - $cached["output"] = ob_get_contents(); ob_end_clean(); } else { - $cached = $this->_pygmentize($file, $lexer); + $cached = $this->_colorify($file, $lexer); } if ($cached["return_value"] != 0) { - $ret = $this->_pygmentize($file, "text"); + $ret = $this->_colorify($file, "text"); $cached["output"] = $ret["output"]; } $this->memcachelibrary->set($filedata['hash'].'_'.$lexer, $cached, 100); @@ -202,7 +192,7 @@ class File extends CI_Controller { echo $this->load->view($this->var->view_dir.'/html_footer', $this->data, true); } - private function _pygmentize($file, $lexer) + private function _colorify($file, $lexer) { $return_value = 0; $output = ""; @@ -211,7 +201,11 @@ class File extends CI_Controller { $output .= '
'."\n";
 
 		ob_start();
-		passthru('pygmentize -F codetagify -O encoding=guess,outencoding=utf8,stripnl=False -l '.escapeshellarg($lexer).' -f html '.escapeshellarg($file), $return_value);
+		if ($lexer == "ascii") {
+			passthru('ansi2html -p < '.escapeshellarg($file), $return_value);
+		} else {
+			passthru('pygmentize -F codetagify -O encoding=guess,outencoding=utf8,stripnl=False -l '.escapeshellarg($lexer).' -f html '.escapeshellarg($file), $return_value);
+		}
 		$buf = ob_get_contents();
 		ob_end_clean();
 
-- 
cgit v1.2.3-24-g4f1b