时间:2021-05-28
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 的升级版,不过,SyntaxHighlighter还不能在 CKEditor 中实现代码高亮) 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.
Can't be bothered reading all this? View the online demo or download the plugin and go play with it yourself.
Correctly installed, the plugin is in the form of a tabbed dialogue box that looks like this:(插件安装好以后的效果)
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.
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
Extract the contents of the zip in your plugins directory, so it ends up like this:(基本的目录结构如下)
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.(注意这里的命名)
Now add in yourfckconfig.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') ;Add the button 'SyntaxHighLight2' button to your toolbarset:
1.FCKConfig.ToolbarSets["Basic"] = [2.['Bold','Italic','-','OrderedList','UnorderedList','-','Link','Unlink', '-','SyntaxHighLight2','-','About']3.] ;The plugin will work 'out of the box', but you can configure a default language using the SyntaxHighlight2LangDefaultparameter:
1.FCKConfig.SyntaxHighlight2LangDefault = 'csharp' ;The full list of languages and corresponding codes are:
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.}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.
Nowclear your browser cache (this stage is important!) and reload the editor, the new button should be ready to use.
There's some additional functionality I might add at a later date:
Thanks goes to Alex Gorbatchev for creating Syntax Highlighter!.
打包下载地址:
/201004/yuanma/FCKEditor-syntaxhighlight.rar
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
FCKeditor是现在最为流行的开源编辑器,SyntaxHighlighter是一个用JS实现的代码高亮显示插件,可以最小化修改您的程序实现效果,最终效果截图
SyntaxHighlighter是一个使用JavaScript编写的支持多种编程语言语法高亮的JS插件,很多大型网站或博客都在使用。SyntaxHighlig
SyntaxHighlighter.js是一个代码高亮的JS插件,使用也很简单,但是由于是浏览器段执行JS代码来着色,会出现视觉上闪一下的效果。比如你的20行代
用SyntaxHighlighter语法高亮插件的朋友可能都遇到过代码显示不换行的问题,这个问题在网上也找不到什么解决办法,一直困扰了我很久,今天算是把它解决了
下载地址:http:///p/syntaxhighlighter/附一个小例子说一下textarea和pre的区别复制代码代码如下:高亮测试程序源代码放在这儿a