-
Notifications
You must be signed in to change notification settings - Fork 15
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
Support customEmojis #31
Conversation
Thank you for sending this patch. I apologize for the delay since I was busy on other projects. |
I reverted this patch because it is broken and it is not easily fixed in my side. When replacing emoji markup with HTML element string, remark sanitizes the input. So, for example, import { remark } from 'remark';
import toHtml from 'remark-html';
import emoji from 'remark-emoji';
const processor = remark()
.use(emoji, {
customEmojis: {
parrot: '<img src="https://cultofthepartyparrot.com/parrots/parrot.gif" style="width:auto;height:1em;">',
},
})
.use(toHtml);
const file = await processor.process('Hello :parrot:!');
console.log(String(file)); The output is:
Please submit a new PR after fixing this issue. Before creating it,
|
The misunderstanding in this patch is that Please read this API document for the details of return type: https://github.com/syntax-tree/mdast-util-find-and-replace?tab=readme-ov-file#returns-1 If we receive HTML fragments as configuration and replace emoji markups with them,
|
I read through the code in rhysd#31 and @rhysd's comments about what should be returned. I then read through the MDAST nodes and there's an Html node, so I used that for the custom emoji as well as changed the aria accessibility wrapping to use that, making it simpler. Added test cases and tweaked the accessibility ones.
Fix #30