Add Name and Description properties to IContentProcessor

This commit is contained in:
Stone_Red
2024-04-27 20:11:25 +02:00
parent 571d8c2b4b
commit aa1484f5d4
3 changed files with 14 additions and 1 deletions
@@ -9,6 +9,10 @@ namespace Markdowser.Processing;
internal interface IContentProcessor internal interface IContentProcessor
{ {
string Name { get; }
string Description { get; }
bool CanProcess(HttpContentHeaders httpContentHeaders); bool CanProcess(HttpContentHeaders httpContentHeaders);
Task<ContentViewModelBase> Process(HttpResponseMessage httpResponseMessage, IProgress<ProcessingProgress> progress); Task<ContentViewModelBase> Process(HttpResponseMessage httpResponseMessage, IProgress<ProcessingProgress> progress);
@@ -7,8 +7,13 @@ using System.Net.Http.Headers;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Markdowser.Processing.Processors; namespace Markdowser.Processing.Processors;
internal class CommonImageProcessor : IContentProcessor internal class CommonImageProcessor : IContentProcessor
{ {
public string Name => "Common Image Processor";
public string Description => "Processes common image types (e.g. PNG, JPEG, GIF)";
public bool CanProcess(HttpContentHeaders httpContentHeaders) public bool CanProcess(HttpContentHeaders httpContentHeaders)
{ {
if (httpContentHeaders.ContentType?.MediaType == "image/svg+xml") if (httpContentHeaders.ContentType?.MediaType == "image/svg+xml")
@@ -23,4 +28,4 @@ internal class CommonImageProcessor : IContentProcessor
{ {
return new CommonImageContentViewModel(httpResponseMessage.RequestMessage?.RequestUri?.Host?.ToString() ?? "Image", await httpResponseMessage.Content.ReadAsStreamAsync()); return new CommonImageContentViewModel(httpResponseMessage.RequestMessage?.RequestUri?.Host?.ToString() ?? "Image", await httpResponseMessage.Content.ReadAsStreamAsync());
} }
} }
@@ -19,6 +19,10 @@ internal partial class HtmlProcessor : IContentProcessor
{ {
private readonly ReverseMarkdown.Converter markdownConverter = new(); private readonly ReverseMarkdown.Converter markdownConverter = new();
public string Name => "HTML Processor";
public string Description => "Processes HTML content";
public HtmlProcessor() public HtmlProcessor()
{ {
markdownConverter.Config.UnknownTags = ReverseMarkdown.Config.UnknownTagsOption.Bypass; markdownConverter.Config.UnknownTags = ReverseMarkdown.Config.UnknownTagsOption.Bypass;