程序代码语法加亮插件比较

Note: this entry has moved.

程序代码语法加亮插件是写BLOG程序员的必选,我试用过多款插件,最终选定功能比较强大的有两款:Code Syntax HighlighterSource Code Formatter,看我BLOG的人可以知道,我以前的BLOG一直使用Source Code Formatter,那是因为一直没有试用Code Syntax Highlighter,通过比较我发现Code Syntax Highlighter的表现力更好,以下是一个简单的比较:

Source Code Formatter的C#效果,选中了自动折行和带行号:

  
  
1 public override object SaveState( object container) 2 { 3 XmlDocument document = (XmlDocument)container; 4 XmlElement element = (XmlElement) base .SaveState(container); 5 6 // Save settings. 7 XmlElement nodeRootElement = document.CreateElement( " nodes " ); 8 element.AppendChild(nodeRootElement); 9 10 this .StoreNode(document, nodeRootElement, this .xmlSpecialCharNode, " SpecialCharNode " ); 11 this .StoreNode(document, nodeRootElement, this .xmlTagNode, " TagNode " ); 12 this .StoreNode(document, nodeRootElement, this .xmlNamespaceNode, " NamespaceNode " ); 13 this .StoreNode(document, nodeRootElement, this .xmlCommentNode, " CommentNode " ); 14 this .StoreNode(document, nodeRootElement, this .xmlAttributeNameNode, " AttributeNameNode " ); 15 this .StoreNode(document, nodeRootElement, this .xmlAttributeValueNode, " AttributeValueNode " ); 16 17 return element; 18 }

Code Syntax Highlighter的C#表现效果,选中了带行号:

1.        public override object SaveState(object container)
2.        {
3.            XmlDocument document = (XmlDocument)container;
4.            XmlElement element = (XmlElement)base.SaveState(container);
5.
6.            // Save settings.
7.            XmlElement nodeRootElement = document.CreateElement("nodes");
8.            element.AppendChild(nodeRootElement);
9.
10.            this.StoreNode(document, nodeRootElement, this.xmlSpecialCharNode, "SpecialCharNode");
11.            this.StoreNode(document, nodeRootElement, this.xmlTagNode, "TagNode");
12.            this.StoreNode(document, nodeRootElement, this.xmlNamespaceNode, "NamespaceNode");
13.            this.StoreNode(document, nodeRootElement, this.xmlCommentNode, "CommentNode");
14.            this.StoreNode(document, nodeRootElement, this.xmlAttributeNameNode, "AttributeNameNode");
15.            this.StoreNode(document, nodeRootElement, this.xmlAttributeValueNode, "AttributeValueNode");
16.
17.            return element;
18.        }

可以看出Code Syntax Highlighter的代码更紧凑,语法着色也更丰富。来看看它们的选项:

 Code
Formatter
Code
Highlighter
支持语言数1422
显示行号支持支持
显示边框不支持支持
改变背景色支持支持
自动折行支持支持
固定宽度不支持支持
自定义TAB宽度支持不支持

 

Code Syntax Highlighter的源代码有两个小问题:

1. 对中文注释的支持有问题
2. 不支持Live Writer Wave 3 Beta

前者是因为它对RTF文件的处理有点问题,后者是因为它使用的WindowsLive.Writer.Controls.BrowseButton 在Wave 3里面不再存在了。

我对代码做了修改,以上两个BUG都做了改正。

1. 修改RTF编码保证正常显示中文。
2. 使用WindowsLive.Writer.Controls.BitmapButton代替WindowsLive.Writer.Controls.BrowseButton ,同时支持14.x和15.x。
3. 同步了最新版本的Wilco SyntaxHighlighting。

Code Syntax Highlighter: 程序下载修改的源代码下载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值