本文整理汇总了PHP中GeSHi::set_strings_highlighting方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::set_strings_highlighting方法的具体用法?PHP GeSHi::set_strings_highlighting怎么用?PHP GeSHi::set_strings_highlighting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeSHi
的用法示例。
在下文中一共展示了GeSHi::set_strings_highlighting方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
/**
* Initialise a GeSHi object to format some code, performing
* common setup for all our uses of it
*
* @note Used only until MW 1.20
*
* @param string $text
* @param string $lang
* @return GeSHi
*/
public static function prepare( $text, $lang ) {
global $wgSyntaxHighlightKeywordLinks;
self::initialise();
$geshi = new GeSHi( $text, $lang );
if( $geshi->error() == GESHI_ERROR_NO_SUCH_LANG ) {
return null;
}
$geshi->set_encoding( 'UTF-8' );
$geshi->enable_classes();
$geshi->set_overall_class( "source-$lang" );
$geshi->enable_keyword_links( $wgSyntaxHighlightKeywordLinks );
// If the source code is over 100 kB, disable higlighting of symbols.
// If over 200 kB, disable highlighting of strings too.
$bytes = strlen( $text );
if ( $bytes > 102400 ) {
$geshi->set_symbols_highlighting( false );
if ( $bytes > 204800 ) {
$geshi->set_strings_highlighting( false );
}
}
return $geshi;
}
示例2: prepare
/**
* Initialise a GeSHi object to format some code, performing
* common setup for all our uses of it
*
* @param string $text
* @param string $lang
* @return GeSHi
*/
public static function prepare($text, $lang)
{
global $wgSyntaxHighlightKeywordLinks;
self::initialise();
$geshi = new GeSHi($text, $lang);
if ($geshi->error() == GESHI_ERROR_NO_SUCH_LANG) {
return null;
}
$geshi->set_encoding('UTF-8');
$geshi->enable_classes();
$geshi->set_overall_class("source-{$lang}");
$geshi->enable_keyword_links($wgSyntaxHighlightKeywordLinks);
// If the source code is over 100 kB, disable higlighting of symbols.
// If over 200 kB, disable highlighting of strings too.
$bytes = strlen($text);
if ($bytes > 102400) {
$geshi->set_symbols_highlighting(false);
if ($bytes > 204800) {
$geshi->set_strings_highlighting(false);
}
}
/**
* GeSHi comes by default with a font-family set to monospace, which
* causes the font-size to be smaller than one would expect.
* We append a CSS hack to the default GeSHi styles: specifying 'monospace'
* twice "resets" the browser font-size specified for monospace.
*
* The hack is documented in MediaWiki core under
* docs/uidesign/monospace.html and in bug 33496.
*/
// Preserve default since we don't want to override the other style
// properties set by geshi (padding, font-size, vertical-align etc.)
$geshi->set_code_style('font-family: monospace, monospace;', true);
// No need to preserve default (which is just "font-family: monospace;")
// outputting both is unnecessary
$geshi->set_overall_style('font-family: monospace, monospace;', false);
return $geshi;
}