Aichatbot12321 commited on
Commit
72dc47e
Β·
verified Β·
1 Parent(s): 7b07766

Update books.html

Browse files
Files changed (1) hide show
  1. books.html +5 -10
books.html CHANGED
@@ -1805,7 +1805,7 @@ $$[Equation without using \\frac]$$
1805
  }
1806
  }
1807
 
1808
- // 🚨 FIXED MARKDOWN PARSER (NO REGEX CORRUPTION) 🚨
1809
  window.addAiMessage = async function(text, typewrite = false) {
1810
  const msgDiv = document.createElement("div"); msgDiv.className = "msg ai";
1811
  const bubble = document.createElement("div"); bubble.className = "bubble";
@@ -1815,8 +1815,6 @@ $$[Equation without using \\frac]$$
1815
  let cleanText = text.replace(/\\frac{([^}]+)}{([^}]+)}/g, '$1/$2').replace(/\\times/g, 'Γ—');
1816
  let formattedHTML = marked.parse(cleanText);
1817
 
1818
- // 🚨 FIX: single ID generated once and reused for both the div AND the Listen button's data-target
1819
- // (previously two separate Date.now() calls almost never matched, so clicking "Listen" silently failed)
1820
  const ttsId = `tts_${Date.now()}_${Math.floor(Math.random()*10000)}`;
1821
  let btnHtml = `<br><button class="listen-btn" onclick="window.playAudio(this)" data-target="${ttsId}">πŸ”Š Listen</button>`;
1822
 
@@ -1841,7 +1839,7 @@ $$[Equation without using \\frac]$$
1841
  currentHTML += formattedHTML.substring(i, end + 1);
1842
  i = end + 1;
1843
  txtBox.innerHTML = currentHTML;
1844
- return; // Skip over HTML tags instantly
1845
  }
1846
  }
1847
 
@@ -1854,16 +1852,13 @@ $$[Equation without using \\frac]$$
1854
  }
1855
  }, 8);
1856
  });
1857
- } else {
1858
  bubble.innerHTML = `<div id="${ttsId}" style="margin-bottom:10px;">${formattedHTML}</div>${btnHtml}${msgMenuHTML}`;
1859
  if(window.MathJax) { MathJax.typesetClear([bubble]); MathJax.typesetPromise([bubble]); }
1860
 
1861
  window.saveHistorySafe(); window.triggerCloudSyncEngine(); window.resetSendButton();
1862
  }
1863
- } // <--- YOU ARE LIKELY MISSING THIS CLOSING BRACE
1864
- </script>
1865
- </body>
1866
- </html>
1867
  </script>
1868
  </body>
1869
- </html>
 
1805
  }
1806
  }
1807
 
1808
+ // 🚨 FIXED MARKDOWN PARSER 🚨
1809
  window.addAiMessage = async function(text, typewrite = false) {
1810
  const msgDiv = document.createElement("div"); msgDiv.className = "msg ai";
1811
  const bubble = document.createElement("div"); bubble.className = "bubble";
 
1815
  let cleanText = text.replace(/\\frac{([^}]+)}{([^}]+)}/g, '$1/$2').replace(/\\times/g, 'Γ—');
1816
  let formattedHTML = marked.parse(cleanText);
1817
 
 
 
1818
  const ttsId = `tts_${Date.now()}_${Math.floor(Math.random()*10000)}`;
1819
  let btnHtml = `<br><button class="listen-btn" onclick="window.playAudio(this)" data-target="${ttsId}">πŸ”Š Listen</button>`;
1820
 
 
1839
  currentHTML += formattedHTML.substring(i, end + 1);
1840
  i = end + 1;
1841
  txtBox.innerHTML = currentHTML;
1842
+ return;
1843
  }
1844
  }
1845
 
 
1852
  }
1853
  }, 8);
1854
  });
1855
+ } else {
1856
  bubble.innerHTML = `<div id="${ttsId}" style="margin-bottom:10px;">${formattedHTML}</div>${btnHtml}${msgMenuHTML}`;
1857
  if(window.MathJax) { MathJax.typesetClear([bubble]); MathJax.typesetPromise([bubble]); }
1858
 
1859
  window.saveHistorySafe(); window.triggerCloudSyncEngine(); window.resetSendButton();
1860
  }
1861
+ };
 
 
 
1862
  </script>
1863
  </body>
1864
+ </html>