Exclude <style> tags from quote and underscore italics processing Fixes #3808

7987f02deed19d15beb411bd6290037edfdaaf6b

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +6 -6Ignore whitespace
public/script.js+1 -1
@@ -2133,7 +2133,7 @@ export function messageFormatting(mes, ch_name, isSystem, isUser, messageId, san
21332133 }
21342134
21352135 mes = mes.replace(
21362136 /<style>[\s\S]*?<\/style>|```[\s\S]*?```|~~~[\s\S]*?~~~|``[\s\S]*?``|`[\s\S]*?`|(".*?")|(\u201C.*?\u201D)|(\u00AB.*?\u00BB)|(\u300C.*?\u300D)|(\u300E.*?\u300F)|(\uFF02.*?\uFF02)/gmgim,
21372137 function (match, p1, p2, p3, p4, p5, p6) {
21382138 if (p1) {
21392139 // English double quotes
public/scripts/chats.js+1 -1
@@ -459,7 +459,7 @@ export async function appendFileContent(message, messageText) {
459459 * @copyright https://github.com/kwaroran/risuAI
460460 */
461461export function encodeStyleTags(text) {
462462 const styleRegex = /<style>(.+?)<\/style>/gmsgims;
463463 return text.replaceAll(styleRegex, (_, match) => {
464464 return `<custom-style>${escape(match)}</custom-style>`;
465465 });
public/scripts/showdown-underscore.js+4 -4
@@ -8,10 +8,10 @@ export const markdownUnderscoreExt = () => {
88
99 return [{
1010 type: 'output',
1111 regex: new RegExp('(<code(?:\\s+[^>]*)?>[\\s\\S]*?<\\/code>|<style(?:\\s+[^>]*)?>[\\s\\S]*?<\\/style>)|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'ggi'),
1212 replace: function(match, codeContenttagContent, italicContent) {
1313 if (codeContenttagContent) {
1414 // If it's inside <code> or <style> tags, return unchanged
1515 return match;
1616 } else if (italicContent) {
1717 // If it's an italic group, apply the replacement