From 2b8b6417794adc3d6bcf7eebc57251c79b1fef6c Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Sat, 12 Jul 2003 20:17:22 +0000 Subject: [PATCH] Added preliminary (ugly) syntax highlight for HTML and XBF files throw GNU Enscript. --- index.php | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index e888743..b1dfc03 100644 --- a/index.php +++ b/index.php @@ -49,8 +49,15 @@ if (@$_SERVER['PATH_INFO']) { if (@$_REQUEST['S']) { if (@$_REQUEST['B']) { // We want to see the BIFE file source. - echo '
';
-        echo htmlentities(join('', file($file)));
+        exec('enscript -q -p - -Ehtml --language=html --color '
+            . escapeshellarg($file), $buffer);
+        $buffer = join("\n", $buffer);
+        $buffer = strstr($buffer, '
');
+        $buffer = substr($buffer, 0, strpos($buffer, '
')); + $buffer = str_replace(array(''), $buffer); + echo $buffer; + #echo htmlentities(join('', file($file))); } else { // We want to see the php file source. highlight_file($_SERVER['SCRIPT_FILENAME']); @@ -64,7 +71,24 @@ $template =& new HTML_Template_HIT('templates'); $parser =& new BIFE_Parser('BIFE_Translate'); $page =& $parser->parseFile($file); $parser->__destruct(); -echo $page->render($template); +// We now see if we want to show the HTML output +if (@$_REQUEST['H']) { + $f = fopen("$file.tmp.html", 'w'); + fputs($f, $page->render($template)); + fclose($f); + exec('enscript -q -p - -Ehtml --language=html --color ' + . escapeshellarg("$file.tmp.html"), $buffer); + unlink("$file.tmp.html"); + $buffer = join("\n", $buffer); + $buffer = strstr($buffer, '
');
+        $buffer = substr($buffer, 0, strpos($buffer, '
')); + $buffer = str_replace(array(''), $buffer); + echo $buffer; + //echo '
' . htmlentities($page->render($template)) . '
'; +} else { + echo $page->render($template); +} // }}} ?> -- 2.43.0