mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-04 05:44:50 +00:00
[PR #386] [MERGED] Emojis and smileys customization #976
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/xoofx/markdig/pull/386
Author: @mlaily
Created: 1/12/2020
Status: ✅ Merged
Merged: 1/21/2020
Merged by: @xoofx
Base:
master← Head:emoji-customization📝 Commits (6)
3033284Re-allow emojis and smileys customization0057b36Add unit tests for custom emojis and smileys0a36382Update changelogaecdf21Improve the emoji extension (code review remarks)8702318Clarify emoji terminology (emoji "shortcode")1cff102Set the default emoji dictionaries capacity in their ctor📊 Changes
9 files changed (+1942 additions, -1773 deletions)
View changed files
📝
changelog.md(+1 -0)📝
src/Markdig.Tests/Specs/EmojiSpecs.generated.cs(+4 -4)📝
src/Markdig.Tests/Specs/EmojiSpecs.md(+3 -3)➕
src/Markdig.Tests/TestCustomEmojis.cs(+99 -0)📝
src/Markdig/Extensions/Emoji/EmojiExtension.cs(+8 -8)📝
src/Markdig/Extensions/Emoji/EmojiInline.cs(+3 -3)➕
src/Markdig/Extensions/Emoji/EmojiMapping.cs(+1794 -0)📝
src/Markdig/Extensions/Emoji/EmojiParser.cs(+9 -1749)📝
src/Markdig/MarkdownExtensions.cs(+21 -6)📄 Description
Hello,
I found out while updating my nuget packages that emojis and smileys customization was not possible anymore (#308).
This PR is an attempt to bring this feature back, while keeping the new performance optimizations in place.
Please note that I'm not much used to caring about allocations, so it's possible I introduced useless ones. Feel free to point them to me so I can fix them.
To summarize the changes:
EmojiMappingclass, wrapping the creation of the compact prefix trees.EmojiMappingcan be constructed from custom dictionaries (it uses the default emojis and smileys otherwise).EmojiMappingexposes two static public methods returning the default emojis and smileys dictionaries, so that they can be used as a base to create a customEmojiMappinginstance.EmojiParsertakes anEmojiMappinginstance, and uses it directly to parse emojis and smileys.The compact prefix trees creation is mostly the same as before. I only added new safety checks, since the input can be provided externally.
I also added some unit tests ensuring the basic use-cases work as expected.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.