一只想有一个直接能在博客里显示代码的功能,看了一下BlogEngine.net的插件,发现有一个叫“CodeFormatterExtension(beta)”的,基本上就是他了。可是点击"view",发现显示“Source for [X:\你的路径\BlogEngine.NET\App_Code\Extensions\CodeFormatterExtension.cs] not found ”,没有找到文件,再查看我的“App_Code\Extensions”文件夹,发现有一个叫做“CodeFormatter”的文件夹,哦,这么回事,可能是beta版的原因,没有使用。所以,如果想使用这个插件,请把“CodeFormatter.cs”文件移动到“App_Code\Extensions”文件夹,并更名为“CodeFormatterExtension.cs”,好了,可以使用了。目前只支持c#,javascript,vb,t-sql等,格式如[code:c#][/code](需要转换为半角)。测试如下:
c#:
class HelloWorldApp
{
static void Main()
{
System.Console.WriteLine("Hello, world!");
}
}
Sql:
[code:tsql]
CREATE TABLE message (text char(15));
INSERT INTO message (text) VALUES ('Hello, world!');
SELECT text FROM message;
DROP TABLE message;
javascript:
document.writeln('Hello, world!');
xml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Hello, world!</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
html:
<html>
<head></head>
<body>
<div>Hello World!</div>
</body>
</html>