21

I'm looking for a jQuery Plugin that will display a textarea for HTML authoring & editing.

The things I'm looking for:

  1. Must support authoring the HTML, not a WYSIWYG representation
  2. Must color the HTML as you type as any rich-client IDE would.
  3. Should be jQuery, but native JS would be OK too.

I have played with MarkItUp which gets me 90% there but offers no syntax coloring. And WYMeditor as far as I can tell has no option for "code view" and is instead just a WYSIWYG view.

Anybody out there done something like this in the past?

4 Answers 4

44

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 or higher
  • Internet Explorer 6 or higher
  • Safari 3 or higher
  • Opera 9.52 or higher
  • Chrome

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.)

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.

Sign up to request clarification or add additional context in comments.

2 Comments

+1 for CodeMirror and a virtual +1 for mentioning that jQuery is not the solution to all problems.
I agree that jQuery isn't the solution to all problems, but requesting a jQuery solution could imply 1) the dev "knows" jQuery, so if they have to customize it, they'll feel more comfortable. 2) zero to minimal configuration 3) jQuery abstracts browser differences, so as a dev, you may feel more "safe" that the plugin is better supported cross browser than a pure native solution.
5

You should also take a look at EditArea

It doesn't use jquery, but it won't conflict with it either.

Comments

4

Take a look at Ace, into which Mozilla merged their Skywriter/Bespin efforts. It supports over 60 languages with client-side code syntax highlighting. The source code is open and available on github.

Comments

1

Gotta go with Bespin by Mozilla. It's built using HTML5 features (so it's quick and fast, but doesn't support legacy browsers though), but definitely amazing to use and beats everything I've come across - probably beacause it's Mozilla backing it, and they develop Firefox so yeah... There's also a jQuery Plugin which contains a extension for it to make it a bit easier to use with jQuery.

1 Comment

@CodeClown and Skywriter is now called Ace (same source link as your one...) - weird correction to make...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.