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)文章
javascript forEach通用循環(huán)遍歷方法
循環(huán)遍歷一個(gè)元素是開(kāi)發(fā)中最常見(jiàn)的需求之一,那么讓我們來(lái)看一個(gè)由框架BASE2和Jquery的結(jié)合版本吧.2010-10-10
詳解如何使用微信小程序云函數(shù)發(fā)送短信驗(yàn)證碼
這篇文章主要介紹了詳解如何使用微信小程序云函數(shù)發(fā)送短信驗(yàn)證碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-03-03
js判斷生效時(shí)間不得大于失效時(shí)間的思路及代碼
生效時(shí)間不得大于失效時(shí)間在一些推銷(xiāo)、優(yōu)惠方面還是比較實(shí)用的,接下來(lái)一起看下詳細(xì)的實(shí)現(xiàn)代碼,感興趣的朋友可以參考下哈,希望對(duì)你有所幫助2013-04-04
在線所見(jiàn)即所得HTML編輯器的實(shí)現(xiàn)原理淺析
這篇文章主要介紹了在線所見(jiàn)即所得HTML編輯器的實(shí)現(xiàn)原理淺析,本文用初始化、打開(kāi)編輯功能、獲取編輯器的內(nèi)容、增加樣式設(shè)置、再進(jìn)一步等步驟闡述在線編輯器的基本實(shí)現(xiàn)原理,需要的朋友可以參考下2015-04-04
javascript table排序 這個(gè)更簡(jiǎn)單了,不用改變現(xiàn)在的表格結(jié)構(gòu)
另外一個(gè)table排序,這個(gè)更簡(jiǎn)單了,不用改變現(xiàn)在的表格結(jié)構(gòu),來(lái)自國(guó)外的代碼。2010-04-04
js 操作table之 移動(dòng)TR位置 兼容FF 跟 IE
js操作table之 移動(dòng)TR位置 兼容FF 跟 IE,需要的朋友可以參考下。2009-11-11
Bootstrap的aria-label和aria-labelledby屬性實(shí)例詳解
這篇文章主要介紹了Bootstrap的aria-label和aria-labelledby屬性實(shí)例詳解,需要的朋友可以參考下2018-11-11

