using System.Web; using System.Web.Mvc; using MarkdownDeep; namespace Yavsc.Helpers { /// /// Helper class for transforming Markdown. /// public static partial class MarkdownHelper { /// /// Transforms a string of Markdown into HTML. /// /// The Markdown that should be transformed. /// The HTML representation of the supplied Markdown. public static IHtmlString Markdown(string text) { // Transform the supplied text (Markdown) into HTML. var markdownTransformer = new Markdown(); string html = markdownTransformer.Transform(text); // Wrap the html in an MvcHtmlString otherwise it'll be HtmlEncoded and displayed to the user as HTML :( return new MvcHtmlString(html); } /// /// Transforms a string of Markdown into HTML. /// /// HtmlHelper - Not used, but required to make this an extension method. /// The Markdown that should be transformed. /// The HTML representation of the supplied Markdown. public static IHtmlString Markdown(this HtmlHelper helper, string text) { // Just call the other one, to avoid having two copies (we don't use the HtmlHelper). return Markdown(text); } } }