32 lines
835 B
C#
32 lines
835 B
C#
using HtmlAgilityPack;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Beam.Abstractions;
|
|
|
|
namespace Beam.Dynamic {
|
|
public class ParagraphedContentDataProvider : IDataProvider<string> {
|
|
public IBinding? Content { get; set; }
|
|
|
|
public string Get(HtmlDocument document) {
|
|
if (Content is null)
|
|
return "";
|
|
|
|
var node = Content.Select(document);
|
|
if (node is null)
|
|
return "";
|
|
|
|
StringBuilder content = new();
|
|
foreach(var childNode in node.ChildNodes) {
|
|
if (childNode.Name != "p")
|
|
continue;
|
|
content.AppendLine(childNode.InnerText);
|
|
}
|
|
|
|
return content.ToString();
|
|
}
|
|
}
|
|
}
|