From f9984ee6d0ecc92c0d54a9aa7e6f352d5b139023 Mon Sep 17 00:00:00 2001 From: dekaSW <152609444+dekaSW@users.noreply.github.com> Date: Tue, 12 Aug 2025 16:13:33 +0200 Subject: [PATCH] Update splt.js: Support html entity decoding Hey Logan, after failing to workaround this issue around spltjs due to the nature of .innerHTML always escaping those HTML entities I tried to apply some changes to your script instead which finally worked. It would be nice if you'd merge this proposal one way or another. The methode used to decode those entities (by using textarea elements) might not be the smartest but it's definitely an easy one and working. Maybe see https://thelinuxcode.com/decode-html-entities-javascript/ for reference. Thanks! --- splt.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/splt.js b/splt.js index 342932d..48add91 100644 --- a/splt.js +++ b/splt.js @@ -4,6 +4,13 @@ function splt({ target = '.splt', reveal = false }) { //grab instances const inst = document.querySelectorAll(target); + // MOD - support for html entity decoding + const decoded = function (encodedStr) { + let textarea = document.createElement('textarea') + textarea.innerHTML = encodedStr + return textarea.value + }; + for (let a = 0; a < inst.length; a++) { inst[a].setAttribute('id', 'i' + [a + 1]); @@ -11,7 +18,7 @@ function splt({ target = '.splt', reveal = false }) { saveOriginal.push(inst[a].innerHTML); //split instance text - const instChars = inst[a].innerHTML.split(''); + const instChars = decoded(inst[a].innerHTML).split(''); for (let b = 0; b < instChars.length; b++) { //nest child span const span = document.createElement('span');