本文整理汇总了PHP中GeSHi::set_numbers_style方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::set_numbers_style方法的具体用法?PHP GeSHi::set_numbers_style怎么用?PHP GeSHi::set_numbers_style使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeSHi
的用法示例。
在下文中一共展示了GeSHi::set_numbers_style方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: jabFormatCode
function jabFormatCode($code)
{
@(include_once "geshi-1.0.8.6/geshi/geshi.php");
if (function_exists('geshi_highlight')) {
// Strip off language specifier
$language = null;
if (preg_match("/^{{(.*)}}\n+/", $code, $matches)) {
$language = $matches[1];
$code = preg_replace("/^{{(.*)}}\n+/", "", $code);
}
global $jab;
if ($language == null && isset($jab['syntax_language'])) {
$language = $jab['syntax_language'];
}
if ($language !== null) {
$geshi = new GeSHi($code, $language, null);
$geshi->set_header_type(GESHI_HEADER_NONE);
$geshi->line_ending = "\n";
$geshi->set_comments_style(1, 'color: #008200;');
$geshi->set_comments_style('MULTI', 'color: #008200;');
$geshi->set_strings_style('color: #848200');
$geshi->set_numbers_style('');
return "<pre><code>" . $geshi->parse_code() . "</code></pre>";
}
}
return "<pre><code>" . htmlspecialchars($code, ENT_NOQUOTES) . "</code></pre>";
}
示例2: 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
//.........这里部分代码省略.........
示例3: 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;
}
示例4: 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');
// because last line changes it