public static string FormatContentAsHTML(string content) { HtmlFormatter formatter = new HtmlFormatter(); StringWriter writer = new StringWriter(); HtmlFormatterOptions options = new HtmlFormatterOptions(' ', 0, 80, HtmlFormatterCase.LowerCase, HtmlFormatterCase.LowerCase, false); formatter.Format(content, writer, options); return(writer.GetStringBuilder().ToString()); }
public static string FormatContentAsXHTML(string content, string rootTag) { // first format HtmlFormatter formatter = new HtmlFormatter(); StringWriter writer = new StringWriter(); HtmlFormatterOptions options = new HtmlFormatterOptions(' ', 0, 80, true); string contentRoot = "<" + rootTag + " xmlns=\"http://www.w3.org/1999/xhtml\">" + content + "</" + rootTag + ">"; formatter.Format(contentRoot, writer, options); return(writer.GetStringBuilder().ToString()); }