34 lines
862 B
C#
34 lines
862 B
C#
using System.Collections.Generic;
|
|
using System.Net;
|
|
using System.Threading;
|
|
|
|
using MfGames.Gallium;
|
|
using MfGames.Nitride.Contents;
|
|
|
|
namespace MfGames.Nitride.Html;
|
|
|
|
/// <summary>
|
|
/// Converts the text input that uses HTML entities and turns them into
|
|
/// Unicode variations.
|
|
/// </summary>
|
|
public class ConvertHtmlEntitiesToUnicode : OperationBase
|
|
{
|
|
/// <inheritdoc />
|
|
public override IEnumerable<Entity> Run(
|
|
IEnumerable<Entity> input,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
return input.SelectEntity<ITextContent>(this.ResolveHtmlEntities);
|
|
}
|
|
|
|
private Entity ResolveHtmlEntities(
|
|
Entity entity,
|
|
ITextContent content)
|
|
{
|
|
string text = content.GetTextContentString();
|
|
string resolved = WebUtility.HtmlDecode(text);
|
|
|
|
return entity.SetTextContent(resolved);
|
|
}
|
|
}
|