Social Icons

twitterfacebookgoogle plusrss feedemail

12/25/2012

[Blogger] 文章中嵌入程式碼

blogger與wordpress都是很多人在用的blog系統 在blogger中如果想要貼上自己的程式碼,又不想要醜醜的顯示,可以參考以下的顯示方式
<?php
$example = range(0, 9);
foreach ($example as $value)
{
 echo $value;
}
首先尋找到你的佈景主題的這個標籤在哪 接下來把下面這串貼在它之後
<!--SYNTAX HIGHLIGHTER BEGINS-->
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"></link>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript"></script>
<script language="javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
<!--SYNTAX HIGHLIGHTER ENDS-->
接著只要在文中用<pre> 把程式碼貼在<pre></pre>中即可,如下
Your 'HTML' code goes here
支持的語言:
http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/
其它語言
http://www.undermyhat.org/blog/2009/09/list-of-brushes-syntaxhighligher/
換主題:
http://alexgorbatchev.com/SyntaxHighlighter/manual/themes/
控制技巧
http://alexgorbatchev.com/SyntaxHighlighter/manual/configuration/
如果程式碼顯示不正常,請先做轉換
http://www.csie.ntu.edu.tw/~piaip/unihtml/
http://formatmysourcecode.blogspot.tw/
http://www.elliotswan.com/postable/

沒有留言:

張貼留言

俗話說
凡走過必留下痕跡,凡住過必留下鄰居
凡爬過必留下樓梯,凡來過必留下IP
看過文章之後歡迎留下您寶貴的意見喔!

 
 
无觅相关文章插件,迅速提升网站流量