public static string Process(string html) { string result = html; result = result.Replace("<font class=\"ms-rteCustom-GreyBox\" >", "<font class=\"ms-rteCustom-GreyBox\">"); result = result.Replace("<font class=\"ms-rteCustom-GreyBox\">", "<font class=\"ms-rteCustom-GreyBox\">"); result = HtmlHelper.ReplaceHtmlWithFencedBlock(result, "p", "ssw15-rteElement-GreyBox", "greybox"); result = HtmlHelper.ReplaceHtmlWithFencedBlock(result, "p", "ms-rteCustom-GreyBox", "greybox"); result = HtmlHelper.ReplaceHtmlWithFencedBlock(result, "font", "ms-rteCustom-GreyBox", "greybox"); result = HtmlHelper.ReplaceHtmlWithFencedBlock(result, "div", "scrum-GreyBox", "greybox"); result = HtmlHelper.ReplaceHtmlWithFencedBlock(result, "div", "greyBox", "greybox"); result = HtmlHelper.ReplaceHtmlWithFencedBlock(result, "div", "ms-rteCustom-GreyBox", "greybox"); result = HtmlHelper.ReplaceHtmlWithFencedBlock(result, "div", "ssw15-rteElement-GreyBox", "greybox"); result = HtmlHelper.ReplaceHtmlWithFencedBlock(result, "dt", "greybox", "greybox"); result = HtmlHelper.ReplaceHtmlWithFencedBlock(result, "p", "greyBox", "greybox"); result = HtmlHelper.ReplaceHtmlWithFencedBlock(result, "font", "greyBox", "greybox"); var boxes = HtmlHelper.GetGreyboxes(result); foreach (var box in boxes) { if (!string.IsNullOrEmpty(box)) { result = result.Replace(box, FencedBlocks.Create(box, "greybox")); } } return(result); }
public static string ReplaceHtmlWithFencedBlock(string html, string oldHtmlTag, string oldClassName, string className) { string result = html; var nodes = HtmlHelper.GetNodesWithTagAndClassName(html, oldHtmlTag, oldClassName); foreach (var node in nodes) { if (!string.IsNullOrEmpty(node.OuterHtml)) { result = result.Replace(node.OuterHtml, FencedBlocks.Create(node.InnerHtml.Trim(' '), className)); } } return(result); }