cvs: phd(PHD_0_4) /include PhDHighlighter.class.php
| From: | Christian Weiske | Date: | Mon, 26 Jan 2009 08:54:58 +0000 |
| Subject: | cvs: phd(PHD_0_4) /include PhDHighlighter.class.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-3089@lists.php.net to get a copy of this message | ||
cweiske Mon Jan 26 08:54:58 2009 UTC
Added files: (Branch: PHD_0_4)
/phd/include PhDHighlighter.class.php
Log:
forgot the main class :)
http://cvs.php.net/viewvc.cgi/phd/include/PhDHighlighter.class.php?view=markup&rev=1.1
Index: phd/include/PhDHighlighter.class.php
+++ phd/include/PhDHighlighter.class.php
<?php
/**
* Source code highlighting class for phd.
*/
class PhDHighlighter
{
/**
* Create a new highlighter instance for the given format.
*
* We use a factory so you can return different objects/classes
* per format.
*
* @param string $format Format to highlight (pdf, html, man, ...)
*
* @return PhDHighlighter Highlighter object
*/
public static function factory($format)
{
return new self();
}//public static function factory(..)
/**
* Highlight a given piece of source code.
* Dead simple version that only works for xhtml+php. Returns text as
* it was in all other cases.
*
* @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, $format)
{
if ($format == 'xhtml') {
if ($role == 'php') {
return highlight_string($text, 1);
} else {
return '<pre>'
. htmlspecialchars($text, ENT_QUOTES, 'UTF-8')
. '</pre>';
}
}
return $text;
}//public function highlight(..)
}
?>