#region using using System; using System.Text.RegularExpressions; using BlogEngine.Core; using BlogEngine.Core.Web.Controls; #endregion /// /// Converts Post Snippets to HTML /// [Extension("Converts Post Snippets to HTML", "1.0.0.0", "BlogEngine.NET")] public class Snippets { public Snippets() { Post.Serving += new EventHandler(Post_Serving); } /// /// The event handler that is triggered every time a comment is served to a client. /// private void Post_Serving(object sender, ServingEventArgs e) { string body = e.Body; Parse(ref body, "NordicTrackPic", ""); Parse(ref body, "NordicTrack", "Nordic Track"); e.Body = body; } /// /// Parses the Snippet into a Url or Image with hyperlink to larger Nordic Track Image /// private static void Parse(ref string body, string code, string urlText) { string imgPath = "http://dbvt.com/images/utils/nordictrack.jpg"; int start = body.IndexOf("[" + code + "]", StringComparison.Ordinal); if (start > -1) { body = body.Remove(start, code.Length + 2); body = body.Insert(start, "" + urlText + ""); Parse(ref body, code, urlText); } } }