Пример #1
0
 public void ExtractRuntimeData()
 {
     if (!string.IsNullOrEmpty(Raw.ShortComment))
     {
         ShortCommentHtml = MarkdownUtil.ToHtml(Raw.ShortComment);
     }
 }
Пример #2
0
 public void ExtractRuntimeData()
 {
     if (!string.IsNullOrEmpty(Raw.MarkdownContent))
     {
         HtmlContent = MarkdownUtil.ToHtml(Raw.MarkdownContent);
         var htmlDoc = new HtmlDocument();
         htmlDoc.LoadHtml(HtmlContent);
         SetTableNodes(htmlDoc);
         var paraNodes =
             htmlDoc.DocumentNode
             .Descendants()
             .Where(_ =>
                    StringUtil.EqualsIgnoreCase(_.Name, "p") &&
                    _.Descendants().FirstOrDefault(c => StringUtil.EqualsIgnoreCase(c.Name, "img")) == null)
             .Take(2)
             .ToList();
         HtmlExcerpt = paraNodes.Count switch
         {
             1 => $"<p>{paraNodes[0].InnerText}</p>",
             2 => $"<p>{paraNodes[0].InnerText}</p><p>{paraNodes[1].InnerText}</p>",
             _ => HtmlExcerpt
         };
     }
 }