Hi.
I've built a CHM file using the new styling.
It is a bit of a hack as rather than just a single CSS file, 3 are
required and also an additional class attribute.
The css class "docs" is not known in the CHM html files.
I've set that on <body class="docs"> and that seems to be good.
It seems IE is making a right pig of the new styling at the moment,
though in the CHM reader, things look quite good.
>From what I can see, alternate row colouring and last column styling
is unsupported by IE in the current form (just using CSS).
Richard.
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
Index: phpdotnet/phd/Package/PHP/CHM.php
===================================================================
--- phpdotnet/phd/Package/PHP/CHM.php (revision 307074)
+++ phpdotnet/phd/Package/PHP/CHM.php (working copy)
@@ -238,7 +238,12 @@
$this->hhcStream = fopen($this->chmdir . "php_manual_{$lang}.hhc",
"w");
$this->hhkStream = fopen($this->chmdir . "php_manual_{$lang}.hhk",
"w");
- file_put_contents($this->outputdir . "style.css",
$this->fetchStylesheet() . PHP_EOL . 'body { padding : 3px;}');
+ file_put_contents($this->outputdir . "style.css",
+ $this->fetchStylesheet('reset.css') . PHP_EOL .
+ $this->fetchStylesheet('theme.css') . PHP_EOL .
+ $this->fetchStylesheet('doc.css') . PHP_EOL .
+ 'body { padding : 3px;}'
+ );
self::headerChm();
break;
@@ -391,11 +396,16 @@
public function header($id) {
$header = parent::header($id);
- // Add CSS link to <head>
- $pattern = '/(.*)(\r|\n|\r\n|\n\r)(.*)<\/head>/';
- $replacement = '$1 <link media="all" rel="stylesheet" type="text/css"
href="style.css"/>$2$3</head>';
-
- $header = preg_replace($pattern, $replacement, $header);
+
+ $patterns = array(
+ '/(.*)(\r|\n|\r\n|\n\r)(.*)<\/head>/', // Add CSS link to <head>
+ '/(<body)/', // Add 'docs' class to body.
+ );
+ $replacements = array(
+ '$1 <link media="all" rel="stylesheet" type="text/css"
href="style.css"/>$2$3</head>',
+ '$1 class="docs"',
+ );
+ $header = preg_replace($patterns, $replacements, $header);
return $header;
}
@@ -412,8 +422,11 @@
}
protected function fetchStylesheet($name = null) {
- $stylesheet = file_get_contents("http://www.php.net/styles/site.css");
- if ($stylesheet) return $stylesheet;
+ $stylesheet = file_get_contents("http://www.php.net/styles/" .
(is_null($name) ? "site.css" : $name));
+ if ($stylesheet) {
+ v("Loaded $name stylesheet.", VERBOSE_MESSAGES);
+ return $stylesheet;
+ }
else {
v("Stylesheet not fetched. Uses default rendering style.",
E_USER_WARNING);
return "";