cvs: phpdoc /chm common.php make_chm_fancy.php
| From: | Moriyoshi Koizumi | Date: | Mon, 12 May 2003 02:46:12 +0000 |
| Subject: | cvs: phpdoc /chm common.php make_chm_fancy.php | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969353366@lists.php.net to get a copy of this message | ||
moriyoshi Sun May 11 22:46:12 2003 EDT
Modified files:
/phpdoc/chm common.php make_chm_fancy.php
Log:
Oops! oneLine() crops too many CRLFs, even in sample codes.
Sorry Derick for the incomplete patch.
Index: phpdoc/chm/common.php
diff -u phpdoc/chm/common.php:1.1 phpdoc/chm/common.php:1.2
--- phpdoc/chm/common.php:1.1 Sun May 11 16:00:23 2003
+++ phpdoc/chm/common.php Sun May 11 22:46:12 2003
@@ -18,11 +18,15 @@
}
// Return a file joined on one line
-function oneLiner($filename)
+function oneLiner($filename, $only_tags = false)
{
global $INTERNAL_CHARSET;
- $buf = preg_replace("/[\r|\n]{1,2}/U", " ", file_get_contents($filename));
+ if ($only_tags) {
+ $buf = preg_replace("/<([a-zA-Z]+)(>|[^>]*>)>/Ue",
"preg_replace('/[\r\n]{1,2}/U', ' ', \"<\$1 \$2\")",
file_get_contents($filename));
+ } else {
+ $buf = preg_replace("/[\r|\n]{1,2}/U", " ",
file_get_contents($filename));
+ }
$charset = detectDocumentCharset($buf);
if ($charset === false) $charset = "UTF-8";
Index: phpdoc/chm/make_chm_fancy.php
diff -u phpdoc/chm/make_chm_fancy.php:1.6 phpdoc/chm/make_chm_fancy.php:1.7
--- phpdoc/chm/make_chm_fancy.php:1.6 Sun May 11 16:00:23 2003
+++ phpdoc/chm/make_chm_fancy.php Sun May 11 22:46:12 2003
@@ -29,10 +29,10 @@
closedir($handle);
// Look for CHM index file (snap-downloader, cvs-usr with/without lang-support)
-if (false == ($content = oneLiner("make_chm_index_$LANGUAGE.html"))) {
- if (false == ($content = oneLiner("$LANGUAGE/make_chm_index_$LANGUAGE.html"))) {
- if (false == ($content =
oneLiner("$HTML_PATH/../$LANGUAGE/make_chm_index_$LANGUAGE.html"))) {
- $content = oneLiner("en/make_chm_index_en.html");
+if (false == ($content = oneLiner("make_chm_index_$LANGUAGE.html", true))) {
+ if (false == ($content = oneLiner("$LANGUAGE/make_chm_index_$LANGUAGE.html", true)))
{
+ if (false == ($content =
oneLiner("$HTML_PATH/../$LANGUAGE/make_chm_index_$LANGUAGE.html", true))) {
+ $content = oneLiner("en/make_chm_index_en.html", true);
}
}
}
@@ -64,7 +64,7 @@
global $HTML_PATH, $FANCY_PATH, $LANGUAGE, $LANGUAGES, $counter, $original_index,
$publication_date;
// Get the contents of the file from $HTML_PATH
- $content = oneLiner("$HTML_PATH/$fname");
+ $content = oneLiner("$HTML_PATH/$fname", true);
// CSS file linking
$content = preg_replace("|</HEAD|", '<LINK REL="stylesheet"
HREF="style.css"></HEAD', $content);
@@ -82,41 +82,41 @@
$space = '<IMG SRC="spacer.gif" WIDTH="10"
HEIGHT="1">';
// Navheader backgound
- $content =
preg_replace("/<DIV\\s+CLASS=\"NAVHEADER\"\\s+><TABLE(.*)CELLPADDING=\"0\"(.*)<\\/TABLE\\s+><\\/DIV\\s+>/Us",
+ $content =
preg_replace("/<DIV\\s+CLASS=\"NAVHEADER\"\\s*><TABLE(.*)CELLPADDING=\"0\"(.*)<\\/TABLE\\s*><\\/DIV\\s*>/Us",
$wpbegin . '<DIV CLASS="NAVHEADER">' . $bnavt .
'<TR><TD><TABLE\\1CELLPADDING="3"\\2</TABLE></TD></TR>'
. $lnavt . '</TABLE></DIV></TD></TR><TR><TD>' . $space
. '</TD><TD HEIGHT="100%" VALIGN="TOP"
WIDTH="100%"><BR>', $content);
// Navfooter backgound
- $content =
preg_replace("/<DIV\\s+CLASS=\"NAVFOOTER\"\\s+><TABLE(.*)CELLPADDING=\"0\"(.*)<\\/TABLE\\s+><\\/DIV\\s+>/Us",
+ $content =
preg_replace("/<DIV\\s+CLASS=\"NAVFOOTER\"\\s*><TABLE(.*)CELLPADDING=\"0\"(.*)<\\/TABLE\\s*><\\/DIV\\s*>/Us",
'<BR></TD><TD>' . $space .
'</TD></TR><TR><TD COLSPAN="3"><DIV
CLASS="NAVFOOTER">' . $bnavt . $lnavt .
'<TR><TD><TABLE\\1CELLPADDING="3"\\2</TABLE></TD></TR></TABLE></DIV></TD></TR></TABLE>',
$content);
// Fix copyright page fault...
if ($fname == "copyright.html") {
$content = preg_replace("/&copy;/", "©", $content);
$content =
preg_replace("/<A\\s+HREF=\"$original_index#(authors|translators)\"/U",
"<A HREF=\"fancy-index.html\"", $content);
- $content = preg_replace("|(</TH\\s+></TR\\s+>)|",
"\\1<TR><TH COLSPAN=\"3\"
ALIGN=\"center\"> </TH></TR>", $content);
- $content = preg_replace("|( </TD\\s+></TR\\s+>)|",
"\\1<TR><TD COLSPAN=\"3\"
ALIGN=\"center\"> </TD></TR>", $content);
+ $content = preg_replace("|(</TH\\s*></TR\\s*>)|",
"\\1<TR><TH COLSPAN=\"3\"
ALIGN=\"center\"> </TH></TR>", $content);
+ $content = preg_replace("|( </TD\\s*></TR\\s*>)|",
"\\1<TR><TD COLSPAN=\"3\"
ALIGN=\"center\"> </TD></TR>", $content);
}
// Fix the original manual index to look far better...
elseif ($fname == "$original_index") {
// Find out manual generation date
- if
(preg_match('|<P\s+CLASS="pubdate"\s+>([\\d-]+)<BR></P\s+>|U',
$content, $match)) {
+ if
(preg_match('|<P\s+CLASS="pubdate"\s*>([\\d-]+)<BR></P\s*>|U',
$content, $match)) {
$publication_date = $match[1];
} else {
$publication_date = 'n/a';
}
// Modify the index file to meet our needs
-
preg_match('|CLASS=\"title\"\\s+><A\\s+NAME=\"manual\"\\s+>(.*)</A\\s+>(.*)</H1|U',
$content, $match);
+
preg_match('|CLASS=\"title\"\\s*><A\\s+NAME=\"manual\"\\s*>(.*)</A\\s*>(.*)</H1|U',
$content, $match);
$indexchange = '<TABLE BORDER="0" WIDTH="100%"
HEIGHT="100%" CELLSPACING="0" CELLPADDING="0"><TR><TD
COLSPAN="3"><DIV CLASS="NAVHEADER"><TABLE
BGCOLOR="#CCCCFF" BORDER="0" CELLPADDING="0" CELLSPACING="0"
WIDTH="100%"><TR><TD><TABLE
WIDTH="100%" BORDER="0" CELLPADDING="3"
CELLSPACING="0"><TR><TH
COLSPAN="3">'.$match[2].'</TH></TR><TR><TD
COLSPAN="3"
ALIGN="center"> </TD></TR></TABLE></TD></TR><TR
BGCOLOR="#333366"><TD><IMG SRC="spacer.gif" BORDER="0"
WIDTH="1" HEIGHT="1"><BR></TD></TR></TABLE>
</DIV></TD></TR><TR><TD><IMG SRC="spacer.gif"
WIDTH="10" HEIGHT="1"></TD><TD HEIGHT="100%"
VALIGN="TOP" WIDTH="100%"><BR>';
$content = preg_replace("/(<DIV\\s+CLASS=\"BOOK\")/",
"$indexchange\\1", $content);
$content =
preg_replace("/(<DIV\\s+CLASS=\"author\").*<HR>/Us", "",
$content);
-
preg_match('|<DIV\\s+CLASS="TOC"\\s+><DL\\s+><DT\\s+><B\\s+>(.*)</B\\s+>|U',
$content, $match);
- $content =
preg_replace("|(CLASS=\"title\"\\s+><A\\s+NAME=\"manual\"\\s+>).*(</A\\s+>).*(</H1)|U",
"\\1$match[1]\\2\\3", $content);
- $content =
preg_replace("|<DT\\s+><B\\s+>(.*)</B\\s+></DT\\s+>|U",
"", $content);
+
preg_match('|<DIV\\s+CLASS="TOC"\\s*><DL\\s*><DT\\s*><B\\s*>(.*)</B\\s*>|U',
$content, $match);
+ $content =
preg_replace("|(CLASS=\"title\"\\s+><A\\s+NAME=\"manual\"\\s*>).*(</A\\s*>).*(</H1)|U",
"\\1$match[1]\\2\\3", $content);
+ $content =
preg_replace("|<DT\\s*><B\\s*>(.*)</B\\s*></DT\\s*>|U",
"", $content);
}