public string GetTagName(HtmlCode htmlCode) { var regex = new Regex(@"^<([a-z-]){1,}>"); var match = regex.Match(htmlCode.Html); return(match.Value.Trim('<', '>')); }
/// <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)); } }
/// <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, ""); } }
/// <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(""); }
public void HtmlCode(HtmlCode code) { Write("html_block {0}", format_str(code.Content)); }
public void HtmlCode(HtmlCode code) { writer.Write(code.Content); }
public void HtmlCode(HtmlCode code) { WriteLinesPrefixed(code.Content); }