Example #1
0
        /// <summary>
        /// Iterates through the provided HTML and fixes up image URLs.
        /// </summary>
        /// <param name="html">The HTML to iterate through.</param>
        /// <param name="sourceUrl">The source URL that the HTML originated from.</param>
        /// <returns>The fixed up HTML.</returns>
        public string FixImageReferences(string html, string sourceUrl)
        {
            if (html == null)
            {
                throw new ArgumentNullException("html");
            }

            if (sourceUrl == null)
            {
                throw new ArgumentNullException("sourceUrl");
            }

            StringBuilder sb = new StringBuilder();

            using (StringWriter writer = new StringWriter(sb, CultureInfo.InvariantCulture))
            {
                if (HtmlHandler.IsSharedCanvasTempUrl(sourceUrl))
                {
                    HtmlReferenceFixer fixer = new HtmlReferenceFixer(html);
                    fixer.FixReferences(writer, _internalReferenceFixer, null);
                }
                else
                {
                    return(html);
                }
            }

            return(sb.ToString());
        }