cvs: phd(PHD_0_4) / build.php config.php package.xml /formats xhtml.php /include PhDHelper.class.php /themes/pear peartheme.php
| From: | Christian Weiske | Date: | Sun, 25 Jan 2009 19:59:05 +0000 |
| Subject: | cvs: phd(PHD_0_4) / build.php config.php package.xml /formats xhtml.php /include PhDHelper.class.php /themes/pear peartheme.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-3083@lists.php.net to get a copy of this message | ||
cweiske Sun Jan 25 19:59:05 2009 UTC
Modified files: (Branch: PHD_0_4)
/phd build.php config.php package.xml
/phd/formats xhtml.php
/phd/include PhDHelper.class.php
/phd/themes/pear peartheme.php
Log:
Implement request #47201: Allow custom source code highlighter (e.g. Geshi) (Christian)
http://cvs.php.net/viewvc.cgi/phd/build.php?r1=1.54.2.3.2.1&r2=1.54.2.3.2.2&diff_format=u Index: phd/build.php diff -u phd/build.php:1.54.2.3.2.1 phd/build.php:1.54.2.3.2.2 --- phd/build.php:1.54.2.3.2.1 Sun Oct 19 14:49:40 2008 +++ phd/build.php Sun Jan 25 19:59:03 2009 @@ -1,9 +1,9 @@ #!@php_bin@ <?php -/* $Id: build.php,v 1.54.2.3.2.1 2008/10/19 14:49:40 bjori Exp $ */ +/* $Id: build.php,v 1.54.2.3.2.2 2009/01/25 19:59:03 cweiske Exp $ */ /* {{{ Find the $ROOT directory of PhD - @php_dir@ will be replaced by the pear package manager + @php_dir@ will be replaced by the pear package manager If @php_dir@ however hasn't been replaced by anything, fallback to the dir containing this file */ $ROOT = "@php_dir@/phd"; @@ -12,7 +12,7 @@ } /* }}} */ -(@include $ROOT."/config.php") +(include $ROOT."/config.php") && isset($OPTIONS) && is_array($OPTIONS) && isset($OPTIONS["output_format"], $OPTIONS["output_theme"]) @@ -97,7 +97,7 @@ foreach($OPTIONS["output_theme"][$output_format] as $theme => $array) { is_dir($ROOT. "/themes/$theme") or die("Can't find the '$theme' theme"); v("Using the %s theme (%s)", $theme, join(", ", $array), VERBOSE_THEME_RENDERING); - + foreach($array as $themename) { $themename = basename($themename); require_once $ROOT. "/themes/$theme/$themename.php"; @@ -114,11 +114,11 @@ default: $themes[$themename] = new $themename(array($IDs, $REFS, $CLASSES, $VARS)); } - + // FIXME: this needs to go away when we add support for // things other than xhtml $themes[$themename]->registerFormat($format); - + // If the theme returns empty callback map there is no need to include it $tmp = $themes[$themename]->getElementMap(); http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.45.2.14.2.10&r2=1.45.2.14.2.11&diff_format=u Index: phd/config.php diff -u phd/config.php:1.45.2.14.2.10 phd/config.php:1.45.2.14.2.11 --- phd/config.php:1.45.2.14.2.10 Sun Dec 28 16:16:13 2008 +++ phd/config.php Sun Jan 25 19:59:03 2009 @@ -1,5 +1,5 @@ <?php -/* $Id: config.php,v 1.45.2.14.2.10 2008/12/28 16:16:13 bjori Exp $ */ +/* $Id: config.php,v 1.45.2.14.2.11 2009/01/25 19:59:03 cweiske Exp $ */ /* {{{ PhD error & message handler */ @@ -178,6 +178,7 @@ 'php_error_output' => STDERR, 'user_error_output' => STDERR, 'phd_info_output' => STDOUT, + 'highlighter' => 'PhDHighlighter', ); /* }}} */ @@ -186,19 +187,20 @@ /* {{{ getopt() options */ $opts = array( - "format:" => "f:", // The format to render (xhtml, pdf...) - "theme:" => "t:", // The theme to render (phpweb, bightml..) - "index:" => "i:", // Re-index or load from cache - "docbook:" => "d:", // The Docbook XML file to render from (.manual.xml) - "output:" => "o:", // The output directory - "partial:" => "p:", // The ID to render (optionally ignoring its children) - "skip:" => "s:", // The ID to skip (optionally skipping its children too) - "verbose:" => "v", // Adjust the verbosity level - "list::" => "l::", // List supported themes/formats - "lang:" => "L:", // Language hint (used by the CHM) - "color::" => "c::", // Use color output if possible - "version" => "V", // Print out version information - "help" => "h", // Print out help + "format:" => "f:", // The format to render (xhtml, pdf...) + "theme:" => "t:", // The theme to render (phpweb, bightml..) + "index:" => "i:", // Re-index or load from cache + "docbook:" => "d:", // The Docbook XML file to render from (.manual.xml) + "output:" => "o:", // The output directory + "partial:" => "p:", // The ID to render (optionally ignoring its children) + "skip:" => "s:", // The ID to skip (optionally skipping its children too) + "verbose:" => "v", // Adjust the verbosity level + "list::" => "l::", // List supported themes/formats + "lang:" => "L:", // Language hint (used by the CHM) + "color::" => "c::", // Use color output if possible + 'highlighter:' => 'h:', // Class used as source code highlighter + "version" => "V", // Print out version information + "help" => "h", // Print out help ); /* }}} */ @@ -545,6 +547,13 @@ break; /* }}} */ + /* {{{ Souce code highlighter */ + case 'h': + case 'highlighter': + $OPTIONS['highlighter'] = (string)$v; + break; + /* }}} */ + /* {{{ Version info */ case "V": case "version": @@ -581,6 +590,8 @@ --lang <language> The language of the source file (used by the CHM theme). (default: en) -c <color> --color <color> Enable color output when output is to a terminal, optionally specify numerical color value (default: false) + -h <classname> + --highlighter <classname> Use custom source code highlighting php class -V --version Print the PhD version information -h http://cvs.php.net/viewvc.cgi/phd/package.xml?r1=1.74.2.19.2.37&r2=1.74.2.19.2.38&diff_format=u Index: phd/package.xml diff -u phd/package.xml:1.74.2.19.2.37 phd/package.xml:1.74.2.19.2.38 --- phd/package.xml:1.74.2.19.2.37 Sun Jan 25 09:39:02 2009 +++ phd/package.xml Sun Jan 25 19:59:03 2009 @@ -41,7 +41,7 @@ <active>yes</active> </developer> - <date>2009-01-17</date> + <date>2009-01-25</date> <version> <release>0.4.4</release> <api>0.4.4</api> @@ -54,6 +54,7 @@ <notes> - Add support for <package> in pear theme (Christian) - Replace ereg_replace with preg_replace + - Implement request #47201: Allow custom source code highlighter (e.g. Geshi) (Christian) </notes> <contents> http://cvs.php.net/viewvc.cgi/phd/formats/xhtml.php?r1=1.67.2.2.2.16&r2=1.67.2.2.2.17&diff_format=u Index: phd/formats/xhtml.php diff -u phd/formats/xhtml.php:1.67.2.2.2.16 phd/formats/xhtml.php:1.67.2.2.2.17 --- phd/formats/xhtml.php:1.67.2.2.2.16 Wed Jan 7 18:06:27 2009 +++ phd/formats/xhtml.php Sun Jan 25 19:59:04 2009 @@ -1,5 +1,5 @@ <?php -/* $Id: xhtml.php,v 1.67.2.2.2.16 2009/01/07 18:06:27 bjori Exp $ */ +/* $Id: xhtml.php,v 1.67.2.2.2.17 2009/01/25 19:59:04 cweiske Exp $ */ class XHTMLPhDFormat extends PhDFormat { protected $elementmap = array( /* {{{ */ @@ -427,11 +427,14 @@ } public function CDATA($str) { switch($this->role) { - case "php": - return '<div class="phpcode">' .(highlight_string(trim($str), 1)). '</div>'; - break; + case '': + return '<div class="cdata"><pre>' + . htmlspecialchars($str, ENT_QUOTES, "UTF-8") + . '</pre></div>'; default: - return '<div class="cdata"><pre>' .(htmlspecialchars($str, ENT_QUOTES, "UTF-8")). '</pre></div>'; + return '<div class="' . $this->role . 'code">' + . $this->highlight(trim($str), $this->role, 'xhtml') + . '</div>'; } } public function TEXT($str) { http://cvs.php.net/viewvc.cgi/phd/include/PhDHelper.class.php?r1=1.9.2.1.2.1&r2=1.9.2.1.2.2&diff_format=u Index: phd/include/PhDHelper.class.php diff -u phd/include/PhDHelper.class.php:1.9.2.1.2.1 phd/include/PhDHelper.class.php:1.9.2.1.2.2 --- phd/include/PhDHelper.class.php:1.9.2.1.2.1 Sun Oct 19 13:06:48 2008 +++ phd/include/PhDHelper.class.php Sun Jan 25 19:59:04 2009 @@ -1,5 +1,5 @@ <?php -/* $Id: PhDHelper.class.php,v 1.9.2.1.2.1 2008/10/19 13:06:48 bjori Exp $ */ +/* $Id: PhDHelper.class.php,v 1.9.2.1.2.2 2009/01/25 19:59:04 cweiske Exp $ */ /** * Base class for PhDTheme @@ -32,6 +32,16 @@ private static $autogen = array(); /** + * Array of highlighter objects + * Key is the format, value the object + * + * @var array + */ + private static $highlighters = array(); + + + + /** * Creates the helper object. * * @param array $a Array with ID array as first value, ref array as second. @@ -182,6 +192,50 @@ PhDHelper::$autogen[$lang] = $autogen; return PhDHelper::$autogen[$lang][$text]; } + + /** + * Highlight (color) the given piece of source code + * + * @param string $text Text to highlight + * @param string $role Source code role to use (php, xml, html, ...) + * @param string $format Format to highlight (pdf, html, man, ...) + * + * @return string Highlighted code + */ + public function highlight($text, $role = 'php', $format = 'xhtml') + { + global $OPTIONS; + + if (!isset(self::$highlighters[$format])) { + $class = $OPTIONS['highlighter']; + + if (!class_exists($class, true)) { + if ($class == 'PhDHighlighter') { + //hard coded path for phdhighlighter, since phd doesn't follow + // pear file conventions + require_once dirname(__FILE__) . '/PhDHighlighter.class.php'; + } else { + //simple autoload replacement for pear-style classes + require_once str_replace('_', '/', $class) . '.php'; + } + + if (!class_exists($class, false)) { + trigger_error( + 'Highlighter class ' . $class . ' is not available', + E_USER_ERROR + ); + } + } + self::$highlighters[$format] = call_user_func( + array($class, 'factory'), $format + ); + + } + + return self::$highlighters[$format]->highlight( + $text, $role, $format + ); + }//public function highlight(..) } /* http://cvs.php.net/viewvc.cgi/phd/themes/pear/peartheme.php?r1=1.8.2.2.2.3&r2=1.8.2.2.2.4&diff_format=u Index: phd/themes/pear/peartheme.php diff -u phd/themes/pear/peartheme.php:1.8.2.2.2.3 phd/themes/pear/peartheme.php:1.8.2.2.2.4 --- phd/themes/pear/peartheme.php:1.8.2.2.2.3 Sun Jan 25 09:39:04 2009 +++ phd/themes/pear/peartheme.php Sun Jan 25 19:59:04 2009 @@ -580,7 +580,7 @@ * Format the text within a program listing section. * * @param string $value Value of the text to format. - * @param unknown_type $tag + * @param string $tag Tag name * * @return string */ @@ -588,12 +588,14 @@ { switch($this->role) { case 'php': - if ( strrpos($value, '<?php') || strrpos($value, '?>') ) - return highlight_string(trim($value), 1); - else return highlight_string("<?php\n" . trim($value) . "\n?>", 1); + if (strrpos($value, '<?php') || strrpos($value, '?>')) { + return $this->highlight(trim($value), 'php', 'xhtml'); + } else { + return $this->highlight("<?php\n" . trim($value) . "\n?>", 'php', 'xhtml'); + } break; default: - return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); + return $this->highlight(trim($value), $this->role, 'xhtml'); } } @@ -642,14 +644,17 @@ switch ($this->role) { case 'php': if (strrpos($str, '<?php') || strrpos($str, '?>')) { - $str = highlight_string(trim($str), 1); + $str = $this->highlight(trim($str), $this->role, 'xhtml'); } else { - $str = highlight_string("<?php\n" . trim($str) . "\n?>", 1); + $str = $this->highlight("<?php\n" . trim($str) . "\n?>", $this->role, 'xhtml'); } break; - default: + case '': $str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8'); break; + default: + $str = $this->highlight($str, $this->role, 'xhtml'); + break; } return $str;
http://cvs.php.net/viewvc.cgi/phd/build.php?r1=1.54.2.3.2.1&r2=1.54.2.3.2.2&diff_format=u Index: phd/build.php diff -u phd/build.php:1.54.2.3.2.1 phd/build.php:1.54.2.3.2.2 --- phd/build.php:1.54.2.3.2.1 Sun Oct 19 14:49:40 2008 +++ phd/build.php Sun Jan 25 19:59:03 2009 @@ -1,9 +1,9 @@ #!@php_bin@ <?php -/* $Id: build.php,v 1.54.2.3.2.1 2008/10/19 14:49:40 bjori Exp $ */ +/* $Id: build.php,v 1.54.2.3.2.2 2009/01/25 19:59:03 cweiske Exp $ */ /* {{{ Find the $ROOT directory of PhD - @php_dir@ will be replaced by the pear package manager + @php_dir@ will be replaced by the pear package manager If @php_dir@ however hasn't been replaced by anything, fallback to the dir containing this file */ $ROOT = "@php_dir@/phd"; @@ -12,7 +12,7 @@ } /* }}} */ -(@include $ROOT."/config.php") +(include $ROOT."/config.php") && isset($OPTIONS) && is_array($OPTIONS) && isset($OPTIONS["output_format"], $OPTIONS["output_theme"]) @@ -97,7 +97,7 @@ foreach($OPTIONS["output_theme"][$output_format] as $theme => $array) { is_dir($ROOT. "/themes/$theme") or die("Can't find the '$theme' theme"); v("Using the %s theme (%s)", $theme, join(", ", $array), VERBOSE_THEME_RENDERING); - + foreach($array as $themename) { $themename = basename($themename); require_once $ROOT. "/themes/$theme/$themename.php"; @@ -114,11 +114,11 @@ default: $themes[$themename] = new $themename(array($IDs, $REFS, $CLASSES, $VARS)); } - + // FIXME: this needs to go away when we add support for // things other than xhtml $themes[$themename]->registerFormat($format); - + // If the theme returns empty callback map there is no need to include it $tmp = $themes[$themename]->getElementMap(); http://cvs.php.net/viewvc.cgi/phd/config.php?r1=1.45.2.14.2.10&r2=1.45.2.14.2.11&diff_format=u Index: phd/config.php diff -u phd/config.php:1.45.2.14.2.10 phd/config.php:1.45.2.14.2.11 --- phd/config.php:1.45.2.14.2.10 Sun Dec 28 16:16:13 2008 +++ phd/config.php Sun Jan 25 19:59:03 2009 @@ -1,5 +1,5 @@ <?php -/* $Id: config.php,v 1.45.2.14.2.10 2008/12/28 16:16:13 bjori Exp $ */ +/* $Id: config.php,v 1.45.2.14.2.11 2009/01/25 19:59:03 cweiske Exp $ */ /* {{{ PhD error & message handler */ @@ -178,6 +178,7 @@ 'php_error_output' => STDERR, 'user_error_output' => STDERR, 'phd_info_output' => STDOUT, + 'highlighter' => 'PhDHighlighter', ); /* }}} */ @@ -186,19 +187,20 @@ /* {{{ getopt() options */ $opts = array( - "format:" => "f:", // The format to render (xhtml, pdf...) - "theme:" => "t:", // The theme to render (phpweb, bightml..) - "index:" => "i:", // Re-index or load from cache - "docbook:" => "d:", // The Docbook XML file to render from (.manual.xml) - "output:" => "o:", // The output directory - "partial:" => "p:", // The ID to render (optionally ignoring its children) - "skip:" => "s:", // The ID to skip (optionally skipping its children too) - "verbose:" => "v", // Adjust the verbosity level - "list::" => "l::", // List supported themes/formats - "lang:" => "L:", // Language hint (used by the CHM) - "color::" => "c::", // Use color output if possible - "version" => "V", // Print out version information - "help" => "h", // Print out help + "format:" => "f:", // The format to render (xhtml, pdf...) + "theme:" => "t:", // The theme to render (phpweb, bightml..) + "index:" => "i:", // Re-index or load from cache + "docbook:" => "d:", // The Docbook XML file to render from (.manual.xml) + "output:" => "o:", // The output directory + "partial:" => "p:", // The ID to render (optionally ignoring its children) + "skip:" => "s:", // The ID to skip (optionally skipping its children too) + "verbose:" => "v", // Adjust the verbosity level + "list::" => "l::", // List supported themes/formats + "lang:" => "L:", // Language hint (used by the CHM) + "color::" => "c::", // Use color output if possible + 'highlighter:' => 'h:', // Class used as source code highlighter + "version" => "V", // Print out version information + "help" => "h", // Print out help ); /* }}} */ @@ -545,6 +547,13 @@ break; /* }}} */ + /* {{{ Souce code highlighter */ + case 'h': + case 'highlighter': + $OPTIONS['highlighter'] = (string)$v; + break; + /* }}} */ + /* {{{ Version info */ case "V": case "version": @@ -581,6 +590,8 @@ --lang <language> The language of the source file (used by the CHM theme). (default: en) -c <color> --color <color> Enable color output when output is to a terminal, optionally specify numerical color value (default: false) + -h <classname> + --highlighter <classname> Use custom source code highlighting php class -V --version Print the PhD version information -h http://cvs.php.net/viewvc.cgi/phd/package.xml?r1=1.74.2.19.2.37&r2=1.74.2.19.2.38&diff_format=u Index: phd/package.xml diff -u phd/package.xml:1.74.2.19.2.37 phd/package.xml:1.74.2.19.2.38 --- phd/package.xml:1.74.2.19.2.37 Sun Jan 25 09:39:02 2009 +++ phd/package.xml Sun Jan 25 19:59:03 2009 @@ -41,7 +41,7 @@ <active>yes</active> </developer> - <date>2009-01-17</date> + <date>2009-01-25</date> <version> <release>0.4.4</release> <api>0.4.4</api> @@ -54,6 +54,7 @@ <notes> - Add support for <package> in pear theme (Christian) - Replace ereg_replace with preg_replace + - Implement request #47201: Allow custom source code highlighter (e.g. Geshi) (Christian) </notes> <contents> http://cvs.php.net/viewvc.cgi/phd/formats/xhtml.php?r1=1.67.2.2.2.16&r2=1.67.2.2.2.17&diff_format=u Index: phd/formats/xhtml.php diff -u phd/formats/xhtml.php:1.67.2.2.2.16 phd/formats/xhtml.php:1.67.2.2.2.17 --- phd/formats/xhtml.php:1.67.2.2.2.16 Wed Jan 7 18:06:27 2009 +++ phd/formats/xhtml.php Sun Jan 25 19:59:04 2009 @@ -1,5 +1,5 @@ <?php -/* $Id: xhtml.php,v 1.67.2.2.2.16 2009/01/07 18:06:27 bjori Exp $ */ +/* $Id: xhtml.php,v 1.67.2.2.2.17 2009/01/25 19:59:04 cweiske Exp $ */ class XHTMLPhDFormat extends PhDFormat { protected $elementmap = array( /* {{{ */ @@ -427,11 +427,14 @@ } public function CDATA($str) { switch($this->role) { - case "php": - return '<div class="phpcode">' .(highlight_string(trim($str), 1)). '</div>'; - break; + case '': + return '<div class="cdata"><pre>' + . htmlspecialchars($str, ENT_QUOTES, "UTF-8") + . '</pre></div>'; default: - return '<div class="cdata"><pre>' .(htmlspecialchars($str, ENT_QUOTES, "UTF-8")). '</pre></div>'; + return '<div class="' . $this->role . 'code">' + . $this->highlight(trim($str), $this->role, 'xhtml') + . '</div>'; } } public function TEXT($str) { http://cvs.php.net/viewvc.cgi/phd/include/PhDHelper.class.php?r1=1.9.2.1.2.1&r2=1.9.2.1.2.2&diff_format=u Index: phd/include/PhDHelper.class.php diff -u phd/include/PhDHelper.class.php:1.9.2.1.2.1 phd/include/PhDHelper.class.php:1.9.2.1.2.2 --- phd/include/PhDHelper.class.php:1.9.2.1.2.1 Sun Oct 19 13:06:48 2008 +++ phd/include/PhDHelper.class.php Sun Jan 25 19:59:04 2009 @@ -1,5 +1,5 @@ <?php -/* $Id: PhDHelper.class.php,v 1.9.2.1.2.1 2008/10/19 13:06:48 bjori Exp $ */ +/* $Id: PhDHelper.class.php,v 1.9.2.1.2.2 2009/01/25 19:59:04 cweiske Exp $ */ /** * Base class for PhDTheme @@ -32,6 +32,16 @@ private static $autogen = array(); /** + * Array of highlighter objects + * Key is the format, value the object + * + * @var array + */ + private static $highlighters = array(); + + + + /** * Creates the helper object. * * @param array $a Array with ID array as first value, ref array as second. @@ -182,6 +192,50 @@ PhDHelper::$autogen[$lang] = $autogen; return PhDHelper::$autogen[$lang][$text]; } + + /** + * Highlight (color) the given piece of source code + * + * @param string $text Text to highlight + * @param string $role Source code role to use (php, xml, html, ...) + * @param string $format Format to highlight (pdf, html, man, ...) + * + * @return string Highlighted code + */ + public function highlight($text, $role = 'php', $format = 'xhtml') + { + global $OPTIONS; + + if (!isset(self::$highlighters[$format])) { + $class = $OPTIONS['highlighter']; + + if (!class_exists($class, true)) { + if ($class == 'PhDHighlighter') { + //hard coded path for phdhighlighter, since phd doesn't follow + // pear file conventions + require_once dirname(__FILE__) . '/PhDHighlighter.class.php'; + } else { + //simple autoload replacement for pear-style classes + require_once str_replace('_', '/', $class) . '.php'; + } + + if (!class_exists($class, false)) { + trigger_error( + 'Highlighter class ' . $class . ' is not available', + E_USER_ERROR + ); + } + } + self::$highlighters[$format] = call_user_func( + array($class, 'factory'), $format + ); + + } + + return self::$highlighters[$format]->highlight( + $text, $role, $format + ); + }//public function highlight(..) } /* http://cvs.php.net/viewvc.cgi/phd/themes/pear/peartheme.php?r1=1.8.2.2.2.3&r2=1.8.2.2.2.4&diff_format=u Index: phd/themes/pear/peartheme.php diff -u phd/themes/pear/peartheme.php:1.8.2.2.2.3 phd/themes/pear/peartheme.php:1.8.2.2.2.4 --- phd/themes/pear/peartheme.php:1.8.2.2.2.3 Sun Jan 25 09:39:04 2009 +++ phd/themes/pear/peartheme.php Sun Jan 25 19:59:04 2009 @@ -580,7 +580,7 @@ * Format the text within a program listing section. * * @param string $value Value of the text to format. - * @param unknown_type $tag + * @param string $tag Tag name * * @return string */ @@ -588,12 +588,14 @@ { switch($this->role) { case 'php': - if ( strrpos($value, '<?php') || strrpos($value, '?>') ) - return highlight_string(trim($value), 1); - else return highlight_string("<?php\n" . trim($value) . "\n?>", 1); + if (strrpos($value, '<?php') || strrpos($value, '?>')) { + return $this->highlight(trim($value), 'php', 'xhtml'); + } else { + return $this->highlight("<?php\n" . trim($value) . "\n?>", 'php', 'xhtml'); + } break; default: - return htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); + return $this->highlight(trim($value), $this->role, 'xhtml'); } } @@ -642,14 +644,17 @@ switch ($this->role) { case 'php': if (strrpos($str, '<?php') || strrpos($str, '?>')) { - $str = highlight_string(trim($str), 1); + $str = $this->highlight(trim($str), $this->role, 'xhtml'); } else { - $str = highlight_string("<?php\n" . trim($str) . "\n?>", 1); + $str = $this->highlight("<?php\n" . trim($str) . "\n?>", $this->role, 'xhtml'); } break; - default: + case '': $str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8'); break; + default: + $str = $this->highlight($str, $this->role, 'xhtml'); + break; } return $str;