Introduction(简介)

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.

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:(插件安装好以后的效果)

FCKeditor 和 SyntaxHighlighter 代码高亮插件的整合

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(安装配置过程)

1. Copying the files(拷贝文件)

Extract the contents of the zip in your plugins directory, so it ends up like this:(基本的目录结构如下)

FCKeditor 和 SyntaxHighlighter 代码高亮插件的整合

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.pre 02.{ 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 FCKeditor 和 SyntaxHighlighter 代码高亮插件的整合 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 

标签:
FCKeditor,SyntaxHighlighter,代码高亮插件

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
内蒙古资源网 Copyright www.nmgbbs.com

《魔兽世界》大逃杀!60人新游玩模式《强袭风暴》3月21日上线

暴雪近日发布了《魔兽世界》10.2.6 更新内容,新游玩模式《强袭风暴》即将于3月21 日在亚服上线,届时玩家将前往阿拉希高地展开一场 60 人大逃杀对战。

艾泽拉斯的冒险者已经征服了艾泽拉斯的大地及遥远的彼岸。他们在对抗世界上最致命的敌人时展现出过人的手腕,并且成功阻止终结宇宙等级的威胁。当他们在为即将于《魔兽世界》资料片《地心之战》中来袭的萨拉塔斯势力做战斗准备时,他们还需要在熟悉的阿拉希高地面对一个全新的敌人──那就是彼此。在《巨龙崛起》10.2.6 更新的《强袭风暴》中,玩家将会进入一个全新的海盗主题大逃杀式限时活动,其中包含极高的风险和史诗级的奖励。

《强袭风暴》不是普通的战场,作为一个独立于主游戏之外的活动,玩家可以用大逃杀的风格来体验《魔兽世界》,不分职业、不分装备(除了你在赛局中捡到的),光是技巧和战略的强弱之分就能决定出谁才是能坚持到最后的赢家。本次活动将会开放单人和双人模式,玩家在加入海盗主题的预赛大厅区域前,可以从强袭风暴角色画面新增好友。游玩游戏将可以累计名望轨迹,《巨龙崛起》和《魔兽世界:巫妖王之怒 经典版》的玩家都可以获得奖励。