Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sgbj/bbcodeparser

A BBCode parser for the .NET framework
https://github.com/sgbj/bbcodeparser

Last synced: 8 days ago
JSON representation

A BBCode parser for the .NET framework

Awesome Lists containing this project

README

        

BBCodeParser
============

A BBCode parser for the .NET framework.

The parser and lexer were generated with ANTLR 4.

Configuring and adding new BBCode rules is simple and easy.

Examples
--------

```csharp
var bbc = new BBC();

bbc["[code]{text}[/code]"] =
_ => "

" + _.text + "
";

bbc["[b]{text}[/b]"] =
_ => "" + bbc.Transform(_.text) + "";

bbc["[i]{text}[/i]"] =
_ => "" + bbc.Transform(_.text) + "";

bbc["[date/]"] =
_ => DateTime.Now.ToShortDateString();

bbc["[url={url}]{text}[/url]"] =
_ => "" + _.text + "";

Console.WriteLine(bbc.Transform("[date/] [b]this is bold[/b] and [code]this is [b]code[/b][/code]\nand this is [b]bold [i]italic[/i][/b]\n[url='http://google.com']test[/url]"));
```

Or for the default BBCode->HTML support, just do:

```csharp
Console.WriteLine(BBCode.Basic().Transform("[b]Awesome[/b]"));
```