cvs: phd(PHD_0_4) /include PhDHelper.class.php PhDHighlighter.class.php /themes/pear peartheme.php
| From: | Christian Weiske | Date: | Mon, 26 Jan 2009 21:32:44 +0000 |
| Subject: | cvs: phd(PHD_0_4) /include PhDHelper.class.php PhDHighlighter.class.php /themes/pear peartheme.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-3095@lists.php.net to get a copy of this message | ||
cweiske Mon Jan 26 21:32:44 2009 UTC
Modified files: (Branch: PHD_0_4)
/phd/include PhDHelper.class.php PhDHighlighter.class.php
/phd/themes/pear peartheme.php
Log:
Fix peartheme to not generate <pre> tags. that's task of the highlighter
(Thanks Laurent for the catch!)
http://cvs.php.net/viewvc.cgi/phd/include/PhDHelper.class.php?r1=1.9.2.1.2.2&r2=1.9.2.1.2.3&diff_format=u
Index: phd/include/PhDHelper.class.php
diff -u phd/include/PhDHelper.class.php:1.9.2.1.2.2 phd/include/PhDHelper.class.php:1.9.2.1.2.3
--- phd/include/PhDHelper.class.php:1.9.2.1.2.2 Sun Jan 25 19:59:04 2009
+++ phd/include/PhDHelper.class.php Mon Jan 26 21:32:44 2009
@@ -1,5 +1,5 @@
<?php
-/* $Id: PhDHelper.class.php,v 1.9.2.1.2.2 2009/01/25 19:59:04 cweiske Exp $ */
+/* $Id: PhDHelper.class.php,v 1.9.2.1.2.3 2009/01/26 21:32:44 cweiske Exp $ */
/**
* Base class for PhDTheme
@@ -204,10 +204,8 @@
*/
public function highlight($text, $role = 'php', $format = 'xhtml')
{
- global $OPTIONS;
-
if (!isset(self::$highlighters[$format])) {
- $class = $OPTIONS['highlighter'];
+ $class = $GLOBALS['OPTIONS']['highlighter'];
if (!class_exists($class, true)) {
if ($class == 'PhDHighlighter') {
http://cvs.php.net/viewvc.cgi/phd/include/PhDHighlighter.class.php?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: phd/include/PhDHighlighter.class.php
diff -u phd/include/PhDHighlighter.class.php:1.1.2.2 phd/include/PhDHighlighter.class.php:1.1.2.3
--- phd/include/PhDHighlighter.class.php:1.1.2.2 Mon Jan 26 08:54:57 2009
+++ phd/include/PhDHighlighter.class.php Mon Jan 26 21:32:44 2009
@@ -35,19 +35,21 @@
*/
public function highlight($text, $role, $format)
{
- if ($format == 'xhtml') {
- if ($role == 'php') {
- return highlight_string($text, 1);
- } else {
- return '<pre>'
- . htmlspecialchars($text, ENT_QUOTES, 'UTF-8')
- . '</pre>';
- }
+ if ($format != 'xhtml') {
+ return $text;
}
- return $text;
+ if ($role == 'php') {
+ return highlight_string($text, 1);
+ } else {
+ return '<pre class="'. ($role ? $role . 'code' :
'programlisting') .'">'
+ . htmlspecialchars($text, ENT_QUOTES, 'UTF-8')
+ . "</pre>\n";
+ }
+
+ return $retval;
}//public function highlight(..)
}
-?>
\ No newline at end of file
+?>
http://cvs.php.net/viewvc.cgi/phd/themes/pear/peartheme.php?r1=1.8.2.2.2.4&r2=1.8.2.2.2.5&diff_format=u
Index: phd/themes/pear/peartheme.php
diff -u phd/themes/pear/peartheme.php:1.8.2.2.2.4 phd/themes/pear/peartheme.php:1.8.2.2.2.5
--- phd/themes/pear/peartheme.php:1.8.2.2.2.4 Sun Jan 25 19:59:04 2009
+++ phd/themes/pear/peartheme.php Mon Jan 26 21:32:44 2009
@@ -558,6 +558,16 @@
$this->phd_pearapi_text = $value;
}
+ /**
+ * Format a <programlisting> tag.
+ * Highlighting an such is done in format_programlisting_text()
+ *
+ * @param string $value Value of the text to format.
+ * @param string $tag Tag name
+ * @param array $attrs Array of attributes
+ *
+ * @return string Generated programlisting html
+ */
public function format_programlisting($open, $name, $attrs)
{
if ($open) {
@@ -565,25 +575,29 @@
if (isset($attrs[PhDReader::XMLNS_DOCBOOK]['role'])) {
$this->role = $attrs[PhDReader::XMLNS_DOCBOOK]['role'];
} else {
- $this->role = 'default';
+ $this->role = '';
}
return $this->format->escapePara()
- . '<pre class="'. ($this->role ? $this->role :
'programlisting') .'" style="background-color:#EEE; width:
100%">';
+ . '<div class="'. ($this->role ? $this->role .
'code' : 'programlisting')
+ . '" style="background-color:#EEE; width: 100%">';
}
$this->role = false;
$this->trim = false;
- return "</pre>\n" . $this->format->restorePara();
+
+ return '</div>' . $this->format->restorePara();
}
/**
- * Format the text within a program listing section.
- *
- * @param string $value Value of the text to format.
- * @param string $tag Tag name
- *
- * @return string
- */
+ * Format the text within a program listing section.
+ * Highlighting is done via the external highlighter.
+ * programlisting without php tags get them appended
+ *
+ * @param string $value Value of the text to format.
+ * @param string $tag Tag name
+ *
+ * @return string Highlighted text.
+ */
public function format_programlisting_text($value, $tag)
{
switch($this->role) {