SoFunction
Updated on 2025-04-13

Two ways to cancel escape by CKEditor

Speaking of which, programmers always use SyntaxHighlighter and other blogs to paste a bunch of code in the pre tag. So I always felt very annoying because I installed CKEditor for WordPress. I wrote some code in HTML tags, and it was escaped in Visual. For example, > and < become >&lt;Shrimps and shrimps. By the way, I went to Google on a whim today. There are really relevant settings in the settings document of CKEditor. Please watch here!

Configure the files in the ckeditor plug-in directory and add the following line.

Copy the codeThe code is as follows:
= false;

However, this is more violent, and all the content is no longer escaped. Is there anyone worried? So I found here that there is another way (as follows), using regular filtering of the code to be protected. This is very good for data, but there is a disadvantage: the protected content cannot be seen in the ckeditor WYSIWYG mode, it depends on your own choices.

Copy the codeThe code is as follows:
(/<pre[\s\S]*?pre>/g);

It seems that I still tend to use the former. The content pasted in the WYSIWYG tag will still be escaped, but the content from HTML is not escaped, which seems to be good. Independent blogs are really hard to do = =  It's so hard...