mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Exclude <style> tags from quote and underscore italics processing
Fixes #3808
This commit is contained in:
@@ -2133,7 +2133,7 @@ export function messageFormatting(mes, ch_name, isSystem, isUser, messageId, san
|
|||||||
}
|
}
|
||||||
|
|
||||||
mes = mes.replace(
|
mes = mes.replace(
|
||||||
/```[\s\S]*?```|~~~[\s\S]*?~~~|``[\s\S]*?``|`[\s\S]*?`|(".*?")|(\u201C.*?\u201D)|(\u00AB.*?\u00BB)|(\u300C.*?\u300D)|(\u300E.*?\u300F)|(\uFF02.*?\uFF02)/gm,
|
/<style>[\s\S]*?<\/style>|```[\s\S]*?```|~~~[\s\S]*?~~~|``[\s\S]*?``|`[\s\S]*?`|(".*?")|(\u201C.*?\u201D)|(\u00AB.*?\u00BB)|(\u300C.*?\u300D)|(\u300E.*?\u300F)|(\uFF02.*?\uFF02)/gim,
|
||||||
function (match, p1, p2, p3, p4, p5, p6) {
|
function (match, p1, p2, p3, p4, p5, p6) {
|
||||||
if (p1) {
|
if (p1) {
|
||||||
// English double quotes
|
// English double quotes
|
||||||
|
@@ -459,7 +459,7 @@ export async function appendFileContent(message, messageText) {
|
|||||||
* @copyright https://github.com/kwaroran/risuAI
|
* @copyright https://github.com/kwaroran/risuAI
|
||||||
*/
|
*/
|
||||||
export function encodeStyleTags(text) {
|
export function encodeStyleTags(text) {
|
||||||
const styleRegex = /<style>(.+?)<\/style>/gms;
|
const styleRegex = /<style>(.+?)<\/style>/gims;
|
||||||
return text.replaceAll(styleRegex, (_, match) => {
|
return text.replaceAll(styleRegex, (_, match) => {
|
||||||
return `<custom-style>${escape(match)}</custom-style>`;
|
return `<custom-style>${escape(match)}</custom-style>`;
|
||||||
});
|
});
|
||||||
|
@@ -8,10 +8,10 @@ export const markdownUnderscoreExt = () => {
|
|||||||
|
|
||||||
return [{
|
return [{
|
||||||
type: 'output',
|
type: 'output',
|
||||||
regex: new RegExp('(<code(?:\\s+[^>]*)?>[\\s\\S]*?<\\/code>)|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'g'),
|
regex: new RegExp('(<code(?:\\s+[^>]*)?>[\\s\\S]*?<\\/code>|<style(?:\\s+[^>]*)?>[\\s\\S]*?<\\/style>)|\\b(?<!_)_(?!_)(.*?)(?<!_)_(?!_)\\b', 'gi'),
|
||||||
replace: function(match, codeContent, italicContent) {
|
replace: function(match, tagContent, italicContent) {
|
||||||
if (codeContent) {
|
if (tagContent) {
|
||||||
// If it's inside <code> tags, return unchanged
|
// If it's inside <code> or <style> tags, return unchanged
|
||||||
return match;
|
return match;
|
||||||
} else if (italicContent) {
|
} else if (italicContent) {
|
||||||
// If it's an italic group, apply the replacement
|
// If it's an italic group, apply the replacement
|
||||||
|
Reference in New Issue
Block a user