Esempio n. 1
0
        public string GetTagName(HtmlCode htmlCode)
        {
            var regex = new Regex(@"^<([a-z-]){1,}>");
            var match = regex.Match(htmlCode.Html);

            return(match.Value.Trim('<', '>'));
        }
Esempio n. 2
0
        /// <summary>
        /// Inserts the downloaded local files into the html code
        /// so that the links in srcs will refer to the local files.
        /// </summary>
        private void InsertLinks()
        {
            foreach (KeyValuePair <string, string> pair in resourcesNames)
            {
                Console.WriteLine("DEBUG: Replacing {0} -> {1}", pair.Key, pair.Value);

                this.HtmlCode = HtmlCode.Replace(pair.Key, GetRelativeUrl(pair.Value));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Removes srcset from the html code because it's making the images
        /// disappear
        /// </summary>
        private void RemoveSrcsetAttribute()
        {
            var srcsetRegex = new Regex(@"srcset=[""'].+[""']", RegexOptions.IgnoreCase);

            foreach (Match match in srcsetRegex.Matches(this.HtmlCode))
            {
                this.HtmlCode = HtmlCode.Replace(match.Value, "");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the content in specified format
        /// </summary>
        /// <param name="mode">The mode.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentOutOfRangeException">mode</exception>
        public string GetContent(nodeBlockOutputEnum mode)
        {
            switch (mode)
            {
            case nodeBlockOutputEnum.graphPath:

                break;

            case nodeBlockOutputEnum.htmlInner:

                return(html.InnerHtml);

                break;

            case nodeBlockOutputEnum.htmlOutter:
                if (HtmlCode.isNullOrEmpty())
                {
                    return(html.OuterHtml);
                }
                else
                {
                    return(HtmlCode);
                }

                break;

            case nodeBlockOutputEnum.none:
                break;

            case nodeBlockOutputEnum.text:
                return(content);

                break;

            case nodeBlockOutputEnum.xpath:
                return(xPath);

                break;

            default:
                throw new ArgumentOutOfRangeException("mode");
                break;
            }
            return("");
        }
Esempio n. 5
0
 public void HtmlCode(HtmlCode code)
 {
     Write("html_block {0}", format_str(code.Content));
 }
Esempio n. 6
0
 public void HtmlCode(HtmlCode code)
 {
     writer.Write(code.Content);
 }
 public void HtmlCode(HtmlCode code)
 {
     WriteLinesPrefixed(code.Content);
 }