7 * Converts the code to HTML
9 * @param File $file File to render
10 * @param Tool_Result $res Tool result to integrate
14 public function toHtml(File $file, Tool_Result $res = null)
17 * Yes, geshi needs to be in your include path
18 * We use the geshi pear package.
20 if (!class_exists('\\geshi', true)) {
21 require_once $GLOBALS['phorkie']['cfg']['geshi'];
23 $geshi = new \geshi($file->getContent(), $this->getType($file));
24 $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
25 $geshi->set_header_type(GESHI_HEADER_DIV);
28 $geshi->highlight_lines_extra(array_keys($res->annotations));
29 $geshi->set_highlight_lines_extra_style('background-color: #F2DEDE');
32 return '<div class="code">'
33 . str_replace(' ', ' ', $geshi->parse_code())
38 * Returns the type of the file, as used by Geshi
42 public function getType($file)
44 $ext = $file->getExt();
45 if (isset($GLOBALS['phorkie']['languages'][$ext]['geshi'])) {
46 $ext = $GLOBALS['phorkie']['languages'][$ext]['geshi'];