From be4637a3a0b6e1ebc8766e6fa9ac48297d51a808 Mon Sep 17 00:00:00 2001
From: Cohee <18619528+Cohee1207@users.noreply.github.com>
Date: Sun, 28 Apr 2024 20:00:22 +0300
Subject: [PATCH] Handle
in message texts with Showdown instead of
manually
---
public/script.js | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/public/script.js b/public/script.js
index 92d3685a2..334b209d8 100644
--- a/public/script.js
+++ b/public/script.js
@@ -724,6 +724,7 @@ function reloadMarkdownProcessor(render_formulas = false) {
underline: true,
tables: true,
parseImgDimensions: true,
+ simpleLineBreaks: true,
extensions: [
showdownKatex(
{
@@ -742,6 +743,7 @@ function reloadMarkdownProcessor(render_formulas = false) {
parseImgDimensions: true,
tables: true,
underline: true,
+ simpleLineBreaks: true,
extensions: [markdownUnderscoreExt()],
});
}
@@ -1807,9 +1809,7 @@ function messageFormatting(mes, ch_name, isSystem, isUser, messageId) {
}
if (this_chid === undefined && !selected_group) {
- mes = mes
- .replace(/\*\*(.+?)\*\*/g, '$1')
- .replace(/\n/g, '
');
+ mes = mes.replace(/\*\*(.+?)\*\*/g, '$1');
} else if (!isSystem) {
// Save double quotes in tags as a special character to prevent them from being encoded
if (!power_user.encode_tags) {
@@ -1841,7 +1841,6 @@ function messageFormatting(mes, ch_name, isSystem, isUser, messageId) {
// Firefox creates extra newlines from
s in code blocks, so we replace them before converting newlines to
s.
return match.replace(/\n/gm, '\u0000');
});
- mes = mes.replace(/\n/g, '
');
mes = mes.replace(/\u0000/g, '\n'); // Restore converted newlines
mes = mes.trim();