在众多的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')) {
, O r1 r/ c# B+ I/ h. f4 o. L $arr['syntaxhighlight'] = array($ @$ i& f" j) A% C3 Q
'name' => 'syntaxhighlight',! y2 v% S; d6 w( R
'desc' => t('Syntaxhighlight plugin'),& J# {' k0 O1 R( [ u1 k
'path' => base_path() . $editor_path . 'plugins/syntaxhighlight/',+ ~) ^, t0 r4 @/ S9 P+ `) v* t; h
'default' => 'f'! ?. d% N) m& _# q" f
);
7 ?6 v, d' Y! y) t } 接下来去管理页面安装模块,配置模块吧。 - 启动语法高亮模块。 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叠加而引起错误。 |