vrana Thu Dec 11 04:14:57 2003 EDT
Modified files:
/phpdoc/scripts html_syntax.php
/phpdoc Makefile.in
Log:
Syntax highlight examples
Index: phpdoc/scripts/html_syntax.php
diff -u phpdoc/scripts/html_syntax.php:1.2 phpdoc/scripts/html_syntax.php:1.3
--- phpdoc/scripts/html_syntax.php:1.2 Wed Dec 10 16:30:03 2003
+++ phpdoc/scripts/html_syntax.php Thu Dec 11 04:14:56 2003
@@ -1,12 +1,16 @@
#!/usr/bin/php -q
<?php
+/*
+There are no restrictions on this file.
+Author: Jakub Vr�na <[EMAIL PROTECTED]>
+*/
if ($_SERVER["argc"] < 3) {
exit("Purpose: Syntax highlight PHP examples in DSSSL generated HTML manual.\n"
.'Usage: html_syntax.php [ "html" | "php" ] [ filename.ext | dir |
wildcard ] ...' ."\n"
- .'"html" - highlight_string() is used, "php" - highlight_php() is
called' ."\n"
+ .'"html" - highlight_string() is applied, "php" - highlight_php() is
added' ."\n"
);
}
-set_time_limit(60*60); // can run long, but not more than 1 hour
+set_time_limit(5*60); // can run long, but not more than 5 minutes
function callback_html_number_entities_decode($matches) {
return chr($matches[1]);
@@ -28,19 +32,23 @@
if (is_file($file)) {
$process = array($file);
} elseif (is_dir($file)) {
- $process = glob(realpath($file) ."/*"); // realpath only for stripping
slash from the end
+ $lastchar = substr($file, -1);
+ $process = glob($file . ($lastchar == "/" || $lastchar == "\\" ? "*" :
"/*"));
} else { // should be wildcard
$process = glob($file);
}
- foreach ($process as $val) {
- echo "$val\n";
- $original = file_get_contents($val);
+ foreach ($process as $filename) {
+ if (!is_file($filename)) { // do not recurse
+ continue;
+ }
+ //~ echo "$filename\n";
+ $original = file_get_contents($filename);
$highlighted =
preg_replace_callback("!<PRE\r?\nCLASS=\"php\"\r?\n>(.*)</PRE\r?\n>!sU",
"callback_highlight_php", $original);
if ($original != $highlighted) {
- // file_put_contents is in PHP >= 5
- $fp = fopen($val, "wb");
- fwrite($fp, $highlighted);
- fclose($fp);
+ // file_put_contents is only in PHP >= 5
+ $fp = fopen($filename, "wb");
+ fwrite($fp, $highlighted);
+ fclose($fp);
}
}
}
Index: phpdoc/Makefile.in
diff -u phpdoc/Makefile.in:1.139 phpdoc/Makefile.in:1.140
--- phpdoc/Makefile.in:1.139 Sun Oct 12 08:11:36 2003
+++ phpdoc/Makefile.in Thu Dec 11 04:14:57 2003
@@ -13,7 +13,7 @@
#
#
-# $Id: Makefile.in,v 1.139 2003/10/12 12:11:36 goba Exp $
+# $Id: Makefile.in,v 1.140 2003/12/11 09:14:57 vrana Exp $
#
all: html
@@ -163,6 +163,7 @@
@test -d html || mkdir html
$(PHP) -q $(scriptdir)/rtlpatch/hackmanuallang.php $(LANGDIR)
$(JADE) $(CATALOG) -d $(HTML_STYLESHEET) -V use-output-dir -t sgml $(XMLDCL)
manual.xml
+ $(PHP) -q $(scriptdir)/html_syntax.php html html/
$(PHP) -q $(scriptdir)/rtlpatch/hackmanuallang.php en
$(HACK_RTL_LANGS_PAGES)
@@ -191,6 +192,7 @@
@test -d php || mkdir php
$(PHP) -q $(scriptdir)/rtlpatch/hackmanuallang.php $(LANGDIR)
-$(JADE) $(CATALOG) -d $(PHPWEB_STYLESHEET) -V use-output-dir -t sgml
$(XMLDCL) manual.xml
+ $(PHP) -q $(scriptdir)/html_syntax.php php php/
$(PHP) -q $(scriptdir)/rtlpatch/hackmanuallang.php en
$(PHP) -q $(scriptdir)/phpweb-entities.php `pwd` remove
$(HACK_RTL_LANGS_PHPWEB)