Update index.html
Browse files- index.html +27 -0
index.html
CHANGED
@@ -586,6 +586,33 @@ function displayMessage(message, role) {
|
|
586 |
sendBtn.click();
|
587 |
}
|
588 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
589 |
</script>
|
590 |
|
591 |
</body>
|
|
|
586 |
sendBtn.click();
|
587 |
}
|
588 |
});
|
589 |
+
function displayMessage(message, role) {
|
590 |
+
const messageElement = document.createElement('div');
|
591 |
+
messageElement.classList.add('message', `${role}-message`);
|
592 |
+
|
593 |
+
// Parse Markdown syntax
|
594 |
+
const markdownParsedMessage = parseMarkdown(message);
|
595 |
+
|
596 |
+
// Set HTML content
|
597 |
+
messageElement.innerHTML = markdownParsedMessage;
|
598 |
+
|
599 |
+
chatOutput.appendChild(messageElement);
|
600 |
+
chatOutput.scrollTop = chatOutput.scrollHeight;
|
601 |
+
}
|
602 |
+
|
603 |
+
function parseMarkdown(message) {
|
604 |
+
// Initialize Showdown converter
|
605 |
+
const converter = new showdown.Converter({
|
606 |
+
// Enable all Markdown extensions
|
607 |
+
simplifiedAutoLink: true,
|
608 |
+
strikethrough: true,
|
609 |
+
tables: true,
|
610 |
+
tasklists: true,
|
611 |
+
literalMidWordUnderscores: true,
|
612 |
+
});
|
613 |
+
// Convert Markdown to HTML
|
614 |
+
return converter.makeHtml(message);
|
615 |
+
}
|
616 |
</script>
|
617 |
|
618 |
</body>
|