国外设计欣赏网站 - DOOOOR.com

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,微信登陆

搜索

[Drupal教程] Drupal7环境下安装语法高亮CKEditor+syntax highlighter

[复制链接]
发表于 1-27-2012 01:03 | 显示全部楼层 |阅读模式

在众多的Druapl语法高亮插件中,syntax highlighter是最好用的插件,因此,Drupal7+CKEditor+syntax highlighter环境也是最好的。

下面将是讲述如何安装CKEditor+syntax highlighter。

最终安装效果:

  1. 下载 Ckeditor  和  Syntax highlighter  模块。
  2. 下载  Syntax highlighter library 解压到 sites/all/libraries
  3. 下载  CKeditor library 解压到 ../Ckeditor/Ckeditor (一般是 sites/all/modules/Ckeditor/Ckeditor)
  4. 下载  ckeditor-syntaxhighlight 插件,解压到 ../Ckeditor /Ckeditor/plugins(一般是 "sites/all/modules/Ckeditor/Ckeditor/plugins" ,务必确认解压的目标文件夹为 Ckeditor/Ckeditor,而不是 Ckeditor/plugins)。
  5. 在文件  /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 }

接下来去管理页面安装模块,配置模块吧。

  1. 启动语法高亮模块。 admin/config/content/syntaxhighlighter
    ckedito<img  data-cke-saved-src=
  2. 调整相应的HTML 过滤顺序。admin/config/content/formats
    ckeditor-syntax highlighter
  3. 设置 CKeditor 模块。 admin/config/content/ckeditor
    1# 开启语法高亮。
    ckeditor-syntax highlighter
    2# 开启<pre>标签

    3# 在CKEditor 工具栏中 添加 {code} 按钮。
    ckeditor-syntax highlighter
    4# 开启 语法高亮 插件
    Ckeditor-syntax-highlighter
     
  4. 大公告成。

​*注:要谨慎选择 “ Inject js/css code on specific pages ”,在不需要开启代码高亮的页面应该关闭它,否则会因为JS或CSS叠加而引起错误。

 

|2011-2026-版权声明|平台(网站)公约|DOOOOR 设计网 ( 吉ICP备2022003869号 )

GMT+8, 4-30-2025 13:55 , Processed in 0.298114 second(s), 62 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表