Drupal:尝试在 CKeditor 中使用 GeSHi

标签 drupal syntax-highlighting ckeditor geshi

我希望将 CKeditor 与 GeSHi 一起使用,但我遇到了一些重大困难。发生的情况是,如果我创建了一个新内容,然后禁用 CKeditor,这样我就可以编写纯 HTML,我可以在 <pre> </pre> 中附上代码片段。标签。如果我然后保存,GeSHi 会很好地完成它的工作,并且代码段看起来不错。

但是,如果我然后尝试编辑那段内容,CKeditor 会弄乱代码的格式,特别是用特殊的转义序列替换很多字符,并且还试图关闭它认为是 HTML 标签但实际上是 C++ 的内容文件,例如#include <iostream>将使 CKeditor 放置一个 </iostream>在文末。然后,在最好的情况下,我的代码看起来很糟糕。

在其他情况下,行为真的很奇怪:页面不会加载,而是给我一个服务器错误。我认为这是因为,在服务器端,CKeditor 对代码片段所做的一些更改导致 GeSHi 崩溃,反之亦然。

这是我在纯文本编辑器中逐字输入并将其包含在 <pre> 中后看起来正确的示例代码。标签:

// All rights reserved
// Email: firstname.lastname@url.com
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include <iostream>
#include <fstream>

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

myClass::myClass()
{
    m_lthing = NULL;
    m_athing = NULL;
    m_bthing = NULL;

    m_lthingthing = NULL;
    m_athingthing = NULL;
    m_bthingthing = NULL;
}

但是,只需单击编辑然后再次保存而不进行任何更改会使 CKeditor 代码困惑,现在看起来像这样:
// All rights reserved
// Email: firstname.lastname@url.com
//////////////////////////////////////////////////////////////////////

#include &quot;stdafx.h&quot;
#include <iostream>
#include <fstream>

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

myClass::myClass()
{
    m_lthing = NULL;
    m_athing = NULL;
    m_bthing = NULL;

    m_lthingthing = NULL;
    m_athingthing = NULL;
    m_bthingthing = NULL;
}</fstream></iostream>

有没有人对此有任何想法,或者任何人都可以推荐我现在尝试使用的系统的一个很好的替代方案?我对 CKeditor 或 GeSHi 并不是特别喜欢,尽管到目前为止我对 CKeditor 总体上很满意,而且我喜欢 GeSHi 进行 MATLAB 格式化的事实。另外,根据下面的回答/评论,我已经尝试过 Peter Petrik 概述的方法 here ,并且仍然发生崩溃行为。

谢谢。

最佳答案

你使用的是哪个版本的 Drupal/CKEditor/GeSHi?我会验证输入格式(管理员/设置/过滤器)并确保您使用的任何格式都不会用其他过滤器弄乱您的代码。还要验证允许的 HTML 标签。

关于Drupal:尝试在 CKeditor 中使用 GeSHi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5100310/

相关文章:

php - 如何使 "test"MySQL 服务器完整?

javascript - 如何将 id 或 class 添加到 Drupal 中的表单元素?

drupal - 显示区 block 中的节点信息

javascript - 有没有占用空间小、格式漂亮的 JavaScript 语法荧光笔?

javascript - CkEditor 无法设置未定义的属性 'dir'

php - 不使用Drupal CMS的views_slideshow

syntax - 如何在我的网站上放置网络文字处理器?

c# - RichTextBox语法实时高亮--禁用重绘

jQuery - 使用 CKeditor 就地编辑

javascript - 无法将 ckeditor 4 选择移至开头