plugin_syntaxhighlight

0 views
Skip to first unread message

elleryq

unread,
Dec 19, 2007, 3:51:42 AM12/19/07
to blogger-ext2
這是我寫的一個很簡單的 syntaxhighlight plugin,主要是使用 dp.syntaxhighlight
使用前需先加入 dp.syntaxhighlight 相關 javascript,例如:
<script type="text/javascript" src='http://
syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/shCore.js'></
script>
<script type="text/javascript" src='http://
syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/
shBrushCSharp.js'></script>
<script type="text/javascript" src='http://
syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/
shBrushVb.js'></script>
<script type="text/javascript" src='http://
syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/
shBrushPhp.js'></script>
<script type="text/javascript" src='http://
syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/
shBrushJScript.js'></script>
<script type="text/javascript" src='http://
syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/
shBrushSql.js'></script>
<script type="text/javascript" src='http://
syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/
shBrushXml.js'></script>
<script type="text/javascript" src='http://
syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/
shBrushPython.js'></script>
<script type="text/javascript" src='http://
syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/
shBrushCss.js'></script>
<script type="text/javascript" src='http://
syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/
shBrushCpp.js'></script>

下面是 plugin 內容:
// Register dp.SyntaxHighLight
// Dependency:
// jQuery
// blogger-ext2-core
BloggerExt.SH = function() {
// Plugin 由此開始
if( dp!='undefined' ) {
jQuery("pre > br").each( function()
{ jQuery(this).replaceWith( "\n" ); } );
jQuery("textarea > br").each( function()
{ jQuery(this).replaceWith( "\n" ); } );
dp.SyntaxHighlighter.ClipboardSwf = 'http://
syntaxhighlighter.googlecode.com/svn/tags/1.5.1/Scripts/
clipboard.swf';
dp.SyntaxHighlighter.HighlightAll('code');
}
};
BloggerExt.SH.user_pref = function() {
var prefs = [];
return prefs;
};
BloggerExt.SH.update_pref = function(prefs) {
};
BloggerExt.register('SH', { SH: true} );
Reply all
Reply to author
Forward
0 new messages