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


PHP GeSHi::set_keyword_group_style方法代码示例

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


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

示例1: ext

print '<!DOCTYPE html><html><head>' . '<title>Source</title>' . "\n" . '<style type="text/css">/*<![CDATA[*/' . "\nhtml { background-color: #333; }\nbody { font-family: 'Trebuchet MS', serif;  font-size: 0.9em;  margin: 2em auto;\nwidth: 50em; padding: 2em; border: 3px solid #000; background-color: #EEE; }\na { color: blue; }\na:hover { color: #000033; }\n/*]]>*/</style></head>\n<body>\n";
if (isset($_GET['sauce'])) {
    if (!valid_path($_GET['sauce']) || !is_file($_GET['sauce'])) {
        print '<h1>YOR ISP MAC ADDRESS HAS BEEN REPORTING TO THE FBI!!!</h1>';
        exit;
    } else {
        require_once '/home/ben/geshi/geshi.php';
        $lang = ext($_GET['sauce']);
        switch ($lang) {
            case 'py':
                $lang = 'python';
                break;
        }
        $geshi = new GeSHi(file_get_contents($_GET['sauce']), $lang);
        $geshi->set_header_type(GESHI_HEADER_PRE_VALID);
        $geshi->enable_classes();
        //$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
        $geshi->enable_keyword_links(false);
        $geshi->set_keyword_group_style(1, 'color: #DD0000;');
        $geshi->set_keyword_group_style(2, 'color: #666;');
        $geshi->set_keyword_group_style(3, 'color: #0033CC;');
        $geshi->set_keyword_group_style(4, 'color: #00CC33;');
        $geshi->set_comments_style(1, 'color: #00CC00;');
        $geshi->set_comments_style(2, 'color: #00CC00;');
        $geshi->set_comments_style('MULTI', 'color: #009900;');
        print '<style type="text/css">/*<![CDATA[*/' . $geshi->get_stylesheet() . "/*]]>*/</style>\n" . $geshi->parse_code();
    }
} else {
    dir_walk();
}
print "\n</body></html>\n";
开发者ID:RayLennox,项目名称:up,代码行数:31,代码来源:source.php

示例2: 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

