private static void DetachExtendedEntryBehavior(TemporaryFixupArgs args) { string html = args.Html; if (html.Contains(EXTENDED_ENTRY_ID)) { //replace the EXTENDED_ENTRY_ID behavior div with the <!--more--> comment StringBuilder output = new StringBuilder(html.Length); SimpleHtmlParser parser = new SimpleHtmlParser(html); SmartPredicate splitDiv = new SmartPredicate(String.Format(CultureInfo.InvariantCulture, "<div id='{0}'>", EXTENDED_ENTRY_ID)); for (Element el; null != (el = parser.Next());) { if (splitDiv.IsMatch(el)) { Element e = parser.Peek(0); if (e is EndTag && ((EndTag)e).NameEquals("div")) { output.Append(BlogPost.ExtendedEntryBreak); parser.Next(); } } else { output.Append(html, el.Offset, el.Length); } } args.Html = output.ToString(); } }
private static void EditorContext_PerformTemporaryFixupsToEditedHtml(TemporaryFixupArgs args) { string html = args.Html; if (html.Contains("table")) { StringBuilder output = new StringBuilder(html.Length); SimpleHtmlParser parser = new SimpleHtmlParser(html); for (Element el; null != (el = parser.Next());) { output.Append(html, el.Offset, el.Length); if (el is BeginTag && ((BeginTag)el).NameEquals("td")) { Element e = parser.Peek(0); if (e is EndTag && ((EndTag)e).NameEquals("td")) { output.Append(" "); } } } args.Html = output.ToString(); } }