I was hoping to use CKeditor with GeSHi, but I have some serious difficulties. What happens if I create a new piece of content, then turn off CKeditor, so I just write simple HTML, I can wrap the snipptet code in <pre> </pre> tags. If I save then, GeSHi will do its job perfectly and the snippet will look good.
However, if I try to edit this piece of content, CKeditor will mess up with code formatting, in particular replacing a lot of characters with special escape sequences, and also try to close what, in his opinion, are HTML tags, but actually C ++ include files, for example #include <iostream> will make CKeditor place </iostream> at the end of the text. Then, at best, my code just looks bad.
In other cases, the behavior is really strange: the page does not load and instead gives me a server error. I assume that because on the server side, some changes made by CKeditor to the code snippet cause GeSHi to crash or vice versa.
Here is a sample code that looked correct after I entered it in a text editor and wrapped it in <pre> tags:
// 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; }
However, simply by clicking โChange,โ then โSave Again," without making any changes, CKeditor gets confused with the code, which now looks like this:
// 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; }</fstream></iostream>
Does anyone have any thoughts on this, or can anyone recommend a good alternative to the system I'm trying to use now? I am not very attached to CKeditor or GeSHi, although I am still pleased with CKeditor and I like the fact that GeSHi does MATLAB formatting. In addition, in accordance with the answer / comment below, I have already tried Petr Petrik's approach outlined here , and malfunctioning still occurred.
Thanks.