Test 'Google Syntax Highlighter for WordPress'

Google Syntax Highlighter for WordPress插件,見此

Google Syntax Highlighter,見此

### Function: Display The Post Views
function the_views($display = true) {
	$post_views = intval(post_custom('views'));
	$views_options = get_option('views_options');
	if($post_views <= 1) {
		$output = str_replace('%VIEW_COUNT%', number_format_i18n($post_views) . ' View', $views_options['template']);
	} else {
		$output = str_replace('%VIEW_COUNT%', number_format_i18n($post_views) . ' Views', $views_options['template']);
	}
	if($display) {
		echo $output;
	} else {
		return $output;
	}
}

dp.sh.Brushes.JScript = function()
{
	var keywords =	'abstract boolean break byte case catch char class const continue debugger ' +
					'default delete do double else enum export extends false final finally float ' +
					'for function goto if implements import in instanceof int interface long native ' +
					'new null package private protected public return short static super switch ' +
					'synchronized this throw throws transient true try typeof var void volatile while with';

	this.regexList = [
		{ regex: dp.sh.RegexLib.SingleLineCComments,				css: 'comment' },			// one line comments
		{ regex: dp.sh.RegexLib.MultiLineCComments,					css: 'comment' },			// multiline comments
		{ regex: dp.sh.RegexLib.DoubleQuotedString,					css: 'string' },			// double quoted strings
		{ regex: dp.sh.RegexLib.SingleQuotedString,					css: 'string' },			// single quoted strings
		{ regex: new RegExp('^\\s*#.*', 'gm'),						css: 'preprocessor' },		// preprocessor tags like #region and #endregion
		{ regex: new RegExp(this.GetKeywords(keywords), 'gm'),		css: 'keyword' }			// keywords
		];

	this.CssClass = 'dp-c';
}

dp.sh.Brushes.JScript.prototype	= new dp.sh.Highlighter();
dp.sh.Brushes.JScript.Aliases	= ['js', 'jscript', 'javascript'];

NOTE: One important thing to watch out for is opening triangular bracket <. It must be replaced with an HTML equivalent of &lt; in all cases. Failure to do won't break the page, but might break the source code displayed.

Leave a Reply