Skip to content

Commit

Permalink
html decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideWiest committed May 1, 2024
1 parent a96749a commit 8b0fdb3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Reader/Modules/TextHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Reader.Modules;
using System.Web;

namespace Reader.Modules;

public static class TextHelper
{
Expand All @@ -8,6 +10,8 @@ public static string Sanitize(string text)
text = text.Replace("\r", "\n");
text = text.Replace("\n", Environment.NewLine);
text = RemoveEmptySpaces(text);
text = text.Trim();
text = HttpUtility.HtmlDecode(text);

return text;
}
Expand All @@ -26,6 +30,7 @@ public static string RemoveEmptySpaces(string text)
var textPieces = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
textPieces = textPieces.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
textPieces = textPieces = textPieces.Select(x => x.Trim()).ToArray();
textPieces = string.Join(Environment.NewLine, textPieces).Split("" , StringSplitOptions.RemoveEmptyEntries);
return string.Join(Environment.NewLine, textPieces);
}
}

0 comments on commit 8b0fdb3

Please sign in to comment.