且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

带有语法着色的HTML编辑器的jQuery插件

更新时间:2023-10-02 16:22:16

使用 CodeMirror .它是Google用于其API运动场的荧光笔.

Use CodeMirror. It's the highlighter used by Google for their API playground.

我已经尝试过了,并且效果很好,并且根据他们的网站,它可以在以下浏览器中运行:

I've tried it and it works well, and according to their site it works in the following browsers:

  • Firefox 1.5或更高版本
  • Internet Explorer 6或更高版本
  • Safari 3或更高版本
  • Opera 9.52或更高版本
  • Chrome

我不明白您为什么在这种情况下提及jQuery,因为jQuery与您需要执行的操作无关,除了它的选择器引擎之外,该选择器引擎可用于查找要为其启用语法突出显示的文本框(尽管如果您在其上放置id,则也不需要jQuery.)

I don't understand why you mention jQuery in this case, since jQuery has nothing relevant to what you need to do, other than its selector engine which could be used to find the textbox you want to enable syntax highlighting for (although if you put an id on it you shouldn't need jQuery for that either.)

***使用专门为解决手头任务而设计的独立库(CodeMirror是这样).您将获得***性能,并且开发人员将更易于维护,从而确保更好的质量.代码.

It's better to go with a stand-alone library that is especially designed to solve the task at hand (which CodeMirror is.) You'll get maximum performance and it'll be much more maintainable by the developers, ensuring better quality of the code.