コード例 #1
0
 static function highlight($a, $language, $line_numbers)
 {
     isset(self::$map[$language]) && ($language = self::$map[$language]);
     $a = new geshi($a, $language);
     $a->set_encoding('UTF-8');
     $line_numbers && $a->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
     $a->set_header_type(GESHI_HEADER_DIV);
     $a->set_tab_width(4);
     return $a->parse_code();
 }
コード例 #2
0
ファイル: kodrs.plugin.php プロジェクト: ravenlp/CodiceCMS
 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;
 }
コード例 #3
0
ファイル: Geshi.php プロジェクト: nickel715/phorkie
 /**
  * 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>';
 }