I have been adapting the rehype-twemojify code to solve some issues that I encountered while adopting it in our codebase.
There were two main business logic issues I encountered:
The grapheme splitting regex doesn't appear to handle some of the newer emoji correctly. I switched to using the emoji-regex library for everything, inspired by the approach of the react-emoji-render library.
Twemoji strips the trailing uFE0F from the code point of non-emoji graphemes that are hinted into being emoji (like ☘️). See for example the logic used in the twemoji library.
Because I'm most comfortable working in TypeScript+pnpm, I ended up doing some more extensive refactoring to solve various issues I found with inconsistent types in the codebase. This includes various backwards-incompatible changes.
I appreciate that these other changes might take this PR past the point where you actually want to merge it into the existing codebase. However, I'd be happy to work with you to find a set of changes that you would want to merge. (I didn't just want to run off and fork the codebase needlessy!)
Hi,
I have been adapting the
rehype-twemojify
code to solve some issues that I encountered while adopting it in our codebase.There were two main business logic issues I encountered:
emoji-regex
library for everything, inspired by the approach of thereact-emoji-render
library.twemoji
library.Because I'm most comfortable working in TypeScript+pnpm, I ended up doing some more extensive refactoring to solve various issues I found with inconsistent types in the codebase. This includes various backwards-incompatible changes.
This PR also depends on some as-yet-unmerged fixes I made to the
unist-util-map
types.I appreciate that these other changes might take this PR past the point where you actually want to merge it into the existing codebase. However, I'd be happy to work with you to find a set of changes that you would want to merge. (I didn't just want to run off and fork the codebase needlessy!)