[TestCase(":/", "<p>😕</p>\n")] // default smiley still works public void TestOverrideDefaultWithCustomEmoji(string input, string expected) { var emojiToUnicode = EmojiMapping.GetDefaultEmojiShortcodeToUnicode(); var smileyToEmoji = EmojiMapping.GetDefaultSmileyToEmojiShortcode(); emojiToUnicode[":smiley:"] = "♥"; var customMapping = new EmojiMapping(emojiToUnicode, smileyToEmoji); var pipeline = new MarkdownPipelineBuilder() .UseEmojiAndSmiley(customEmojiMapping: customMapping) .Build(); var actual = Markdown.ToHtml(input, pipeline); Assert.AreEqual(expected, actual); }
[TestCase(":/", "<p>:/</p>\n")] // default smiley does not work public void TestCustomEmoji(string input, string expected) { var emojiToUnicode = new Dictionary <string, string>(); var smileyToEmoji = new Dictionary <string, string>(); emojiToUnicode[":smiley:"] = "♥"; var customMapping = new EmojiMapping(emojiToUnicode, smileyToEmoji); var pipeline = new MarkdownPipelineBuilder() .UseEmojiAndSmiley(customEmojiMapping: customMapping) .Build(); var actual = Markdown.ToHtml(input, pipeline); Assert.AreEqual(expected, actual); }
/// <summary> /// Uses the emojis and smileys extension. /// </summary> /// <param name="pipeline">The pipeline.</param> /// <param name="customEmojiMapping">Enable customization of the emojis and smileys mapping.</param> /// <returns>The modified pipeline</returns> public static MarkdownPipelineBuilder UseEmojiAndSmiley(this MarkdownPipelineBuilder pipeline, EmojiMapping customEmojiMapping) { if (!pipeline.Extensions.Contains <EmojiExtension>()) { pipeline.Extensions.Add(new EmojiExtension(customEmojiMapping)); } return(pipeline); }
public EmojiExtension(EmojiMapping emojiMapping) { EmojiMapping = emojiMapping; }
/// <summary> /// Initializes a new instance of the <see cref="EmojiParser"/> class. /// </summary> public EmojiParser(EmojiMapping emojiMapping) { _emojiMapping = emojiMapping; OpeningCharacters = _emojiMapping.OpeningCharacters; }