Codekicker.BBCode is a stable and performant BBCode-Parser for .NET. Transform any BBCode into HTML or into an in-memory syntax tree that can be analyzed or translated. All tags are fully customizable, nothing is hardcoded. Codekicker.BBCode is used in-the-field on http://codekicker.de which is a german question and answer site for programming questions.

The design goals of Codekicker.BBCode were:
  • Stable - it never ever crashes
  • Safe - it does not let through unsafe HTML like <script> under any circumstances
  • Performance - it is meant to be used in production
  • Easy to use - Just call BBCode.ToHtml("[url=http://codekicker.de]codekicker[url]")
  • Customizable - Customizing the translation of every tag is easy and flexible
  • Error messages - the messages are available in english and german. Language contributions are welcome.

Quickstart
Just call BBCode.ToHtml("[url=http://codekicker.de]codekicker[url]")

How do I customize the markup set?
            var parser = new BBCodeParser(new[]
                {
                    new BBTag("b", "<b>", "</b>"), 
                    new BBTag("i", "<span style=\"font-style:italic;\">", "</span>"), 
                    new BBTag("u", "<span style=\"text-decoration:underline;\">", "</span>"), 
                    new BBTag("code", "<pre class=\"prettyprint\">", "</pre>"), 
                    new BBTag("img", "<img src=\"${content}\" />", "", false, true), 
                    new BBTag("quote", "<blockquote>", "</blockquote>"), 
                    new BBTag("list", "<ul>", "</ul>"), 
                    new BBTag("*", "<li>", "</li>", true, false), 
                    new BBTag("url", "<a href=\"${href}\">", "</a>", new BBAttribute("href", ""), new BBAttribute("href", "href")), 
                });
            return parser.Transform("[b]bbcode[/b]");

Why is it as stable as we claim?
We have used Pex (http://research.microsoft.com/en-us/projects/Pex/) to extensively test some important properties of this BBCode-Parser. We used Pex to ensure that the parser never crashes and that it never emits any dangerous tag such as <script>, no matter what the input was. The user can type any HTML he wants but it will just get encoded, even when it is in unusual places like the href-attribute of the url-tag. If you have any questions about this you can post them on http//codekicker.de if you speak german. In other cases you can contact us by email in english.

Licence
This BBCode-parser is licensed unter the Creative Commons Attribution 3.0 Licence: http://creativecommons.org/licenses/by/3.0/. You can freely use and modify the code even commercially. Please help us spread the word: We require a link from anywhere on your corporate website or blog (or from a staff-member's personal blog).

Who can use it?
As this parser is written in C#, it can be used in any .NET-Language like C# or VB.NET. The reason why we wrote it is that all existing BBCode-parsers for .NET seem to be very buggy and immature. Now we don't have trouble anymore.

What else?
That's it. It is that easy to use. If you have questions, feature suggestion or bug reports (very unlikely) you can contact us at team@codekicker.de in english and german. If you do speak german you should instead post you question on http//codekicker.de.

Last edited Oct 6, 2011 at 3:27 PM by codekicker, version 16