In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "Javascript how to achieve a super grammar highlighting engine", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Javascript how to achieve a super grammar highlighting engine" article.
SyCODE Syntax Highlighter has the characteristics of high speed and strong expansibility, it can easily complete the code highlighting processing of 32KB on a current mainstream PC, and can complete the code highlighting processing of 64KB at one time without the slow prompt of script. Syntax highlighting processing of any programming language can be realized by adding different regular expressions.
Syntax highlighting in more than 20 languages has been implemented within SyCODE Syntax Highlighter 1.0, including:
1. C _ blank +
2. C#
3. CSS
4. Delphi/Kylix
5. Pascal
6. Java
7. Vb/Vb.net
8. J (ava) Script
9. ActionScript
10. Php
11. Python
12. Ruby/Rails
13. Perl
14. Assembly
15. Bat batch processing
16. UNIX Shell
18. AWK
19. Sql
20. Xml/xhtml
Example: Highlighter.Execute (cleanCode, language)
Effect:
Var Highlighter = {
Brushes: {}
RegexLib: {
MultiLineCComments: new RegExp ('/\ * [\\ s\\ S] *?\\ * /', 'gm')
SingleLineCComments: new RegExp ('/. * $', 'gm')
SingleLinePerlComments: new RegExp ('#. * $', 'gm')
DoubleQuotedString: new RegExp ('"(?:\\. | (\") | [^\ "\\ n]) *",'g')
SingleQuotedString: new RegExp ("'(?:\\. | (\') | [^\'\\ n]) *','g')
}
Match: function (value, index, css) {
This.value = value
This.index = index
This.length = value.length
This.css = css
}
Execute: function (str,lang) {
Var registered = new Object ()
For (var brush in Highlighter.Brushes)
{
Var aliases = Highlight. Brushes.aliases
If (aliases = = null) continue
For (var itemositani}
If (!! registered [lang.toLowerCase ()]) {
Var ht = new Highlighter.Brushes [registered [lang.toLowerCase [)] ()
Return ht.Highlight (str)
}
Else {
Str = str.replace (/ & / g,'&')
Str = str.replace (/ str = str.replace (/ > / g,'>')
Str = str.replace (/\ t Compact g,'')
Str = str.replace (/ [] {2} / g,'')
Return str.replace (/\ nUnip g,'
')
}
}
}
The above is about the content of this article on "how to achieve a super grammar highlighting engine in Javascript". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.