title: Split string in characters turns & into &amp;
body: <p>I am splitting a string by each character and wrapping them in a span. I'm using a modified version of the script from splt.js. When the string contains special characters such as '&amp;' it will return
  <code>&lt;span&gt;&amp;&lt;/span&gt;&lt;span&gt;a&lt;/span&gt;&lt;span&gt;m&lt;/span&gt;&lt;span&gt;p&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;</code> instead of just &amp;. Is there a way to solve that? This is what the code looks like:</p>
  <pre><code>function splt({ target: q = &quot;.splt&quot;, reveal: o = !1 }) {
      let r = [],
          b = document.querySelectorAll(q);
      for (let a = 0; a &lt; b.length; a++) {
          b[a].setAttribute(&quot;id&quot;, &quot;i&quot; + [a + 1]), r.push(b[a].innerHTML);
          let l = b[a].innerHTML.split(&quot; &quot;);
          for (let g = 0; g &lt; l.length; g++) {
              let m = document.createElement(&quot;span&quot;);
              l[g] += &quot; &quot;;
              let h = l[g].split(&quot;&quot;);
              for (let c = 0; c &lt; h.length; c++) {
                  let d = document.createElement(&quot;span&quot;);
                  if ((m.appendChild(d), d.setAttribute(&quot;id&quot;, &quot;c&quot; + [c + 1]), &quot; &quot; == h[c] ? d.classList.add(&quot;whtSpc&quot;) : d.classList.add(&quot;char&quot;), !0 == o)) {
                      let i = document.createElement(&quot;span&quot;);
                      (i.innerHTML = h[c]), d.appendChild(i), i.setAttribute(&quot;id&quot;, &quot;r&quot;), i.classList.add(&quot;reveal&quot;);
                  } else d.innerHTML = h[c];
              }
              (m.style.display = &quot;inline-block&quot;), b[a].appendChild(m);
          }
          b[a].removeChild(b[a].childNodes[0]);
      }
      let j = document.querySelectorAll(&quot;.char&quot;);
      for (let e = 0; e &lt; j.length; e++) (j[e].style.display = &quot;inline-block&quot;), (j[e].style.overflow = &quot;hidden&quot;), (j[e].style.verticalAlign = &quot;top&quot;);
      let p = document.querySelectorAll(&quot;.whtSpc&quot;);
      for (let n = 0; n &lt; p.length; n++) p[n].style[&quot;white-space&quot;] = &quot;pre&quot;;
      if (!0 == o) {
          let k = document.querySelectorAll(&quot;.reveal&quot;);
          for (let f = 0; f &lt; k.length; f++) (k[f].style.display = &quot;inherit&quot;), (k[f].style.overflow = &quot;inherit&quot;), (k[f].style.verticalAlign = &quot;inherit&quot;);
      }
      splt.revert = () =&gt; {
          for (let a = 0; a &lt; b.length; a++) b[a].removeAttribute(&quot;id&quot;), (b[a].innerHTML = r[a]);
      };
  }
  splt({ target: &quot;.splt&quot;, reveal: !1 });
  ```
  </code></pre>