LocalToWeb
/// <summary> /// Adapts the HTML source from it's local MS Word form in order to be used by the wiki. /// </summary> /// <param name="content">The initial HTML source.</param> /// <returns>The adapted HTML code.</returns> public String AdaptSource(String content) { XmlDocument xmlDoc = new XmlDocument(); //xmlDoc.XmlResolver = null; content = new LocalToWebHTMLCleaner(HTML_OPENING_TAG).Clean(content); xmlDoc.LoadXml(content); //rigister the html filters List<IDOMFilter> contentFilters = new List<IDOMFilter>() { new LocalToWebStyleFilter(manager), new StyleRemoverFilter(manager), new GrammarAndSpellingErrorsFilter(manager), new LocalImageAdaptorFilter(manager), new LocalListsAdaptorFilter(manager), new LocalMacrosAdaptorFilter(manager), new OfficeAttributesRemoverFilter(manager), //new EmptySpanRemoverFilter(manager), //new EmptyNestedElementsFilter(manager), new ParentDivAttributeRemoverFilter(manager), }; foreach(IDOMFilter contentFilter in contentFilters) { contentFilter.Filter(ref xmlDoc); } StringBuilder sb = new StringBuilder(xmlDoc.GetIndentedXml()); sb.Replace(" xmlns=\"\"",""); return sb.ToString(); }
public void TestCleaner() { bool noException = true; try { htmlContent = new LocalToWebHTMLCleaner(htmlOpeningTag).Clean(htmlContent); xmlDoc.LoadXml(htmlContent); } catch (Exception e) { noException = false; Console.Error.WriteLine(e); } Assert.IsTrue(noException); }