Cyotek.Web.BbCodeFormatter/PlainTextProcessor.cs
Download
cyotek.web.bbcodeformatter.zip
(7.12 KB | 18 March 2010 )
A simple to use class library for converting text containing BBCode used by popular forum systems into HTML using C#.
Donate
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Contents of cyotek.web.bbcodeformatter.zip/Cyotek.Web.BbCodeFormatter/PlainTextProcessor.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Cyotek.Web.BbCodeFormatter
{
public static class PlainTextProcessor
{
static List<IHtmlFormatter> _formatters;
static PlainTextProcessor()
{
_formatters = new List<IHtmlFormatter>();
_formatters.Add(new SearchReplaceFormatter("\r", ""));
_formatters.Add(new SearchReplaceFormatter("\n\n", "</p><p>"));
_formatters.Add(new SearchReplaceFormatter("\n", "<br />"));
}
public static string Format(string data)
{
foreach (IHtmlFormatter formatter in _formatters)
data = formatter.Format(data);
return "<p>" + data + "</p>";
}
}
}
