Exclude <style> tags from quote and underscore italics processing Fixes #3808
| @@ -2133,7 +2133,7 @@ export function messageFormatting(mes, ch_name, isSystem, isUser, messageId, san | |||
| 2133 | } | 2133 | } |
| 2134 | 2134 | ||
| 2135 | mes = mes.replace( | 2135 | mes = mes.replace( |
| 2136 | /```[\s\S]*?```|~~~[\s\S]*?~~~|``[\s\S]*?``|`[\s\S]*?`|(".*?")|(\u201C.*?\u201D)|(\u00AB.*?\u00BB)|(\u300C.*?\u300D)|(\u300E.*?\u300F)|(\uFF02.*?\uFF02)/gm, | 2136 | /<style>[\s\S]*?<\/style>|```[\s\S]*?```|~~~[\s\S]*?~~~|``[\s\S]*?``|`[\s\S]*?`|(".*?")|(\u201C.*?\u201D)|(\u00AB.*?\u00BB)|(\u300C.*?\u300D)|(\u300E.*?\u300F)|(\uFF02.*?\uFF02)/gim, |
| 2137 | function (match, p1, p2, p3, p4, p5, p6) { | 2137 | function (match, p1, p2, p3, p4, p5, p6) { |
| 2138 | if (p1) { | 2138 | if (p1) { |
| 2139 | // English double quotes | 2139 | // English double quotes |
| @@ -459,7 +459,7 @@ export async function appendFileContent(message, messageText) { | |||
| 459 | * @copyright https://github.com/kwaroran/risuAI | 459 | * @copyright https://github.com/kwaroran/risuAI |
| 460 | */ | 460 | */ |
| 461 | export function encodeStyleTags(text) { | 461 | export function encodeStyleTags(text) { |
| 462 | const styleRegex = /<style>(.+?)<\/style>/gms; | 462 | const styleRegex = /<style>(.+?)<\/style>/gims; |
| 463 | return text.replaceAll(styleRegex, (_, match) => { | 463 | return text.replaceAll(styleRegex, (_, match) => { |
| 464 | return `<custom-style>${escape(match)}</custom-style>`; | 464 | return `<custom-style>${escape(match)}</custom-style>`; |
| 465 | }); | 465 | }); |
| @@ -8,10 +8,10 @@ export const markdownUnderscoreExt = () => { | |||
| 8 | 8 | ||
| 9 | return [{ | 9 | return [{ |
| 10 | type: 'output', | 10 | type: 'output', |
| 11 | regex: new RegExp('(<code(?:\\s+[^>]*)?>[\\s\\S]*?<\\/code>)|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'g'), | 11 | regex: new RegExp('(<code(?:\\s+[^>]*)?>[\\s\\S]*?<\\/code>|<style(?:\\s+[^>]*)?>[\\s\\S]*?<\\/style>)|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'gi'), |
| 12 | replace: function(match, codeContent, italicContent) { | 12 | replace: function(match, tagContent, italicContent) { |
| 13 | if (codeContent) { | 13 | if (tagContent) { |
| 14 | // If it's inside <code> tags, return unchanged | 14 | // If it's inside <code> or <style> tags, return unchanged |
| 15 | return match; | 15 | return match; |
| 16 | } else if (italicContent) { | 16 | } else if (italicContent) { |
| 17 | // If it's an italic group, apply the replacement | 17 | // If it's an italic group, apply the replacement |