FCKeditor 和 SyntaxHighlighter 代碼高亮插件的整合
Introduction(簡(jiǎn)介)
This is a dialog-based plugin to handle formatting of source code for FCKeditor 2.5.x. It WON'T work with the new CKEditor (yet).(CKEditor 是FCKEditor 的升級(jí)版,不過(guò),SyntaxHighlighter 還不能在 CKEditor 中實(shí)現(xiàn)代碼高亮) It makes use of the SyntaxHighlighter 2.0.x javascript library available to download from Alex Gorbatchev's project page (the older version 1.5.1 version is available from Google Code).
The plugin primiarily edits a <pre> tag with some custom attributes. Its mainly aimed at users editing blogs or content management systems where there is a requirement to format programming languages on a website that is being edited using FCKEditor.
The plugin will not format the code in FCKEditor - the SyntaxHighlighter javascript library dynamically generates a lot of formatted HTML at runtime, which would cause problems in FCKEditor.
Skip straight to the good bits
Can't be bothered reading all this? View the online demo or download the plugin and go play with it yourself.
So what do I get then?
Correctly installed, the plugin is in the form of a tabbed dialogue box that looks like this:(插件安裝好以后的效果)

Version history:(版本歷史)
Huge thanks goes to Sergey Gurevich who wrote the updated code for the FCKEditor plugin to handle the latest version of the SyntaxHighlighter code and submitted useful bug fixes.
- v2.1.0 [23 May 2009]
- Plugin version information now being displayed
- Line highlighting feature added
Download | Demo
- v2.0.1 [22 March 2009]
Minor bug fix where semi-colons were sometimes positioned in the wrong place when no advanced options were selected
Download
- v2.0 [2 March 2009]
Latest version supporting SyntaxHighlighter 2.0.x
- v1.0.2 [2 March 2009]
Bug fixes, final release supporting the older SyntaxHighlighter 1.5.1
Note the instructions below are for the newer version of the library and makes references to syntaxhighlight2 a lot, this version uses syntaxhighlight. The documentation in the download will be more accurate.
Download.| Demo
- v1.0.1 [10 Feb 2009].
- v1.0 [30 Nov 2008]. First version.
Known bugs:
Occasionally the dialogue box does not pickup the <pre> element to be edited in Firefox. It only seems to happen when a user clicks inside the <pre> tag with the mouse but doesn't actually move or interact with the cursor.
Fixed in version 1.0.2 - Thanks to Sergey Gurevich
Installation(安裝配置過(guò)程)
1. Copying the files(拷貝文件)
Extract the contents of the zip in your plugins directory, so it ends up like this:(基本的目錄結(jié)構(gòu)如下)

