Skip to content

Commit 9d67561

Browse files
authored
Merge pull request #170 from tradiuz/patch-1
Fix <br \> issue and convert all HTML Specials to Text
2 parents 3655e4d + c921d12 commit 9d67561

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/module.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,12 @@ Hooks.on("createChatMessage", function (chatEntity, _, userId) {
263263
let charSpans = [];
264264
let textContent = chatData.content;
265265

266-
// replace entities
267-
textContent = textContent.replace(/&gt;/g, ">");
268-
textContent = textContent.replace(/&lt;/g, "<");
269-
textContent = textContent.replace(/&amp;/g, "&");
270-
textContent = textContent.replace(/<br>/g, "\n");
271-
266+
// replace newlines
267+
textContent = textContent.replace(/<br(| \/)>/g, "\n");
268+
// convert all html specials to plaintext
269+
let txtTemp = document.createElement("hiddentext");
270+
txtTemp.innerHTML = textContent;
271+
textContent = txtTemp.textContent;
272272
if (textBox) {
273273
// kill all tweens
274274
for (let c of textBox.children) {

0 commit comments

Comments
 (0)