From 822e4b88f51daadb0af88d49c328b61fd59b9dde Mon Sep 17 00:00:00 2001 From: Cohee Date: Sat, 1 Jul 2023 17:24:55 +0300 Subject: [PATCH] #606 Support multiline curly bias --- public/script.js | 10 ++++++---- public/style.css | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/public/script.js b/public/script.js index 37d3fb123..d324dfc76 100644 --- a/public/script.js +++ b/public/script.js @@ -1086,7 +1086,7 @@ function messageFormatting(mes, ch_name, isSystem, isUser) { mes = mes.replaceAll('\\begin{align*}', '$$'); mes = mes.replaceAll('\\end{align*}', '$$'); mes = converter.makeHtml(mes); - mes = mes.replace(/{{(\*?.*\*?)}}/g, ""); + mes = replaceBiasMarkup(mes); mes = mes.replace(/[\s\S]*?<\/code>/g, function (match) { // Firefox creates extra newlines from
s in code blocks, so we replace them before converting newlines to
s. @@ -1101,10 +1101,12 @@ function messageFormatting(mes, ch_name, isSystem, isUser) { }); } + /* // Hides bias from empty messages send with slash commands if (isSystem) { - mes = mes.replace(/{{(\*?.*\*?)}}/g, ""); + mes = mes.replace(/\{\{[\s\S]*?\}\}/gm, ""); } + */ if (!power_user.allow_name2_display && ch_name && !isUser && !isSystem) { mes = mes.replaceAll(`${ch_name}:`, ""); @@ -1534,7 +1536,7 @@ export function extractMessageBias(message) { const forbiddenMatches = ['user', 'char', 'time', 'date']; const found = []; - const rxp = /\{\{(.+?)\}\}/g; + const rxp = /\{\{([\s\S]+?)\}\}/gm; //const rxp = /{([^}]+)}/g; let curMatch; @@ -2741,7 +2743,7 @@ function formatMessageHistoryItem(chatItem, isInstruct) { } export function replaceBiasMarkup(str) { - return (str ?? '').replace(/{{(\*?.*\*?)}}/g, ''); + return (str ?? '').replace(/\{\{[\s\S]*?\}\}/gm, ''); } export async function sendMessageAsUser(textareaText, messageBias) { diff --git a/public/style.css b/public/style.css index fdecbc3f8..933b578a0 100644 --- a/public/style.css +++ b/public/style.css @@ -193,7 +193,7 @@ table.responsiveTable { text-align: right; } -.mes_text br { +.mes_text br, .mes_bias br { content: ' '; } @@ -5001,4 +5001,4 @@ body.waifuMode .zoomed_avatar { background-color: var(--SmartThemeBlurTintColor); text-align: center; line-height: 14px; -} \ No newline at end of file +}