Javascript syntax coloring engine (Demo and package file download)

Source: Internet
Author: User

I sorted out the Javascript syntax coloring engine I wrote last year and provided the download. Even if you like it
In general, it is very simple. It only provides the coloring of keywords and some basic syntaxes (such as comments, strings, and regular expressions). It is easy to see its usage in the demo, here is a brief introduction:
Class Name: lighter
You can use new lighter () to obtain a coloring engine instance, which is assumed to be lighter. It has the following attributes and methods:
Language attribute: lighter. Language
The range of this attribute can be added by yourself based on the number of syntax files. The provided demo contains four syntax files: 'cpp ', 'js', 'xml', and 'java, you are welcome to provide more syntax files :)
Coloring method: lighter. Highlight (CODE)
This is the core coloring function, and the code needs to be colored. CodeThe method returns the colored code, and the color of the Code is implemented using HTML tags.
Syntax Extension: lighter. addlanguage (object)
This is a static method called by class name. The parameter is a JavaScript Object and contains syntax keyword information. For details, see the format extension syntax file in lang/demo. js. An independent syntax file can be directly tagged with <SCRIPT> links in HTML, or dynamically loaded using the $ import method provided. Note that the syntax file must be added before class instantiation after class definition.
Existing syntax file: lighter. supportedlanguages
It is also a static attribute, indicating a set of currently supported languages.

Demo address: http://www.supnate.com/codelighter/demo.html
: Http://www.supnate.com/codelighter/X2CodeLighter.rar

Local download

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.