public static string FixReferences(string html, ReferenceFixer fixer, ReferenceFixedCallback referenceFixed) { TextWriter htmlWriter = new StringWriter(CultureInfo.InvariantCulture); HtmlReferenceFixer referenceFixer = new HtmlReferenceFixer(html); referenceFixer.FixReferences(htmlWriter, fixer, referenceFixed); return htmlWriter.ToString(); }
public static string FixReferences(string html, ReferenceFixer fixer, ReferenceFixedCallback referenceFixed) { TextWriter htmlWriter = new StringWriter(CultureInfo.InvariantCulture); HtmlReferenceFixer referenceFixer = new HtmlReferenceFixer(html); referenceFixer.FixReferences(htmlWriter, fixer, referenceFixed); return(htmlWriter.ToString()); }
/// <summary> /// Initializes a new instance of the ExternalHtmlReferenceFixer class. /// </summary> /// <param name="html">The HTML to iterate through.</param> /// <param name="sourceUrl">The source URL that the HTML originated from.</param> public ExternalHtmlReferenceFixer(string html, string sourceUrl) { _htmlReferenceFixer = new HtmlReferenceFixer(html); _sourceUrl = sourceUrl; }
public string PublishHtml() { TextWriter htmlWriter = new StringWriter(CultureInfo.InvariantCulture); HtmlReferenceFixer fixer = new HtmlReferenceFixer(_html); fixer.FixReferences(htmlWriter, ReferenceFixerForPublish, null); htmlWriter.Flush(); return htmlWriter.ToString(); }
private static void ConvertImageReferencesToLocal(IBlogPostEditingContext editingContext) { ImageReferenceFixer refFixer = new ImageReferenceFixer(editingContext.ImageDataList, editingContext.BlogId); // Create a text writer that the new html will be written to TextWriter htmlWriter = new StringWriter(CultureInfo.InvariantCulture); // Check an html image fixer that will find references and rewrite them to new paths HtmlReferenceFixer referenceFixer = new HtmlReferenceFixer(editingContext.BlogPost.Contents); // We need to update the editing context when we change an image ContextImageReferenceFixer contextFixer = new ContextImageReferenceFixer(editingContext); // Do the fixing referenceFixer.FixReferences(htmlWriter, new ReferenceFixer(refFixer.FixImageReferences), contextFixer.ReferenceFixedCallback); // Write back the new html editingContext.BlogPost.Contents = htmlWriter.ToString(); }