Fix standard emoji not rendering as Discord-style images (#1488)

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
Copilot 2026-02-26 17:20:04 +02:00 committed by GitHub
parent ad1170b42e
commit 522caba420
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 47 deletions

View file

@ -8855,6 +8855,8 @@ internal static class EmojiIndex
["united_nations"] = "🇺🇳", ["united_nations"] = "🇺🇳",
}; };
public static IReadOnlyCollection<string> GetAllNames() => _toCodes.Keys;
public static string? TryGetCode(string name) => _toCodes.GetValueOrDefault(name); public static string? TryGetCode(string name) => _toCodes.GetValueOrDefault(name);
public static string? TryGetName(string code) => _fromCodes.GetValueOrDefault(code); public static string? TryGetName(string code) => _fromCodes.GetValueOrDefault(code);

View file

@ -208,53 +208,18 @@ internal static partial class MarkdownParser
private static readonly IMatcher<MarkdownContext, MarkdownNode> StandardEmojiNodeMatcher = private static readonly IMatcher<MarkdownContext, MarkdownNode> StandardEmojiNodeMatcher =
new RegexMatcher<MarkdownContext, MarkdownNode>( new RegexMatcher<MarkdownContext, MarkdownNode>(
new Regex( new Regex(
@"(" // Build a pattern from all known emoji, sorted longest-first so that compound
+ // emoji (e.g. sequences with ZWJ or skin-tone modifiers) are matched before
// Country flag emoji (two regional indicator surrogate pairs) // their individual components.
@"(?:\uD83C[\uDDE6-\uDDFF]){2}|" "("
+ + string.Join(
// Digit emoji (digit followed by enclosing mark) "|",
@"\d\p{Me}|" EmojiIndex
+ .GetAllNames()
// Surrogate pair .OrderByDescending(e => e.Length)
@"\p{Cs}{2}|" .Select(Regex.Escape)
+ )
// Miscellaneous characters + ")",
@"["
+ @"\u2600-\u2604"
+ @"\u260E\u2611"
+ @"\u2614-\u2615"
+ @"\u2618\u261D\u2620"
+ @"\u2622-\u2623"
+ @"\u2626\u262A"
+ @"\u262E-\u262F"
+ @"\u2638-\u263A"
+ @"\u2640\u2642"
+ @"\u2648-\u2653"
+ @"\u265F-\u2660"
+ @"\u2663"
+ @"\u2665-\u2666"
+ @"\u2668\u267B"
+ @"\u267E-\u267F"
+ @"\u2692-\u2697"
+ @"\u2699"
+ @"\u269B-\u269C"
+ @"\u26A0-\u26A1"
+ @"\u26A7"
+ @"\u26AA-\u26AB"
+ @"\u26B0-\u26B1"
+ @"\u26BD-\u26BE"
+ @"\u26C4-\u26C5"
+ @"\u26C8"
+ @"\u26CE-\u26CF"
+ @"\u26D1"
+ @"\u26D3-\u26D4"
+ @"\u26E9-\u26EA"
+ @"\u26F0-\u26F5"
+ @"\u26F7-\u26FA"
+ @"\u26FD"
+ @"]"
+ @")",
DefaultRegexOptions DefaultRegexOptions
), ),
(_, _, m) => new EmojiNode(m.Groups[1].Value) (_, _, m) => new EmojiNode(m.Groups[1].Value)