diff --git a/src/TagzApp.Web/wwwroot/js/site.js b/src/TagzApp.Web/wwwroot/js/site.js index 109d3b8e..7b18b090 100644 --- a/src/TagzApp.Web/wwwroot/js/site.js +++ b/src/TagzApp.Web/wwwroot/js/site.js @@ -57,6 +57,12 @@ observer.observe(taggedContent, observerConfig); } + function decodeHtml(html) { + var txt = document.createElement('textarea'); + txt.innerHTML = html; + return txt.value; + } + async function start() { try { await connection.start(); @@ -317,7 +323,7 @@ } function FormatContextWithEmotes(content) { - var text = content.text; + var text = decodeHtml(content.text); if (!content.emotes) return text; var toReplace = []; @@ -330,11 +336,15 @@ .substring(emote.pos, emote.length + emote.pos + 1) .trim(); var emoteHtml = ``; + console.log( + `Formatting text: '${text}' with emote at ${emote.pos}, with length ${emote.length} and found text ${emoteName}`, + ); toReplace.push({ name: emoteName, html: emoteHtml }); } for (var r in toReplace) { var item = toReplace[r]; + console.log(`Replacing ${item.name} with ${item.html}`); text = text.replace(item.name, item.html); }