Add generated Emoji class with corresponding non-generated file

This commit is contained in:
Kristian Hellang 2020-09-15 22:53:14 +02:00 committed by Patrik Svensson
parent 0632b38477
commit fea8a36e8a
3 changed files with 1869 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,23 @@
using System.Text.RegularExpressions;
namespace Spectre.Console
{
/// <summary>
/// Utility class for working with emojis.
/// </summary>
internal static partial class Emoji
{
private static readonly Regex _emojiCode = new Regex(@"(:(\S*?):)", RegexOptions.Compiled);
/// <summary>
/// Replaces emoji markup with corresponding unicode characters.
/// </summary>
/// <param name="value">A string with emojis codes, e.g. "Hello :smiley:!".</param>
/// <returns>A string with emoji codes replaced with actual emoji.</returns>
public static string Replace(string value)
{
static string ReplaceEmoji(Match match) => _emojis[match.Groups[2].Value];
return _emojiCode.Replace(value, ReplaceEmoji);
}
}
}

View File

@ -20,6 +20,9 @@
<Compile Update="Border.*.cs">
<DependentUpon>Border.cs</DependentUpon>
</Compile>
<Compile Update="Emoji.*.cs">
<DependentUpon>Emoji.cs</DependentUpon>
</Compile>
<Compile Update="Extensions/AnsiConsoleExtensions.*.cs">
<DependentUpon>Extensions/AnsiConsoleExtensions.cs</DependentUpon>
</Compile>