cvs: phd /include PhDHighlighter.class.php /themes/pear peartheme.php

From: Date: Mon, 26 Jan 2009 21:32:36 +0000
Subject: cvs: phd /include PhDHighlighter.class.php /themes/pear peartheme.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-3094@lists.php.net to get a copy of this message
cweiske Mon Jan 26 21:32:36 2009 UTC Modified files: /phd/include 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/PhDHighlighter.class.php?r1=1.1&r2=1.2&diff_format=u Index: phd/include/PhDHighlighter.class.php diff -u phd/include/PhDHighlighter.class.php:1.1 phd/include/PhDHighlighter.class.php:1.2 --- phd/include/PhDHighlighter.class.php:1.1 Mon Jan 26 08:54:38 2009 +++ phd/include/PhDHighlighter.class.php Mon Jan 26 21:32:30 2009 @@ -35,17 +35,19 @@ */ 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(..) } http://cvs.php.net/viewvc.cgi/phd/themes/pear/peartheme.php?r1=1.23&r2=1.24&diff_format=u Index: phd/themes/pear/peartheme.php diff -u phd/themes/pear/peartheme.php:1.23 phd/themes/pear/peartheme.php:1.24 --- phd/themes/pear/peartheme.php:1.23 Sun Jan 25 19:59:28 2009 +++ phd/themes/pear/peartheme.php Mon Jan 26 21:32:31 2009 @@ -558,6 +558,16 @@ $this->phd_pearapi_text = $value; } + /** + * Format a &lt;programlisting&gt; 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) {

« previous php.doc.cvs (#3094) next »