本文整理匯總了PHP中GeSHi::add_keyword方法的典型用法代碼示例。如果您正苦於以下問題:PHP GeSHi::add_keyword方法的具體用法?PHP GeSHi::add_keyword怎麽用?PHP GeSHi::add_keyword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GeSHi
的用法示例。
在下文中一共展示了GeSHi::add_keyword方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: GeSHi
function ch_highlight_code($matches)
{
global $ch_options;
// undo nl and p formatting
$plancode = $matches[2];
$plancode = $this->entodec($plancode);
$geshi = new GeSHi($plancode, strtolower($matches[1]));
$geshi->set_encoding('utf-8');
$geshi->set_header_type(GESHI_HEADER_DIV);
$geshi->enable_classes(true);
$language = $geshi->get_language_name();
if ($language == 'PHP') {
$geshi->add_keyword(2, 'protected');
$geshi->add_keyword(2, 'private');
$geshi->add_keyword(2, 'abstract');
$geshi->add_keyword(2, 'static');
$geshi->add_keyword(2, 'final');
$geshi->add_keyword(2, 'implements');
} elseif ($language == 'Bash') {
$geshi->add_keyword(2, 'convert');
$geshi->add_keyword(2, 'git');
} elseif ($language == 'Vim Script') {
$geshi->add_keyword(1, 'endfunction');
}
if (ch_go('ch_b_linenumber')) {
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
}
$geshi->enable_strict_mode(ch_go('ch_b_strict_mode'));
$geshi->set_tab_width(ch_go('ch_in_tab_width'));
$geshi->set_overall_class('dean_ch');
$overall_style = '';
if (!ch_go("ch_b_wrap_text")) {
$overall_style .= 'white-space: nowrap;';
} else {
$overall_style .= 'white-space: wrap;';
}
if ($overall_style != '') {
$geshi->set_overall_style($overall_style, false);
}
return $geshi->parse_code();
}