public void Emoji_() { WriteLine(Emoji.Get(":tada:").Raw); // 🎉 WriteLine(Emoji.Raw(":tada:")); // 🎉 WriteLine(Emoji.Emojify(":tada: initial commit")); // 🎉 initial commit WriteLine(Emoji.Find("party popper").First().Raw); // 🎉 }
public void Emojify() { Emoji.Emojify("Hello, :earth_africa:").Should().Be("Hello, 🌍"); Emoji.Emojify("Hello, :fail:").Should().Be("Hello, :fail:"); Action act = () => Emoji.Emojify(NullString); act.Should().Throw <ArgumentNullException>(); }
public void Emojify() { Emoji.Emojify("Hello, :earth_africa:").Should().Be("Hello, 🌍"); Emoji.Emojify("Hello, :fail:").Should().Be("Hello, :fail:"); }
/// <summary> /// Return a filtered list, based on the given query. /// </summary> /// <param name="query">The query to filter the list.</param> /// <returns>A filtered list, can be empty when nothing was found.</returns> public List <Result> Query(Query query) { if (query?.Search is null) { return(new List <Result>(0)); } var value = query.Search; if (string.IsNullOrEmpty(value)) { return(Emoji.All.Select(GetResult).ToList()); } var emojis = Emoji.Find(value); if (emojis.Any()) { return(emojis.Select(GetResult).ToList()); } var results = new List <Result>(); if (HasAlias(value)) { var result = Emoji.Emojify(value); results.Add( new Result { QueryTextDisplay = value, IcoPath = IconPath, Title = result, SubTitle = "Replace aliases in text with raw emojis", ToolTipData = new ToolTipData("Emojify", $"{value}\n{result}"), Action = _ => CopyToClipboard(result), ContextData = new EmojifiedString(result), }); } if (HasEmoji(value)) { var result = Emoji.Demojify(value); results.Add( new Result { QueryTextDisplay = value, IcoPath = IconPath, Title = result, SubTitle = "Replace raw emojis in text with aliases", ToolTipData = new ToolTipData("Demojify", $"{value}\n{result}"), Action = _ => CopyToClipboard(result), ContextData = new DemojifiedString(result), }); } return(results); Result GetResult(GEmoji emoji) => new() { QueryTextDisplay = value, IcoPath = IconPath, Title = emoji.Raw, SubTitle = string.Join(" ", emoji.Aliases.Select(x => x.PadAlias())), ToolTipData = new ToolTipData("GEmoji", $"Description: {emoji.Description}\nCategory: {emoji.Category}\nTags: {string.Join(", ", emoji.Tags ?? Enumerable.Empty<string>())}\n"), Action = _ => CopyToClipboard(emoji.Raw), ContextData = emoji, }; bool HasAlias(string value) { return(Regex.IsMatch(value, @":([\w+-]+):", RegexOptions.Compiled)); } bool HasEmoji(string value) { return(Regex.IsMatch(value, Emoji.RegexPattern, RegexOptions.Compiled)); } }