JavaScript syntax coloring engine (demo and package file download) _ prototype

Source: Internet
Author: User
The JavaScript syntax coloring engine (demo and package file download) should be proud of the suggestions of little snake. I sorted out the JavaScript syntax coloring engine written last year and provided the download.
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. The code is the code to be colored. The 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 marked with a link in html using script, or it can be 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.