Added a wrapper Markdown Rendered to render BOTH Emojis and Mardown as HTML

This commit is contained in:
SuperChamp234 2022-01-14 14:39:21 +05:30
parent 916236db5d
commit 88fdde519d
17 changed files with 65 additions and 41 deletions

View file

@ -0,0 +1,17 @@
import MarkdownIt from "markdown-it";
import markdownitEmoji from "markdown-it-emoji"
import twemoji from "twemoji";
export default function renderMarkdown(markdown: string) {
const md = new MarkdownIt({
html: true,
breaks: true,
linkify: true,
typographer: true
});
md.use(markdownitEmoji);
md.renderer.rules.emoji = function(token, idx) {
return twemoji.parse(token[idx].content);
};
return md.render(markdown);
}