From 58838c8810850cf9a8e60d0438fef62d87219bb0 Mon Sep 17 00:00:00 2001 From: Mystikfluu Date: Sat, 27 Aug 2022 19:15:01 +0200 Subject: [PATCH] add title to emojis --- js/markdown.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/markdown.js b/js/markdown.js index 86182ba..2f01302 100644 --- a/js/markdown.js +++ b/js/markdown.js @@ -30,7 +30,13 @@ function filterMentions(text) { const emojiregex = /:([^:\s]*):/gi function emojify(text) { - return text.replace(emojiregex,"$1") + return text.replace(emojiregex,"$1 title=':$1:'") +} + +function unemojify(text){ + text = text.replace(/\u{1F5FF}/gu,":moyai:") + text = text.replace(/\u{1F440}/gu,":eyes:") + return text } const allregex = /(```([^```]*)```)|(\n)|(~([^~]*)~)|(\*\*([^\*]*)\*\*)|(\*([^\*]*)\*)|(@[^\s]*)|(:([^:\s]*):)/gi @@ -43,6 +49,7 @@ const cdblregex = /```([^```]*)```/gi * @return {string} html that represents the filtered text */ function filterPost(text){ + text = unemojify(text) let result = htmlesc(text).replace(allregex, function (match) { let out = match if(cdblregex.test(match)) { @@ -51,7 +58,6 @@ function filterPost(text){ out = newlineify(out) return `
${out}
` } - out = newlineify(out) out = urlify(out) out = emojify(out)