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 mediawiki geshi extension package.
20 require_once $GLOBALS['phorkie']['cfg']['geshi'];
21 $geshi = new \GeSHi($file->getContent(), $this->getType($file));
22 $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
23 $geshi->set_header_type(GESHI_HEADER_DIV);
26 $geshi->highlight_lines_extra(array_keys($res->annotations));
27 $geshi->set_highlight_lines_extra_style('background-color: #F2DEDE');
30 return '<div class="code">'
31 . $geshi->parse_code()
36 * Returns the type of the file, as used by Geshi
40 public function getType($file)
42 $ext = $file->getExt();
43 if (isset($GLOBALS['phorkie']['languages'][$ext]['geshi'])) {
44 $ext = $GLOBALS['phorkie']['languages'][$ext]['geshi'];