Skip to content

Commit

Permalink
Merge pull request #170 from tradiuz/patch-1
Browse files Browse the repository at this point in the history
Fix <br \> issue and convert all HTML Specials to Text
  • Loading branch information
megahead11 authored Jul 2, 2024
2 parents 3655e4d + c921d12 commit 9d67561
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,12 @@ Hooks.on("createChatMessage", function (chatEntity, _, userId) {
let charSpans = [];
let textContent = chatData.content;

// replace entities
textContent = textContent.replace(/&gt;/g, ">");
textContent = textContent.replace(/&lt;/g, "<");
textContent = textContent.replace(/&amp;/g, "&");
textContent = textContent.replace(/<br>/g, "\n");

// replace newlines
textContent = textContent.replace(/<br(| \/)>/g, "\n");
// convert all html specials to plaintext
let txtTemp = document.createElement("hiddentext");
txtTemp.innerHTML = textContent;
textContent = txtTemp.textContent;
if (textBox) {
// kill all tweens
for (let c of textBox.children) {
Expand Down

0 comments on commit 9d67561

Please sign in to comment.