Esempio n. 1
0
 private function replace_with_geshi($matches)
 {
     $params = $this->getParams(strtolower($matches[1]));
     $code = trim($matches[2]);
     $lang = $params['lang'];
     $geshi = new geshi($code, isset($lang) ? $lang : "");
     $geshi->enable_classes(false);
     $geshi->set_overall_id('geshi_code');
     if (isset($params['title'])) {
         $geshi->highlight_lines_extra(array($params['title']));
     }
     $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
     $geshi->set_tab_width(3);
     $geshi->set_header_type(GESHI_HEADER_DIV);
     $code = "<div class=\"kodrs\">" . @$geshi->parse_code() . "</div>";
     return $code;
 }
Esempio n. 2
0
 /**
  * Converts the code to HTML
  *
  * @param File        $file File to render
  * @param Tool_Result $res  Tool result to integrate
  *
  * @return string HTML
  */
 public function toHtml(File $file, Tool_Result $res = null)
 {
     /**
      * Yes, geshi needs to be in your include path
      * We use the geshi pear package.
      */
     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_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 '<style type="text/css">' . $geshi->get_stylesheet() . '</style>' . '<div class="code">' . str_replace('&nbsp;', '&#160;', $geshi->parse_code()) . '</div>';
 }
Esempio n. 3
0
 private function replace_with_geshi($matches)
 {
     $lang = strtolower($matches[1]);
     $code = trim($matches[2]);
     $geshi = new geshi($code, isset($lang) ? $lang : "");
     $geshi->enable_classes(false);
     $geshi->set_overall_id('geshi_code');
     return @$geshi->parse_code();
 }