当前位置: 首页>>代码示例>>PHP>>正文


PHP GeSHi::set_url_for_keyword_group方法代码示例

本文整理汇总了PHP中GeSHi::set_url_for_keyword_group方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::set_url_for_keyword_group方法的具体用法?PHP GeSHi::set_url_for_keyword_group怎么用?PHP GeSHi::set_url_for_keyword_group使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GeSHi的用法示例。


在下文中一共展示了GeSHi::set_url_for_keyword_group方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GeSHi

 static function render_code($source, $line_numbers = false, $lang = 'cpp-qt', $class = null)
 {
     require_once self::$geshi_file;
     $geshi = new GeSHi($source, $lang);
     $geshi->add_keyword_group(42, 'font-weight:bold', false, Yii::app()->db->createCommand()->select('name')->from('class')->queryColumn());
     $geshi->set_url_for_keyword_group(42, CHtml::normalizeUrl(array('class/view')) . '/{FNAME}');
     if ($line_numbers) {
         $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
     }
     return $geshi->parse_code();
 }
开发者ID:black2279,项目名称:Tracy-openshift,代码行数:11,代码来源:CodeGen.php

示例2: highlight_syntax

function highlight_syntax($code, $langid)
{
    $value = get_record('problemstatement_programming_language', 'id', $langid);
    if ($value) {
        $syntax = $value->geshi;
    } else {
        $syntax = '';
    }
    /*
    	switch ($langid) {
    		case '0': $syntax='cpp'; break;
    		case '1': $syntax='delphi'; break;
    		case '2': $syntax='java'; break;
    		case '3': $syntax='python'; break;
    		case '4': $syntax='csharp'; break;
    	}*/
    $geshi = new GeSHi($code, $syntax);
    $geshi->set_header_type(GESHI_HEADER_DIV);
    //   $geshi->enable_classes(true);
    $geshi->set_overall_style('font-family: monospace;');
    $linenumbers = 1;
    if ($linenumbers) {
        $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 5);
        $geshi->set_line_style('color:#222;', 'color:#888;');
        $geshi->set_overall_style('font-size: 14px;font-family: monospace;', true);
    }
    $urls = FALSE;
    $indentsize = FALSE;
    $inline = FALSE;
    if (!$urls) {
        for ($i = 0; $i < 5; $i++) {
            $geshi->set_url_for_keyword_group($i, '');
        }
    }
    if ($indentsize) {
        $geshi->set_tab_width($indentsize);
    }
    $parsed = $geshi->parse_code();
    if ($inline) {
        $parsed = preg_replace('/^<div/', '<span', $parsed);
        $parsed = preg_replace('/<\\/div>$/', '</span>', $parsed);
    }
    //return $geshi->parse_code().$syntax;
    $lang = get_record('problemstatement_programming_language', 'id', $langid);
    if (!$lang) {
        $lang = '';
    }
    $comment = get_string("programwritten", "problemstatement") . $lang->language_name;
    //get_string("lang_".$langid, "problemstatement");
    return $parsed . $comment;
}
开发者ID:Anna-Sentyakova,项目名称:runningcat,代码行数:51,代码来源:problemstatement.class.php

示例3: highlightSourceFile

 protected function highlightSourceFile($filename)
 {
     if ($this->geshipath) {
         require_once $this->geshipath . '/geshi.php';
         $source = file_get_contents($filename);
         $geshi = new GeSHi($source, 'php', $this->geshilanguagespath);
         $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
         $geshi->enable_strict_mode(true);
         $geshi->enable_classes(true);
         $geshi->set_url_for_keyword_group(3, '');
         $html = $geshi->parse_code();
         $lines = split("<li>|</li>", $html);
         // skip first and last line
         array_pop($lines);
         array_shift($lines);
         $lines = array_filter($lines);
         $lines = array_map(array($this, 'stripDiv'), $lines);
         return $lines;
     } else {
         $lines = file($filename);
         for ($i = 0; $i < count($lines); $i++) {
             $line = $lines[$i];
             $line = rtrim($line);
             if (function_exists('mb_convert_encoding')) {
                 $lines[$i] = mb_convert_encoding($line, 'UTF-8');
             } else {
                 $lines[$i] = utf8_encode($line);
             }
         }
         return $lines;
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:32,代码来源:CoverageReportTask.php

示例4: rgb

	$geshi->set_methods_style(1, "color: black;", false);
	
	//for multi-line comments /**/
	$geshi->set_comments_style('MULTI','color: rgb(63,127,95); font-style: code;', false);

	//for 'import' keyword
//	$geshi->set_comments_style(2,'color: rgb(127,0,85); font-weight: bold;', false);

	//for string constants
	$geshi->set_strings_style('color: rgb(42,0,255);', true);

	//for links (standard classes, etc.)
	$geshi->set_link_styles(GESHI_LINK, 'color: #000060;');
	$geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;');

	//for keywords
	$geshi->set_keyword_group_style(1,'color: rgb(127,0,85); font-weight: bold;', false);
	$geshi->set_keyword_group_style(2,'color: rgb(127,0,85); font-weight: bold;', false); 
	$geshi->set_keyword_group_style(4,'color: rgb(127,0,85); font-weight: bold;', false); 
	
	//new keyword group for 'package'
//	$geshi->add_keyword_group(5, 'color: rgb(127,0,85); font-weight: bold;', true, array('package', 'import'));

	$geshi->set_header_content('SVNKit API examlpe: '.$fileName);
	$geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;');
	$geshi->set_symbols_highlighting(false);
	$geshi->set_footer_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-top: 1px solid #d0d0d0; padding: 2px;');
	$geshi->set_url_for_keyword_group(3,"http://java.sun.com/j2se/1.4.2/docs/api/");
	$code = $geshi->parse_code();
	echo "<html><body><h1 >".$fileName."</h1>".$code."<div style=\"max-width: 800px; width: 800px;\"><center><small style=\"color: #669999; font-size: 100%; margin: 0px; padding: 0px; margin-top: 0.5em; font-weight: normal;\"><span style=\"font-size: 80%;\">(c) 2004-2007 TMate Software. All rights reserved.</span></small></center></div></body></html>";
?>
开发者ID:hudson,项目名称:svnkit,代码行数:31,代码来源:display_example.php


注:本文中的GeSHi::set_url_for_keyword_group方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。