vrana Wed Dec 10 16:30:04 2003 EDT
Modified files:
/phpdoc/scripts html_syntax.php
Log:
Parameter to set output for HTML or PHP
Index: phpdoc/scripts/html_syntax.php
diff -u phpdoc/scripts/html_syntax.php:1.1 phpdoc/scripts/html_syntax.php:1.2
--- phpdoc/scripts/html_syntax.php:1.1 Wed Dec 10 05:55:49 2003
+++ phpdoc/scripts/html_syntax.php Wed Dec 10 16:30:03 2003
@@ -1,26 +1,29 @@
#!/usr/bin/php -q
<?php
-if ($_SERVER["argc"] < 2) {
+if ($_SERVER["argc"] < 3) {
exit("Purpose: Syntax highlight PHP examples in DSSSL generated HTML manual.\n"
- ."Usage: html_syntax.php [ filename.ext | dir | wildcard ] ...\n"
+ .'Usage: html_syntax.php [ "html" | "php" ] [ filename.ext | dir |
wildcard ] ...' ."\n"
+ .'"html" - highlight_string() is used, "php" - highlight_php() is
called' ."\n"
);
}
set_time_limit(60*60); // can run long, but not more than 1 hour
-//~ include dirname(__FILE__) ."/layout.inc"; // we need highlight_php function from
/phpweb/include/layout.inc
-
function callback_html_number_entities_decode($matches) {
return chr($matches[1]);
}
function callback_highlight_php($matches) {
$with_tags = preg_replace_callback("!&#([0-9]+);!",
"callback_html_number_entities_decode", $matches[1]);
- return highlight_string($with_tags, true);
- //~ return highlight_php($with_tags, true);
+ if ($GLOBALS["TYPE"] == "php") {
+ return "\n<?php\nhighlight_php('". addcslashes($with_tags, "'\\")
."');\n?>\n";
+ } else { // "html"
+ return highlight_string($with_tags, true);
+ }
}
$files = $_SERVER["argv"];
array_shift($files); // $argv[0] - script filename
+$TYPE = array_shift($files); // "html" or "php"
while (($file = array_shift($files)) !== null) {
if (is_file($file)) {
$process = array($file);