Note: Version 2 of the plugin must be extracted to a directory named 'syntaxhighlighter2'. The older plugin for the earlier version of the library must go in a folder named 'syntaxhighlighter'. The file fckplugin.js references this directory when the plugin initialises.(注意這里的命名)
2. Adding it to FCKeditor(將它添加到 FCKeditor)
Now add in your fckconfig.js or custom js configuration file the following line (remember its javascript we are dealing with so everything is case sensitive!):
1.FCKConfig.Plugins.Add( 'syntaxhighlight2', 'en') ;3. Adding it to the toolbarset
Add the button 'SyntaxHighLight2' button to your toolbarset:
1.FCKConfig.ToolbarSets["Basic"] = [2.['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink', '-','SyntaxHighLight2','-','About']3.] ;4. Configure the plugin
The plugin will work 'out of the box', but you can configure a default language using the SyntaxHighlight2LangDefault parameter:
1.FCKConfig.SyntaxHighlight2LangDefault = 'csharp' ;The full list of languages and corresponding codes are:
-
- c++ - C++
- csharp - C#
- css - CSS
- delphi - Delphi
- java - Java
- jscript - Java Script
- php - PHP
- python - Python
- ruby - Ruby
- sql - SQL
- vb - VB.NET
- xhtml - XML/HTML
In FCKEditor <pre> blocks aren't really formatted by default. I suggest editing your fck_editorarea.css (or equivalant if you are using a custom CSS file) to something that highlights code blocks better. eg:
01.pre02.{03. background-color: #fff;04. font-family: "Consolas" , "Courier New" ,Courier,mono,serif;05. font-size: 12px;06. color: blue;07. padding: 5px;08. border: 1px dashed blue;09.}Configuring SyntaxHighlighter.
You must have SyntaxHighlighter installed and working to display properly formatted code. FCKEditor does not need it, but for code to be properly formatted on your website you must have it configurated correctly. For SyntaxHighlighter2 Alex Gorbatchev's site has loads of excellent information (he wrote it after all!), for the old version 1.5.1 library, the project wiki here is a good resouce, or this blog post might also be useful.
5. Use it
Now clear your browser cache (this stage is important!) and reload the editor, the new button
should be ready to use.
6. Future updates
There's some additional functionality I might add at a later date:
- Preview tab using the SyntaxHighlighter library
- More configuration options, eg, available languages, path to SyntaxHighlighter files
- Dynamically adding a <pre> formatting style to the editor by default
7. And finally...
Thanks goes to Alex Gorbatchev for creating Syntax Highlighter!.
腳本之家打包下載地址:
/201004/yuanma/FCKEditor-syntaxhighlight.rar
- 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)分析
- SyntaxHighlighter 語(yǔ)法高亮插件的使用教程
- 使用SyntaxHighlighter實(shí)現(xiàn)HTML高亮顯示代碼的方法
- FCKEditor SyntaxHighlighter整合實(shí)現(xiàn)代碼高亮顯示
- SyntaxHighlighter代碼加色使用方法
- syntaxhighlighter 使用方法
- 關(guān)于實(shí)現(xiàn)代碼語(yǔ)法標(biāo)亮 dp.SyntaxHighlighter
- SyntaxHighlighter?Autoloader(自動(dòng)加載)最優(yōu)方式
相關(guān)文章
myFocus 一個(gè)KindEditor的焦點(diǎn)圖插件
使用KindEditor(富文本編輯器)提供的接口將myFocus(焦點(diǎn)圖庫(kù))集成在KindEditor上2011-04-04
ckeditor和ueditor那個(gè)好 CKEditor和UEditor使用比較
本來(lái)項(xiàng)目中使用CKEditor已經(jīng)做好了的富文本編輯器的功能,但是業(yè)務(wù)考慮到美觀性要求換成UEditor,所以就在這里總結(jié)下,需要的朋友可以參考下2017-03-03
FckEditor 中文配置手冊(cè)詳細(xì)說(shuō)明
首先,FCKEDITOR的性能是非常好的,用戶(hù)只需很少的時(shí)間就可以載入FCKEDITOR所需文件.對(duì)于其他在線編輯器來(lái) 說(shuō),這幾乎是個(gè)很難解決的難題2009-05-05
關(guān)于jsp版ueditor1.2.5的部分問(wèn)題解決(上傳圖片失敗)
這篇文章主要介紹大家在使用jsp版ueditor1.2.5的碰到的一些問(wèn)題解決方法,需要的朋友可以參考下2013-06-06
最新版CKEditor的配置方法及插件(Plugin)編寫(xiě)示例
本文記錄配置CKEditor過(guò)程,并以文章分頁(yè)插件為例,簡(jiǎn)要CKEditor Plugin編寫(xiě)過(guò)程。 從官網(wǎng)http://ckeditor.com/download下載最新版CKEditor,解壓2017-03-03
Windows Live Writer 實(shí)現(xiàn)代碼高亮
有時(shí)會(huì)包含大量代碼,如果能在文章中高亮顯示代碼文章的可讀性肯定會(huì)好很多。2009-05-05
使用 CodeMirror 打造屬于自己的帶高亮顯示的在線代碼編輯器
寫(xiě)這個(gè)的目的是因?yàn)橹绊?xiàng)目里用到過(guò) CodeMirror,覺(jué)得作為一款在線代碼編輯器還是不錯(cuò),也看到過(guò)有些網(wǎng)站用到過(guò)在線代碼編輯,當(dāng)然我不知道他們是用什么做的2018-02-02

