diff --git a/smartassist/src/static/js/frontend.js b/smartassist/src/static/js/frontend.js index f62a278..54f0453 100644 --- a/smartassist/src/static/js/frontend.js +++ b/smartassist/src/static/js/frontend.js @@ -3,7 +3,13 @@ const chatbox = document.getElementById('chatbox'); const userInput = document.getElementById('userInput'); -const parser = window.markdownit(); +const parser = window.markdownit({ + linkify: true, + strikethrough: true, +}); + +parser.enable(['table']); + // const html = markdownIt.use({ // // You can customize the parser options here, e.g., enable/disable certain features @@ -42,18 +48,6 @@ function sendMessage() { } } -function customRenderer(markdownText) { - // Use a regex pattern to match LaTeX code (e.g. $$...$$ or $...$) - const latexPattern = /(?:\$\$|\\\[)(.*?)?(?:\$\$|\\\])/g; - - // Replace each occurrence of LaTeX code with an HTML span element - const html = markdownText.replace(latexPattern, (match, p1) => { - return `${p1}`; - }); - - // Return the rendered HTML - return html; -} // Define a function to render a message in the chatbox with a specific class name @@ -67,20 +61,18 @@ function renderMessage(text, className) { // // Set the text content of the element to the message text // messageElement.textContent = text; - // Parse Markdown text into HTML and set it as the innerHTML of the element - // messageElement.innerHTML = marked.parse(text); - // Use the markdown-it parser const html = parser.render(text); messageElement.innerHTML = html; - // Typeset math // Append the message element to the chatbox immediately - chatbox.appendChild(messageElement); + // chatbox.appendChild(messageElement); // Typeset math in the message element MathJax.typesetPromise([messageElement]).then(() => { // No need to append anything here, it's already appended above + chatbox.appendChild(messageElement); + }); }