如何在CKeditor中以原始格式输入代码

如何在CKeditor中以原始格式输入代码,ckeditor,Ckeditor,我将使用CKeditor在其中发布一些代码,但它不能保持stackoverflow中显示的原始代码格式,例如: public void Test() { for (int i = 0; i < 100; i++) { System.IO.File.AppendAllText(@"c:\tmp\d.txt", $"a: {i}\n"); System.Threading.Thread.Sleep(1000); } } 公共无效测试

我将使用CKeditor在其中发布一些代码,但它不能保持stackoverflow中显示的原始代码格式,例如:

  public void Test()
{
    for (int i = 0; i < 100; i++)
    {
        System.IO.File.AppendAllText(@"c:\tmp\d.txt", $"a: {i}\n");
        System.Threading.Thread.Sleep(1000);
    }
}
公共无效测试()
{
对于(int i=0;i<100;i++)
{
System.IO.File.AppendAllText(@“c:\tmp\d.txt”,$“a:{i}\n”);
系统线程线程睡眠(1000);
}
}
但在ckeditor中,它将显示如下:


public void Test(){for(int i=0;i<100;i++){System.IO.File.AppendAllText(@“c:\tmp\d.txt,$“a:{i}\n”);System.Threading.Thread.Sleep(1000);}}}

你想使用一个专用的插件,就像这样。

我使用了代码片段plus,但当我发布它时,它在我的html页面中无法工作,它只在我的ckeditor实例中工作,因此看起来您的后端正在剥离
pre
code
HTML元素。这才是问题所在,而不是编辑本身。