private static string GetTitle(string htmlInput, string imdbId) { HtmlCodes htmlCodes = new HtmlCodes(); string _title = ""; string titlePattern = "<title>.*</title>"; Regex rgx = new Regex(titlePattern, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); if (rgx.Matches(htmlInput).Count > 0) { _title = rgx.Matches(htmlInput)[0].Value; //remove the beginning title tag <title> _title = _title.Substring(7); //remove the ending title tag </title> _title = _title.Substring(0, _title.Length - 8); _title = htmlCodes.ToText(_title); } return(_title); }
protected override void WriteContent(StringBuilder htmlStringBuilder) { for (int i = 0; i < _textContentLines.Count; i++) { var text = _textContentLines[i]; if (_lineWithinBreakShouldBeAdded.Count != 0 && i == _lineWithinBreakShouldBeAdded.Peek()) { htmlStringBuilder.Append("<br>"); _lineWithinBreakShouldBeAdded.Dequeue(); } foreach (var c in text) { if (HtmlCodes.TryGetValue(c, out string replacement)) { htmlStringBuilder.Append(replacement); continue; } htmlStringBuilder.Append(c); } } }