本文整理汇总了PHP中GeSHi::set_comments_style方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::set_comments_style方法的具体用法?PHP GeSHi::set_comments_style怎么用?PHP GeSHi::set_comments_style使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeSHi
的用法示例。
在下文中一共展示了GeSHi::set_comments_style方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: GeSHi
}
include_once 'geshi/geshi.php';
$geshi = new GeSHi($contents, 'java');
$geshi->set_header_type(GESHI_HEADER_PRE);
$geshi->set_numbers_highlighting(false);
$geshi->set_overall_style('color: rgb(0,0,0); border: 1px solid #d0d0d0; background-color: #f0f0f0;', true);
// Note the use of set_code_style to revert colours...
$geshi->set_line_style('font: normal normal 95% \'Courier New\', Courier, monospace; color: black;', 'font-weight: bold; color: blue;', true);
//for methods
$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);
示例3: 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";
示例4: 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
//.........这里部分代码省略.........
示例5: processor_geshi
function processor_geshi($formatter, $value, $options)
{
global $DBInfo;
if (!defined('GESHI_VERSION')) {
return $formatter->processor_repl('vim', $value, $options);
}
$syntax = array('actionscript', 'ada', 'apache', 'asm', 'asp', 'bash', 'c', 'c_mac', 'caddcl', 'cadlisp', 'cpp', 'csharp', 'css-gen', 'css', 'delphi', 'html4strict', 'java', 'javascript', 'lisp', 'lua', 'nsis', 'objc', 'oobas', 'oracle8', 'pascal', 'perl', 'php-brief', 'php', 'python', 'qbasic', 'smarty', 'sql', 'vb', 'vbnet', 'visualfoxpro', 'xml');
if ($value[0] == '#' and $value[1] == '!') {
list($line, $value) = explode("\n", $value, 2);
}
# get parameters
if ($line) {
$line = substr($line, 2);
$tag = strtok($line, ' ');
$type = strtok(' ');
$extra = strtok('');
if ($tag != 'vim') {
$extra = $type;
$type = $tag;
}
}
$src = rtrim($value);
// XXX
if (!$type) {
$type = 'nosyntax';
}
$uniq = md5($extra . $value);
if ($DBInfo->cache_public_dir) {
$fc = new Cache_text('geshi', array('ext' => 'html', 'dir' => $DBInfo->cache_public_dir));
$htmlname = $fc->getKey($uniq, false);
$html = $DBInfo->cache_public_dir . '/' . $htmlname;
} else {
$cache_dir = $DBInfo->upload_dir . "/GeshiProcessor";
$html = $cache_dir . '/' . $uniq . '.html';
}
if (!is_dir(dirname($html))) {
$om = umask(00);
_mkdir_p(dirname($html), 0777);
umask($om);
}
if (file_exists($html) && !$formatter->refresh) {
$out = "";
$fp = fopen($html, "r");
while (!feof($fp)) {
$out .= fread($fp, 1024);
}
return $out;
}
# comment out the following two lines to freely use any syntaxes.
if (!in_array($type, $syntax)) {
return "<pre class='code'>\n{$line}\n" . htmlspecialchars($src) . "\n</pre>\n";
}
$geshi = new GeSHi($src, $type, dirname(__FILE__) . "/../../lib/geshi/geshi");
if ($extra == "number") {
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
}
if ($extra == "fancy") {
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
} else {
$geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS);
}
$out = '';
$geshi->set_comments_style(1, 'font-style: normal;');
$geshi->set_header_type(GESHI_HEADER_DIV);
#$geshi->set_header_type(GESHI_HEADER_PRE);
#$out = '<style type="text/css"><!--'.$geshi->get_stylesheet().'--></style>';
#$geshi->enable_classes();
$out .= $geshi->parse_code();
$fp = fopen($html, "w");
fwrite($fp, $out);
fclose($fp);
return $out;
}