引言
syntaxhighlighter的目的是不依赖任何服务器端脚本即可在网页上插入着色后的代码
目标客户
主要是针对博客。不过,我看到了一些源码网站使用它作为其主要展示源代码的工具。
不适合客户
syntaxhighlighter不是针对那种强调在线编辑高亮代码的客户设计的,它不会让您编辑源代码,它不能这样做也绝不会这样做。
性能
syntaxhighlighter使用正则表达式解析源码。它不是非常快,事实上,它的速度相当缓慢。如果您想尝试百十行代码,您将不会看到任何问题。如果要高亮超过10k的源码,由于JavaScript运行时间过长会导致程序中止
SyntaxHighlighter is here to help a developer/coder to post code snippets online with ease and have it look pretty. It's 100% Java Script based and it doesn't care what you have on your server.
Features Summary of features.
SyntaxHighlighter features
- 100% client side, no server dependency
- Multiple languages support
- Easy to use and deploy, just copy files and link them in your templates
- Wide browser support
- Very lightweight, compressed core library is 11kb plus whatever brushes you need.
Languages List of supported languages.
Supported languagesHere's a list of supported languages and their aliases:
Language | Aliases |
C++ | cpp, c, c++ |
C# | c#, c-sharp, csharp |
CSS | css |
Delphi | delphi, pascal |
Java | java |
Java Script | js, jscript, javascript |
PHP | php |
Python | py, python |
Ruby | rb, ruby, rails, ror |
Sql | sql |
VB | vb, vb.net |
XML/HTML | xml, html, xhtml, xslt |
Usage How to use SyntaxHighlighter.
UsagePlacing the codePlace your code on the page and surround it with
tag. Set name attribute to code and class attribute to one of the language aliases you wish to use.... some code here ...NOTE: One important thing to watch out for is opening triangular bracket <. It must be replaced with an HTML equivalent of < in all cases. Failure to do won't break the page, but might break the source code displayed.
An alternative tois to use Extended configurationThere's a way to pass a few configuration options to the code block. It's done via colon separated arguments.Making it workFinally, to get the whole thing to render properly on the page, you have to add JavaScript to the page.... some code here ...
type="text/css" rel="stylesheet" href="css/SyntaxHighlighter.css"><script language="javascript" src="js/shCore.js"></script><script language="javascript" src="js/shBrushCSharp.js"></script><script language="javascript" src="js/shBrushXml.js"></script><script language="javascript">dp.SyntaxHighlighter.ClipboardSwf = '/flash/clipboard.swf';dp.SyntaxHighlighter.HighlightAll('code');</script>For optimal result, place this code at the very end of your page. Check HighlightAll for more details about the function.
下载
Filename | Summary + Labels | Uploaded | Size | DownloadCount | ... | |
SyntaxHighlighter_1.5.1.rar | 1.5.1 Featured | Aug 05 | 39.3 KB | 22152 |
本文转自
http://www.mikecat.net/space/viewspacepost.aspx?postid=52