-
-
Notifications
You must be signed in to change notification settings - Fork 456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emojis and smileys customization #386
Conversation
If we are adding support to customize the emoji set, I don't think having an EnableSmiley flag on EmojiParser makes sense anymore. I would still keep it in the UseEmojiAndSmiley and select the EmojiMapping to pass to the parser there. EmojiMapping currently represents two possible mappings (smiley or not), I would prefer it only represents one and we instead have two default properties. |
Thank you for this, in general LGTM other than some implementation details mentioned above. |
Thanks for the review.
My understanding is that it's currently possible to change the value of Also, what would
So an What would be the two default properties ? One just for the emojis, and the second for both the emojis and the smileys? |
No. It can technically be changed between the ctor and first use, but that was to allow for customization before. Now we don't need to wait for initialize, that work can be done in the ctor. In general, parsers should be immutable and thread-safe, to allow for Pipeline reuse to be safe.
That was the idea. The one accepting bool would call the one accepting EmojiMapping directly.
I think it's still a good name, no hard preference tho
Yes |
I'm working on the changes, but I also have another question: I don't think the terminology used in the extension is correct. Since I'm introducing new properties, I would like to use this as an opportunity to use a better terminology. Specifically, I don't think "emoji" is used properly. I think "emoji" should be used to talk about the unicode representation. I'm also not a big fan of "smiley" to describe a face made of text, but I don't have anything better to suggest... What do you think? I would make these changes in a separate commit at the end... |
The naming change LGTM, I can't really think of a different name for smiley. |
That's alright, thank you :) |
Well that's an awful git merge diff, sorry. Looks like the web editor replaced all \n with \r\n (If you want, you can force-push my commit off your branch - I didn't know that resolving the merge conflict in the web editor would push to your branch, i assumed that it would open a PR against it) |
(this feature was broken in xoofx#308)
e344436
to
1cff102
Compare
I rebased my branch on top of the markdig master. The only conflict I had was the changelog. If for whatever reason you don't like that, tell me and I'll revert the rebase, and do a merge into my branch instead. |
Thanks for that! |
Thank you for your wonderful work on open source projects! |
I forgot to thank also @MihaZupan who is helping a lot to keep this project updated. Thank you again for reviewing this PR @MihaZupan ! |
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:
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 customEmojiMapping
instance.EmojiParser
takes anEmojiMapping
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.