PlainText

This article is also available in English!This article is also available in English!

PlainText 是 BlogEngine 的一个插件,它的功能是为了让你能在启用插件的同时,允许某些需要在文章中显示,却同时被插件识别为关键字的文字能正常显示。比如,你想要在一篇文章中,向读者展示 CodeFormatter 的语法,你将需要在文章中输入类似于 [code:C#] 和 [/code] 这样的标记,不幸的是,当 CodeFormatter 插件启用时,你无法让这些文字显示出来,他们被插件自动转化成相应的功能,并将这些标记隐藏了起来。如果使用 PlainText 插件,就可以决定每一个标记是否被插件识别。

以下是未使用 PlainText 忽略识别功能的时候,一段文字被自动转化的结果:

private static void DoSomething(object sender)
{
  foreach (int i = 0; i < 10; i++)
  {
    ...
    ...
  }
}

以下是使用了 PlainText 忽略识别功能的时候,同一段文字的显示:

[code:c#]
private static void DoSomething(object sender)
{
  foreach (int i = 0; i < 10; i++)
  {
    ...
    ...
  }
}
[/code]

这样你就能输入任何一个标记而不担心标记的显示问题了,你甚至可以让标记起作用的同时,显示你所描述的标记,比如:

[code:c#]
private static void DoSomething(object sender)
{
  foreach (int i = 0; i < 10; i++)
  {
    ...
    ...
  }
}
[/code]

上面是如何做到的呢,使用 PlainText,在任何一个标记的左中括号后面,加入 p: 这个标记,比如要显示 [code] 标记,就输入:


[p:code]

那么此标记就不会被当作插件的标记处理,而这写文字最终被显示到文章中的效果是以下的形式:

[code]

 

 下载 PlainText.cs

 

 

This article is also available in English!

PlainText is an extension for BlogEngine, it can make a tag which is recognized by an extension to be ignored by the extension, and to be displayed in a post. For example, you want to show the CodeFormatter gramma to your readers, you need to type keywords like [code:c#] and [/code], but unfortunately, when CodeFormatter's enabled, you cannot make those tags to be displayed in your post, they're automatically transformed and hidden by the extension. If you use PlainText, you can decide every tag to be ignored by extensions or not.

Below code block is an example of using CodeFormatter:

private static void DoSomething(object sender)
{
  foreach (int i = 0; i < 10; i++)
  {
    ...
    ...
  }
}

Here's another code block showing the CodeFormatter's keywords, but being ignored:

[code:c#]
private static void DoSomething(object sender)
{
  foreach (int i = 0; i < 10; i++)
  {
    ...
    ...
  }
}
[/code]

You can also make it to show the keywords, but without ignoring the code block:

[code:c#]
private static void DoSomething(object sender)
{
  foreach (int i = 0; i < 10; i++)
  {
    ...
    ...
  }
}
[/code]

How did I do this? Insert p: after the left bracket of the tag which you'd like it to be ignored. For example, to show [code], then type:


[p:code]

and then this tag will not be regonized by an extension, it will be shown as "PlainText" in your post like this:

[code]

 

Download PlainText.cs

最新评论

Comment RSS