关于Windows Live Writer的代码高亮插件bug修改

旧地址:http://blog.canself.com/codehighlight_wlwplugin/

背景:在使用WLW向自己Wordpress网站发布文章后,第二次修改,在修改代码时总是会把<pre>标签一起放到code中;同时,其中的‘<’符号亦是使用html里的符号,修改代码会很不方便。【插件为针对SyntaxHighligter进行开发】

不得以下载SourceCode plugin for Windows Live Writer源码自行修改。

其中主要修改了两个代码段

1、修改<pre>标签总是被处理到代码区问题【原因为自己博客那边传过来的pre转大写了】

1
2
3
4
5
6
7
8
//在CodeForm.cs文件的Code属性的set中修改
//修改前:
int preFrom = value.IndexOf(prePrefix);
int fromPos = value.IndexOf(preSuffix);

//修改后:
int preFrom = value.ToLower().IndexOf(prePrefix);
int fromPos = value.ToLower().IndexOf(preSuffix);

2、修改“<”等符号表示为html中的格式【对传入的content进行格式转换——见高亮代码】

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//修改SourceCodePluginl.cs文件中的CreateContent方法
public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content)
{
DialogResult result = DialogResult.Cancel;
content = HtmlServices.HtmlDecode(content);
using (CodeForm form = new CodeForm(content))
{
result = form.ShowDialog(dialogOwner);
if (result == DialogResult.OK)
{
content = form.Code;
}
}
return result;
}

SourceCode plugin for Windows Live Writer源码地址:点击进入

更改后的插件下载:下载地址1下载地址2