在众多的Druapl语法高亮插件中,syntax highlighter是最好用的插件,因此,Drupal7+CKEditor+syntax highlighter环境也是最好的。 下面将是讲述如何安装CKEditor+syntax highlighter。 最终安装效果: 
- 下载 Ckeditor 和 Syntax highlighter 模块。
- 下载 Syntax highlighter library 解压到 sites/all/libraries
- 下载 CKeditor library 解压到 ../Ckeditor/Ckeditor (一般是 sites/all/modules/Ckeditor/Ckeditor)
- 下载 ckeditor-syntaxhighlight 插件,解压到 ../Ckeditor /Ckeditor/plugins(一般是 "sites/all/modules/Ckeditor/Ckeditor/plugins" ,务必确认解压的目标文件夹为 Ckeditor/Ckeditor,而不是 Ckeditor/plugins)。
- 在文件 /sites/all/modules/ckeditor/includes/ckeditor.lib.inc 314行左右,'plugins section' 后添加以下代码:
if (file_exists($editor_path . 'plugins/syntaxhighlight/plugin.js')) {
% C/ I5 w" |: F $arr['syntaxhighlight'] = array(
; r+ c' y3 E' A- i5 r 'name' => 'syntaxhighlight',
: K6 m4 M: _6 D. l2 O" z 'desc' => t('Syntaxhighlight plugin'),' x1 N" A2 l/ \4 ~$ j# i Z4 Q# n% O
'path' => base_path() . $editor_path . 'plugins/syntaxhighlight/',+ X8 m$ w% ]- ?) X {& g4 u
'default' => 'f'
8 o. F% [! q; ?- S );
$ [; H+ {' ^3 f } 接下来去管理页面安装模块,配置模块吧。 - 启动语法高亮模块。 admin/config/content/syntaxhighlighter
 - 调整相应的HTML 过滤顺序。admin/config/content/formats
 - 设置 CKeditor 模块。 admin/config/content/ckeditor
1# 开启语法高亮。
 2# 开启<pre>标签
 3# 在CKEditor 工具栏中 添加 {code} 按钮。
 4# 开启 语法高亮 插件
 - 大公告成。
*注:要谨慎选择 “ Inject js/css code on specific pages ”,在不需要开启代码高亮的页面应该关闭它,否则会因为JS或CSS叠加而引起错误。 |