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è)滾動條的方法
- 防止SyntaxHighlighter.js的代碼高亮?xí)r閃一下的解決方法
- SyntaxHighlighter自動識別并加載腳本語言
- z-blog SyntaxHighlighter 長代碼無法換行解決辦法(基于jquery)
- SyntaxHighlighter 3.0.83使用筆記
- ckeditor syntaxhighlighter代碼高亮插件配置分享
- CKEditor中加入syntaxhighlighter代碼高亮插件
- z-blog SyntaxHighlighter 長代碼無法換行解決辦法(jquery)
- 解決SyntaxHighlighter 代碼高亮不換行問題的解決方法
- FCKeditor + SyntaxHighlighter 讓代碼高亮著色插件
- 代碼著色之SyntaxHighlighter項目(最流行的代碼高亮)
- syntaxhighlighter 去掉右上角問號圖標(biāo)的三種方法
- 為SyntaxHighlighter添加新語言的方法
- SyntaxHighlighter配合CKEditor插件輕松打造代碼語法著色
- SyntaxHighlighter語法高亮插件使用說明
- ckeditor syntaxhighlighter代碼高亮插件,完美修復(fù)
- coolcode轉(zhuǎn)SyntaxHighlighter與Mysql正則表達(dá)式實現(xiàn)分析
- FCKeditor 和 SyntaxHighlighter 代碼高亮插件的整合
- SyntaxHighlighter 語法高亮插件的使用教程
- 使用SyntaxHighlighter實現(xiàn)HTML高亮顯示代碼的方法
- FCKEditor SyntaxHighlighter整合實現(xiàn)代碼高亮顯示
- SyntaxHighlighter代碼加色使用方法
- 關(guān)于實現(xiàn)代碼語法標(biāo)亮 dp.SyntaxHighlighter
- SyntaxHighlighter?Autoloader(自動加載)最優(yōu)方式
相關(guān)文章
Jvascript學(xué)習(xí)實踐案例(開發(fā)常用)
一些在Jvascript學(xué)習(xí)實踐的實例代碼,需要的朋友可以參考下2012-06-06BootStrap的alert提示框的關(guān)閉后再顯示怎么解決
這篇文章主要介紹了BootStrap的alert提示框的關(guān)閉后再顯示問題的相關(guān)資料,需要的朋友可以參考下2016-05-05