本文整理汇总了PHP中GeSHi::set_symbols_style方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::set_symbols_style方法的具体用法?PHP GeSHi::set_symbols_style怎么用?PHP GeSHi::set_symbols_style使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeSHi
的用法示例。
在下文中一共展示了GeSHi::set_symbols_style方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
//.........这里部分代码省略.........
示例2: 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;
}