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 | 2135 | mes = mes.replace( |
| 2136 | 2136 | /<style>[\s\S]*?<\/style>|```[\s\S]*?```|~~~[\s\S]*?~~~|``[\s\S]*?``|`[\s\S]*?`|(".*?")|(\u201C.*?\u201D)|(\u00AB.*?\u00BB)|(\u300C.*?\u300D)|(\u300E.*?\u300F)|(\uFF02.*?\uFF02)/gmgim, |
| 2137 | 2137 | function (match, p1, p2, p3, p4, p5, p6) { |
| 2138 | 2138 | if (p1) { |
| 2139 | 2139 | // English double quotes |
| @@ -459,7 +459,7 @@ export async function appendFileContent(message, messageText) { | ||
| 459 | 459 | * @copyright https://github.com/kwaroran/risuAI |
| 460 | 460 | */ |
| 461 | 461 | export function encodeStyleTags(text) { |
| 462 | 462 | const styleRegex = /<style>(.+?)<\/style>/gmsgims; |
| 463 | 463 | return text.replaceAll(styleRegex, (_, match) => { |
| 464 | 464 | return `<custom-style>${escape(match)}</custom-style>`; |
| 465 | 465 | }); |
| @@ -8,10 +8,10 @@ export const markdownUnderscoreExt = () => { | ||
| 8 | 8 | |
| 9 | 9 | return [{ |
| 10 | 10 | type: 'output', |
| 11 | 11 | regex: new RegExp('(<code(?:\\s+[^>]*)?>[\\s\\S]*?<\\/code>|<style(?:\\s+[^>]*)?>[\\s\\S]*?<\\/style>)|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'ggi'), |
| 12 | 12 | replace: function(match, codeContenttagContent, italicContent) { |
| 13 | 13 | if (codeContenttagContent) { |
| 14 | 14 | // If it's inside <code> or <style> tags, return unchanged |
| 15 | 15 | return match; |
| 16 | 16 | } else if (italicContent) { |
| 17 | 17 | // If it's an italic group, apply the replacement |