private static string MakeLinksAbsolute(HtmlParser parser, HtmlMarkupFormatter formatter, IExecutionContext context, string value) { if (!string.IsNullOrEmpty(value)) { IHtmlDocument dom = parser.Parse(string.Empty); INodeList nodes = parser.ParseFragment(value, dom.Body); IEnumerable <IElement> elements = nodes.SelectMany(x => x.Descendents <IElement>().Where(y => y.HasAttribute("href") || y.HasAttribute("src"))); bool replaced = false; foreach (IElement element in elements) { replaced = MakeLinkAbsolute(element, "href", context) || replaced; replaced = MakeLinkAbsolute(element, "src", context) || replaced; } if (replaced) { using (StringWriter writer = new StringWriter()) { nodes.ToHtml(writer, formatter); return(writer.ToString()); } } } return(null); }