Archive Browser
Download cyotek.web.bbcodeformatter.zip, last updated 18/03/2010 (7.12 KB)
Download- md5: e33d27a1760bd48f92ea2556322c392f
using System.Text.RegularExpressions;
using System.Web;
using Manoli.Utils.CSharpFormat;
namespace Cyotek.Web.BbCodeFormatter
{
internal class SyntaxFormatter : RegexFormatter
{
#region Private Member Declarations
private SourceFormat _formatter;
#endregion Private Member Declarations
#region Public Constructors
public SyntaxFormatter(SourceFormat formatter, string pattern, string replace)
: this(formatter, pattern, replace, true)
{ }
public SyntaxFormatter(SourceFormat formatter, string pattern, string replace, bool ignoreCase)
: base(pattern, replace, ignoreCase)
{
_formatter = formatter;
}
#endregion Public Constructors
#region Public Overridden Methods
public override string Format(string data)
{
return base.Regex.Replace(data, SyntaxMatcher);
}
#endregion Public Overridden Methods
#region Private Methods
private string SyntaxMatcher(Match match)
{
return match.Result(string.Format(base.Replace, _formatter.FormatCode(HttpUtility.HtmlDecode(match.Groups[1].Value)))); // need to call htmldecode as all html was encoded before getting here. If you don't encode the source data, then remove this call.
}
#endregion Private Methods
}
}
Donate
This software may be used free of charge, but as with all free software there are costs involved to develop and maintain.
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Donate