syntaxhighlighter 使用方法
Placing the code
Place your code on the page and surround it with <pre> tag. Set name attribute to code and class attribute to one of the language aliases you wish to use.
<pre name="code" class="c-sharp"> ... some code here ... </pre>
NOTE: One important thing to watch out for is opening triangular bracket <. It must be replaced with an HTML equivalent of < in all cases. Failure to do won't break the page, but might break the source code displayed.
An alternative to <pre> is to use <textarea> tag. There are no problems with < character in that case. The main problem is that it doesn't look as good as <pre> tag if for some reason JavaScript didn't work (in RSS feed for example).
<textarea name="code" class="c#" cols="60" rows="10"> ... some code here ... </textarea>
Extended configuration
There's a way to pass a few configuration options to the code block. It's done via colon separated arguments.
<pre name="code" class="html:collapse"> ... some code here ... </pre>
Making it work
Finally, to get the whole thing to render properly on the page, you have to add JavaScript to the page.
<link type="text/css" rel="stylesheet" href="css/SyntaxHighlighter.css"></link> <script language="javascript" src="js/shCore.js"></script> <script language="javascript" src="js/shBrushCSharp.js"></script> <script language="javascript" src="js/shBrushXml.js"></script> <script language="javascript"> dp.SyntaxHighlighter.ClipboardSwf = '/flash/clipboard.swf'; dp.SyntaxHighlighter.HighlightAll('code'); </script>
For optimal result, place this code at the very end of your page. Check HighlightAll for more details about the function.
下載地址:SyntaxHighlighter_1.5.0.zip
- SyntaxHighlighter 去掉右側(cè)滾動(dòng)條的方法
- 防止SyntaxHighlighter.js的代碼高亮?xí)r閃一下的解決方法
- SyntaxHighlighter自動(dòng)識(shí)別并加載腳本語(yǔ)言
- z-blog SyntaxHighlighter 長(zhǎng)代碼無(wú)法換行解決辦法(基于jquery)
- SyntaxHighlighter 3.0.83使用筆記
- ckeditor syntaxhighlighter代碼高亮插件配置分享
- CKEditor中加入syntaxhighlighter代碼高亮插件
- z-blog SyntaxHighlighter 長(zhǎng)代碼無(wú)法換行解決辦法(jquery)
- 解決SyntaxHighlighter 代碼高亮不換行問(wèn)題的解決方法
- FCKeditor + SyntaxHighlighter 讓代碼高亮著色插件
- 代碼著色之SyntaxHighlighter項(xiàng)目(最流行的代碼高亮)
- syntaxhighlighter 去掉右上角問(wèn)號(hào)圖標(biāo)的三種方法
- 為SyntaxHighlighter添加新語(yǔ)言的方法
- SyntaxHighlighter配合CKEditor插件輕松打造代碼語(yǔ)法著色
- SyntaxHighlighter語(yǔ)法高亮插件使用說(shuō)明
- ckeditor syntaxhighlighter代碼高亮插件,完美修復(fù)
- coolcode轉(zhuǎn)SyntaxHighlighter與Mysql正則表達(dá)式實(shí)現(xiàn)分析
- FCKeditor 和 SyntaxHighlighter 代碼高亮插件的整合
- SyntaxHighlighter 語(yǔ)法高亮插件的使用教程
- 使用SyntaxHighlighter實(shí)現(xiàn)HTML高亮顯示代碼的方法
- FCKEditor SyntaxHighlighter整合實(shí)現(xiàn)代碼高亮顯示
- SyntaxHighlighter代碼加色使用方法
- 關(guān)于實(shí)現(xiàn)代碼語(yǔ)法標(biāo)亮 dp.SyntaxHighlighter
- SyntaxHighlighter?Autoloader(自動(dòng)加載)最優(yōu)方式
相關(guān)文章
JS利用時(shí)間戳倒計(jì)時(shí)的實(shí)現(xiàn)示例
這篇文章主要介紹了JS利用時(shí)間戳倒計(jì)時(shí)的實(shí)現(xiàn)示例,本文將提供代碼示例和詳細(xì)的步驟,幫助你實(shí)現(xiàn)一個(gè)簡(jiǎn)單而實(shí)用的時(shí)間戳倒計(jì)時(shí),感興趣的可以了解一下2023-12-12js實(shí)現(xiàn)股票實(shí)時(shí)刷新數(shù)據(jù)案例
下面小編就為大家?guī)?lái)一篇js實(shí)現(xiàn)股票實(shí)時(shí)刷新數(shù)據(jù)案例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-05-05Javascript 實(shí)現(xiàn)匿名遞歸的實(shí)例代碼
本篇文章主要介紹了Javascript 實(shí)現(xiàn)匿名遞歸的實(shí)例代碼,利用 arguments.callee 來(lái)實(shí)現(xiàn)匿名遞歸的方式。有興趣的可以了解一下2017-05-05Jvascript學(xué)習(xí)實(shí)踐案例(開發(fā)常用)
一些在Jvascript學(xué)習(xí)實(shí)踐的實(shí)例代碼,需要的朋友可以參考下2012-06-06js拖動(dòng)滑塊和點(diǎn)擊水波紋效果實(shí)例代碼
在本文里面我們給大家分享了js實(shí)現(xiàn)拖動(dòng)滑塊和點(diǎn)擊水波紋效果的相關(guān)實(shí)例代碼,有需要的朋友們學(xué)習(xí)下。2018-10-10小程序api實(shí)現(xiàn)promise封裝過(guò)程解析
這篇文章主要介紹了小程序api實(shí)現(xiàn)promise封裝過(guò)程解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-11-11BootStrap的alert提示框的關(guān)閉后再顯示怎么解決
這篇文章主要介紹了BootStrap的alert提示框的關(guān)閉后再顯示問(wèn)題的相關(guān)資料,需要的朋友可以參考下2016-05-05