示例3: switch

 /**
  * Style language
  *
  * @param array $subjects
  */
 function _styleSubjects($subjects)
 {
     // set overall style
     if (isset($subjects['view'])) {
         $this->geshi->set_overall_style($subjects['view'], $this->_invertOverwrite($subjects['view.']['overwrite']));
     }
     if (isset($subjects['view.']['container'])) {
         switch ($subjects['view.']['container']) {
             case 'none':
             case 'NONE':
             case 'None':
                 $this->geshi->set_header_type(GESHI_HEADER_NONE);
                 break;
             case 'div':
             case 'Div':
             case 'DIV':
                 $this->geshi->set_header_type(GESHI_HEADER_DIV);
                 break;
             case 'pre':
             case 'Pre':
             case 'PRE':
             default:
                 $this->geshi->set_header_type(GESHI_HEADER_PRE);
                 break;
         }
     }
     if (isset($subjects['view.']['tabwidth'])) {
         $this->geshi->set_tab_width(intval($subjects['view.']['tabwidth']));
     }
     // configure linenumbers
     if (isset($subjects['linenumbers'])) {
         $this->geshi->set_line_style($subjects['linenumbers'], isset($subjects['linenumbers.']['fancy']) ? $subjects['linenumbers.']['fancy'] : '', $this->_invertOverwrite($subjects['linenumbers.']['overwrite']));
     }
     // enable / disable linenumbers
     if (isset($subjects['linenumbers.']['enable'])) {
         $this->geshi->enable_line_numbers($subjects['linenumbers.']['enable']);
     }
     // configure code style
     if (isset($subjects['code'])) {
         $this->geshi->set_code_style($subjects['code'], $this->_invertOverwrite($subjects['code.']['overwrite']));
     }
     // configure escape
     if (isset($subjects['escape'])) {
         $this->geshi->set_escape_characters_style($subjects['escape'], $this->_invertOverwrite($subjects['escape.']['overwrite']));
     }
     // configure symbols
     if (isset($subjects['symbols'])) {
         $this->geshi->set_symbols_style($subjects['symbols'], $this->_invertOverwrite($subjects['symbols.']['overwrite']));
     }
     // configure strings
     if (isset($subjects['strings'])) {
         $this->geshi->set_strings_style($subjects['strings'], $this->_invertOverwrite($subjects['strings.']['overwrite']));
     }
     // configure numbers
     if (isset($subjects['numbers'])) {
         $this->geshi->set_numbers_style($subjects['numbers'], $this->_invertOverwrite($subjects['numbers.']['overwrite']));
     }
     // configure comment style
     if (isset($subjects['comments.'])) {
         foreach ($subjects['comments.'] as $key => $value) {
             if (strstr($key, '.') == false) {
                 $this->geshi->set_comments_style($key, $value, $this->_invertOverwrite($subjects['comments.'][$key . '.']['overwrite']));
             }
         }
     }
     // configure keywords style
     if (isset($subjects['keywords.'])) {
         foreach ($subjects['keywords.'] as $key => $value) {
             if (strstr($key, '.') == false) {
                 $this->geshi->set_keyword_group_style($key, $value, $this->_invertOverwrite($subjects['keywords.'][$key . '.']['overwrite']));
             }
         }
     }
     // enable / disable keyword links
     if (isset($subjects['keyword.']['links.']['enable'])) {
         $this->geshi->enable_keyword_links($subjects['keyword.']['links.']['enable']);
     }
     // configure keyword link styles
     if (isset($subjects['keyword.']['links'])) {
         $this->geshi->set_link_styles(GESHI_LINK, $subjects['keyword.']['links']);
     }
     if (isset($subjects['keyword.']['links.']['hover'])) {
         $this->geshi->set_link_styles(GESHI_HOVER, $subjects['keyword.']['links.']['hover']);
     }
     if (isset($subjects['keyword.']['links.']['active'])) {
         $this->geshi->set_link_styles(GESHI_ACTIVE, $subjects['keyword.']['links.']['active']);
     }
     if (isset($subjects['keyword.']['links.']['visited'])) {
         $this->geshi->set_link_styles(GESHI_VISITED, $subjects['keyword.']['links.']['visited']);
     }
     // configure keyword link target
     if (isset($subjects['keyword.']['links.']['target'])) {
         $this->geshi->set_link_target($subjects['keyword.']['links.']['target']);
     }
     // configure method styles
//.........这里部分代码省略.........
开发者ID:sema,项目名称:typo3-source-code-highlighter,代码行数:101,代码来源:class.tx_semasourcecode_pi1.php

示例4: code

 private function code($string)
 {
     $code = array('4cs', '6502acme', '6502kickass', '6502tasm', '68000devpac', 'abap', 'actionscript', 'actionscript3', 'ada', 'algol68', 'apache', 'applescript', 'apt_sources', 'arm', 'asm', 'asp', 'asymptote', 'autoconf', 'autohotkey', 'autoit', 'avisynth', 'awk', 'bascomavr', 'bash', 'basic4gl', 'bf', 'bibtex', 'blitzbasic', 'bnf', 'boo', 'c', 'caddcl', 'cadlisp', 'cfdg', 'cfm', 'chaiscript', 'cil', 'clojure', 'cmake', 'cobol', 'coffeescript', 'cpp-qt', 'cpp', 'csharp', 'css', 'cuesheet', 'c_loadrunner', 'c_mac', 'd', 'dcl', 'dcpu16', 'dcs', 'delphi', 'diff', 'div', 'dos', 'dot', 'e', 'ecmascript', 'eiffel', 'email', 'epc', 'erlang', 'euphoria', 'f1', 'falcon', 'fo', 'fortran', 'freebasic', 'freeswitch', 'fsharp', 'gambas', 'gdb', 'genero', 'genie', 'gettext', 'glsl', 'gml', 'gnuplot', 'go', 'groovy', 'gwbasic', 'haskell', 'haxe', 'hicest', 'hq9plus', 'html4strict', 'html5', 'icon', 'idl', 'ini', 'inno', 'intercal', 'io', 'j', 'java', 'java5', 'javascript', 'jquery', 'kixtart', 'klonec', 'klonecpp', 'latex', 'lb', 'ldif', 'lisp', 'llvm', 'locobasic', 'logtalk', 'lolcode', 'lotusformulas', 'lotusscript', 'lscript', 'lsl2', 'lua', 'm68k', 'magiksf', 'make', 'mapbasic', 'matlab', 'mirc', 'mmix', 'modula2', 'modula3', 'mpasm', 'mxml', 'mysql', 'nagios', 'netrexx', 'newlisp', 'nsis', 'oberon2', 'objc', 'objeck', 'ocaml-brief', 'ocaml', 'octave', 'oobas', 'oorexx', 'oracle11', 'oracle8', 'oxygene', 'oz', 'parasail', 'parigp', 'pascal', 'pcre', 'per', 'perl', 'perl6', 'pf', 'php-brief', 'php', 'pic16', 'pike', 'pixelbender', 'pli', 'plsql', 'postgresql', 'povray', 'powerbuilder', 'powershell', 'proftpd', 'progress', 'prolog', 'properties', 'providex', 'purebasic', 'pycon', 'pys60', 'python', 'q', 'qbasic', 'rails', 'rebol', 'reg', 'rexx', 'robots', 'rpmspec', 'rsplus', 'ruby', 'sas', 'scala', 'scheme', 'scilab', 'sdlbasic', 'smalltalk', 'smarty', 'spark', 'sparql', 'sql', 'stonescript', 'systemverilog', 'tcl', 'teraterm', 'text', 'thinbasic', 'tsql', 'typoscript', 'unicon', 'upc', 'urbi', 'uscript', 'vala', 'vb', 'vbnet', 'vedit', 'verilog', 'vhdl', 'vim', 'visualfoxpro', 'visualprolog', 'whitespace', 'whois', 'winbatch', 'xbasic', 'xml', 'xorg_conf', 'xpp', 'yaml', 'z80', 'zxbasic');
     /*
      * Loop throught each available programming languages
      */
     foreach ($code as $highlight) {
         // using regex is worth to save some lines :)
         preg_match_all('/\\[' . $highlight . '\\].*?\\[\\/' . $highlight . '\\]/s', $string, $out);
         if (!empty($out[0])) {
             foreach ($out[0] as $multi) {
                 $no_tag = preg_replace('/\\[\\/?.*\\]/', '', $multi);
                 $geshi = new GeSHi($no_tag, $highlight);
                 $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
                 $geshi->set_overall_style('background: #414141;width:100%;');
                 $geshi->set_header_type(GESHI_HEADER_PRE_VALID);
                 $geshi->set_case_keywords(GESHI_CAPS_LOWER);
                 $geshi->set_symbols_style('color: white;', false, 1);
                 $geshi->set_symbols_style('color: #B3F9FF;', false, 2);
                 $geshi->set_methods_style(1, 'color: white;');
                 $geshi->set_strings_style('color: yellow;', false, 'HARD');
                 $geshi->set_strings_style('color: yellow;', false);
                 $geshi->set_numbers_style('color: #FF80E5;');
                 $geshi->set_escape_characters_style('color: #FF80E5;');
                 $geshi->set_regexps_style(1, 'color: white;');
                 $geshi->set_regexps_style(0, 'color: white;');
                 $geshi->set_keyword_group_style(1, 'color: #FF8B8B;', true);
                 $geshi->set_keyword_group_style(2, 'color: #B3F9FF;', true);
                 $geshi->set_keyword_group_style(3, 'color: #B3F9FF;', true);
                 $geshi->set_keyword_group_style(4, 'color: #B3F9FF;', true);
                 $geshi->set_keyword_group_style(5, 'color: #B3F9FF;', true);
                 $geshi->set_keyword_group_style(6, 'color: #B3F9FF;', true);
                 $string = str_replace($multi, $geshi->parse_code(), $string);
             }
         }
     }
     return $string;
 }
开发者ID:shahril96,项目名称:Old-Skool,代码行数:38,代码来源:mybb_class.php

示例5: format_author

<?php 
echo format_author($page['lastlog']['author_name']);
echo ' [' . $page['lastlog']['author_datetime'] . ']';
?>
</div>
<div class="commitmessage">
<pre>
<?php 
echo htmlentities_wrapper($page['lastlog']['message_full']);
?>
</pre>
</div>
<div class="file" style="overflow:auto;">
<?php 
if (isset($page['html_data'])) {
    echo $page['html_data'];
} else {
    ?>
 
<pre><?php 
    //retrieve file extension
    $ext = substr($f, strrpos($f, '.') + 1, strlen($f) - strrpos($f, '.'));
    $geshi = new GeSHi($page['data'], $ext);
    $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
    $geshi->set_keyword_group_style(3, 'color: black; ', true);
    echo $geshi->parse_code();
    ?>
</pre>
</div>
<?php 
}
开发者ID:n3wtron,项目名称:viewgit,代码行数:31,代码来源:blob.php

示例6: dirname

*/
if ($_SERVER["argc"] < 3) {
    exit("Purpose: Syntax highlight PHP examples in XSLT generated manual.\r\n" . 'Usage: highlight.php [ "xml" | "php" ] [ filename.ext | dir | wildcard ] ...' . "\r\n");
}
set_time_limit(5 * 60);
// can run long, but not more than 5 minutes
ini_set("error_reporting", E_ALL);
// kill the E_STRICT warnings in GeSHi under PHP 5
require dirname(__FILE__) . '/geshi/geshi.php';
$geshi = new GeSHi('', 'php', dirname(__FILE__) . '/geshi/geshi');
$geshi->set_tab_width(4);
$geshi->set_overall_class('phpcode');
$geshi->set_overall_style('font-size: 85%', true);
$geshi->set_symbols_highlighting(false);
$geshi->set_strings_style('color: green', true);
$geshi->set_keyword_group_style(1, 'color: #d09010; font-weight: bold', true);
$geshi->set_numbers_style('color: #aa0000; font-weight: bold', true);
$geshi->set_methods_style('color: black; font-style: italic', true);
$geshi->set_regexps_style(0, 'color: #004090', true);
// use this to get updated stylesheet info if changed via abovementioned API
// file_put_contents('style.css', $geshi->get_stylesheet());
function callback_html_number_entities_decode($matches)
{
    return chr($matches[1]);
}
function callback_highlight_php($matches)
{
    $with_tags = trim(html_entity_decode($matches[1]));
    global $geshi;
    $geshi->set_language('php');
    $geshi->set_overall_class('phpcode');
开发者ID:phpsource,项目名称:doc-gtk,代码行数:31,代码来源:highlight.php

示例7: get_queries

    private function get_queries()
    {
        global $wpdb;
        if (QUERY_CACHE_TYPE_OFF) {
            $wpdb->query('SET SESSION query_cache_type = 0;');
        }
        $html = '';
        if ($wpdb->queries) {
            $total_time = timer_stop(FALSE, 22);
            $total_query_time = 0;
            $class = '';
            $html .= '<table class="mp-queries display" cellpadding="0" cellspacing="0" border="0" width="100%">';
            $html .= '<thead><tr>';
            $html .= '<th>' . __('ID') . '</th>';
            $html .= '<th>' . __('Time') . '</th>';
            $html .= '<th>' . __('Query') . '</th>';
            $html .= '<th>' . __('Called From') . '</th>';
            $html .= '</tr></thead><tbody>';
            if ($this->highlight_syntax) {
                $geshi = new GeSHi('', 'mysql');
                $geshi->set_header_type(GESHI_HEADER_NONE);
                $geshi->set_keyword_group_style(1, 'color: #000;', true);
                $geshi->set_keyword_group_style(5, 'color: #000;', true);
                $geshi->set_strings_style('color: #009;', false, 0);
            }
            $i = 0;
            foreach ($wpdb->queries as $query_entry) {
                $query = $query_entry[0];
                $time = $query_entry[1];
                $trace = $query_entry[2];
                $total_query_time += $time;
                $full_trace = $this->get_trace_by_query($query);
                $displayed_query = preg_replace('/[\\s]+/', ' ', $query);
                if ($this->highlight_syntax) {
                    $geshi->set_source($displayed_query);
                    $displayed_query = $geshi->parse_code();
                }
                if ($full_trace) {
                    $trace_html = $this->get_trace_html($full_trace);
                } else {
                    if ($this->display_files) {
                        $trace = explode(', ', $trace);
                        $trace = implode('<br />', $trace);
                    }
                    $trace_html = $trace;
                }
                $html .= '<tr' . $class . '>';
                $html .= '<td class="mp-column-id">' . ($i + 1) . '</td>';
                $html .= '<td class="mp-column-time">' . number_format($time, 8) . '</td>';
                $html .= '<td class="mp-column-query"><div class="mp-column-query-content">' . $displayed_query . '</div></td>';
                $html .= '<td class="mp-column-trace"><div class="mp-column-trace-content">' . $trace_html . '</div></td>';
                $html .= '</tr>';
                $i++;
            }
            $html .= '</tbody></table>';
            $html .= '
				<script type="text/javascript">
					jQuery(document).ready(function() {
						jQuery(".mp-queries").dataTable({
							"bPaginate": false,
							"bLengthChange": false
						});
						jQuery(".mp-queries .mp-column-trace-content").each(function() {
							jQuery(this).scrollTop(jQuery(this)[0].scrollHeight);
						});
					});
				</script>
			';
        }
        $php_time = $total_time - $total_query_time;
        $mysql_percentage = number_format_i18n($total_query_time / $total_time * 100, 2);
        $php_percentage = number_format_i18n($php_time / $total_time * 100, 2);
        $html .= '<ul class="mp-general-stats">';
        $html .= '<li><strong>' . __('Total query time:') . ' ' . number_format_i18n($total_query_time, 5) . __('s for') . ' ' . count($wpdb->queries) . ' ' . __('queries.') . '</strong></li>';
        if (count($wpdb->queries) != get_num_queries()) {
            $html .= '<li><strong>' . __('Total num_query time:') . ' ' . timer_stop() . ' ' . __('for') . ' ' . get_num_queries() . ' ' . __('num_queries.') . '</strong></li>';
            $html .= '<li class="none_list">' . __('&raquo; Different values in num_query and query? Please set the constant') . ' <code>define(\'SAVEQUERIES\', true);</code> ' . __('in') . ' <code>wp-config.php</code>.</li>';
        }
        if ($total_query_time == 0) {
            $html .= '<li class="none_list">' . __('&raquo; Query time is null (0)? Please set the constant') . ' <code>SAVEQUERIES</code> ' . ' ' . __('at') . ' <code>true</code> ' . __('in') . ' <code>wp-config.php</code>.</li>';
        }
        $html .= '<li>' . __('Page generated in') . ' ' . number_format_i18n($total_time, 5) . __('s (') . $php_percentage . __('% PHP') . ', ' . $mysql_percentage . __('% MySQL') . ')</li>';
        $html .= '</ul>';
        $html .= '<p class="mp-final-message">Be sure to deactivate MySQL Profiler when you\'ve finished debugging!</p>';
        return $html;
    }
开发者ID:sq1agency,项目名称:wordpress-vagrant-starter-kit,代码行数:86,代码来源:mysql_profiler.php


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