JavaScript - Text Areas with Code Syntax Highlighting
Jump to navigation
Jump to search
About
NOTE: This page is a daughter page of: JavaScript - Syntax Highlighting
The HTML textarea
element is limited to just text - it cannot do color syntax highlighting easily. To achieve colored highlighting, various people/groups have created JavaScript libraries.
These are summarized here:
- Comparison of JavaScript-based source code editors - Wikipedia - lists a bunch.
Looking at the forums, there are two that stand out:
- Code Mirror (html demo) (Google kml example)
- For which I did a hello world here: JavaScript - Syntax Highlighting - CodeMirror Hello World
- Ace Editor (kitch sink demo)
I'd also like to create a "do it yourself" guide, once I figure out if it's easy to do just really simply highlighting where you can specify a few words or regex to highlight.
Code license | For all of the code on my site... if there are specific instruction or licence comments please leave them in. If you copy my code with minimum modifications to another webpage, or into any code other people will see I would love an acknowledgment to my site.... otherwise, the license for this code is more-or-less WTFPL (do what you want)! If only copying <20 lines, then don't bother. That said - if you'd like to add a web-link to my site www.andrewnoske.com or (better yet) the specific page with code, that's a really sweet gestures! Links to the page may be useful to yourself or your users and helps increase traffic to my site. Hope my code is useful! :)
|