X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/7bf061541b0424b427bbbd1300e81d12190c9c54..c9e9855eb649e5b9237a81a6076ddd7fb30fe9e3:/src/phorkie/Renderer/Geshi.php diff --git a/src/phorkie/Renderer/Geshi.php b/src/phorkie/Renderer/Geshi.php index 1a79e16..2b3854a 100644 --- a/src/phorkie/Renderer/Geshi.php +++ b/src/phorkie/Renderer/Geshi.php @@ -6,21 +6,36 @@ class Renderer_Geshi /** * Converts the code to HTML * - * @param File $file File to render + * @param File $file File to render + * @param Tool_Result $res Tool result to integrate * * @return string HTML */ - public function toHtml(File $file) + public function toHtml(File $file, Tool_Result $res = null) { /** * Yes, geshi needs to be in your include path - * We use the mediawiki geshi extension package. + * We use the geshi pear package. */ - require_once 'MediaWiki/geshi/geshi/geshi.php'; - $geshi = new \GeSHi($file->getContent(), $this->getType($file)); + if (!class_exists('\\geshi', true)) { + require_once $GLOBALS['phorkie']['cfg']['geshi']; + } + $geshi = new \geshi($file->getContent(), $this->getType($file)); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); - $geshi->set_header_type(GESHI_HEADER_DIV); - return $geshi->parse_code(); + $geshi->set_header_type(GESHI_HEADER_PRE_TABLE); + $geshi->enable_classes(); + $geshi->set_line_style('color: #DDD;'); + + if ($res !== null) { + $geshi->highlight_lines_extra(array_keys($res->annotations)); + $geshi->set_highlight_lines_extra_style('background-color: #F2DEDE'); + } + + return '' + . '
' + . str_replace(' ', ' ', $geshi->parse_code()) + . '
'; } /**