Skip to content

Commit

Permalink
Merge pull request #836 from EdiWang/fix/umlauts-encoding
Browse files Browse the repository at this point in the history
Fix umlauts encoding
  • Loading branch information
EdiWang authored Oct 21, 2024
2 parents 0b745cf + 6e3201c commit ff7d415
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Moonglade.Utils/ContentProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Markdig;
using System.Text.RegularExpressions;
using System.Web;
using System.Xml.Linq;

namespace Moonglade.Utils;
Expand All @@ -26,10 +27,14 @@ public static string GetPostAbstract(string content, int wordCount, bool useMark
MarkdownToContent(content, MarkdownConvertType.Text) :
RemoveTags(content);

var result = plainText.Ellipsize(wordCount);
var decodedText = HtmlDecode(plainText);
var result = decodedText.Ellipsize(wordCount);
return result;
}

// Fix #833 - umlauts like (ä,ö,ü). are not displayed correctly in the abstract
public static string HtmlDecode(string content) => HttpUtility.HtmlDecode(content);

public static string RemoveTags(string html)
{
if (string.IsNullOrEmpty(html))
Expand Down
2 changes: 1 addition & 1 deletion src/Moonglade.Web/Pages/Shared/_PostListEntry.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
</h3>

<abbr class="post-summary-text d-block mb-3">@(Model.ContentAbstract)</abbr>
<abbr class="post-summary-text d-block mb-3">@(ContentProcessor.HtmlDecode(Model.ContentAbstract))</abbr>

@if (null != Model.Tags)
{
Expand Down

0 comments on commit ff7d415

Please sign in to comment.