在众多的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')) {. k# n7 z9 `8 X" X2 i
$arr['syntaxhighlight'] = array() ?+ G" G; C& h# Y5 ~, }/ q5 j( a
'name' => 'syntaxhighlight',# V) J W! M9 y3 B& n, [
'desc' => t('Syntaxhighlight plugin'),$ a+ F: x* T- q$ t0 w v% g" q
'path' => base_path() . $editor_path . 'plugins/syntaxhighlight/',0 L" c; y+ b$ ~+ g) p1 [" m- e, _
'default' => 'f'
4 C* q, p0 S' J @# `9 b- a );
5 f" N' F$ _" P2 m% |. s1 V } 接下来去管理页面安装模块,配置模块吧。 - 启动语法高亮模块。 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叠加而引起错误。 |