[PR #386] [MERGED] Emojis and smileys customization #976

Closed
opened 2026-01-29 14:48:05 +00:00 by claunia · 0 comments
Owner

📋 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: masterHead: emoji-customization


📝 Commits (6)

  • 3033284 Re-allow emojis and smileys customization
  • 0057b36 Add unit tests for custom emojis and smileys
  • 0a36382 Update changelog
  • aecdf21 Improve the emoji extension (code review remarks)
  • 8702318 Clarify emoji terminology (emoji "shortcode")
  • 1cff102 Set 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:

  • I introduced a new immutable EmojiMapping class, wrapping the creation of the compact prefix trees.
  • EmojiMapping can be constructed from custom dictionaries (it uses the default emojis and smileys otherwise).
  • EmojiMapping exposes two static public methods returning the default emojis and smileys dictionaries, so that they can be used as a base to create a custom EmojiMapping instance.
  • EmojiParser takes an EmojiMapping instance, 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.

## 📋 Pull Request Information **Original PR:** https://github.com/xoofx/markdig/pull/386 **Author:** [@mlaily](https://github.com/mlaily) **Created:** 1/12/2020 **Status:** ✅ Merged **Merged:** 1/21/2020 **Merged by:** [@xoofx](https://github.com/xoofx) **Base:** `master` ← **Head:** `emoji-customization` --- ### 📝 Commits (6) - [`3033284`](https://github.com/xoofx/markdig/commit/303328409637abc7bca172cf35984cb02956952d) Re-allow emojis and smileys customization - [`0057b36`](https://github.com/xoofx/markdig/commit/0057b368ec18dcdb47c7566bfcea8b3ad990c52d) Add unit tests for custom emojis and smileys - [`0a36382`](https://github.com/xoofx/markdig/commit/0a3638212656326c48b2903d93a7b8f717d45126) Update changelog - [`aecdf21`](https://github.com/xoofx/markdig/commit/aecdf2192eec3463e85870c287d9802963c605c2) Improve the emoji extension (code review remarks) - [`8702318`](https://github.com/xoofx/markdig/commit/87023184cbb6f8da00e99e947cb3872521a28b32) Clarify emoji terminology (emoji "shortcode") - [`1cff102`](https://github.com/xoofx/markdig/commit/1cff10270a0ad69c6ef18066b3347b8b49f75f11) Set the default emoji dictionaries capacity in their ctor ### 📊 Changes **9 files changed** (+1942 additions, -1773 deletions) <details> <summary>View changed files</summary> 📝 `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) </details> ### 📄 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: - I introduced a new immutable `EmojiMapping` class, wrapping the creation of the compact prefix trees. - `EmojiMapping` can be constructed from custom dictionaries (it uses the default emojis and smileys otherwise). - `EmojiMapping` exposes two static public methods returning the default emojis and smileys dictionaries, so that they can be used as a base to create a custom `EmojiMapping` instance. - `EmojiParser` takes an `EmojiMapping` instance, 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 14:48:05 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#976