mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Regex: Change how MD formatting works
Previously, there was a checkbox to select placement as MD display. This was counterintuitive since some users believed MD display enclosed the other placement options. Now, add a universal switch to finely tune what parts of a chat should be excluded with MD formatting. For example a regex with the option enabled with AI output selected will only format replies from the character. This is an improvement since users can now choose what parts of a chat to format rather than sticking with a global display specifier. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
@@ -7,6 +7,7 @@ export {
|
||||
}
|
||||
|
||||
const regex_placement = {
|
||||
// MD Display is deprecated. Do not use.
|
||||
MD_DISPLAY: 0,
|
||||
USER_INPUT: 1,
|
||||
AI_OUTPUT: 2,
|
||||
@@ -38,13 +39,17 @@ function regexFromString(input) {
|
||||
}
|
||||
|
||||
// Parent function to fetch a regexed version of a raw string
|
||||
function getRegexedString(rawString, placement, { characterOverride } = {}) {
|
||||
function getRegexedString(rawString, placement, { characterOverride, isMarkdown } = {}) {
|
||||
let finalString = rawString;
|
||||
if (extension_settings.disabledExtensions.includes("regex") || !rawString || placement === undefined) {
|
||||
return finalString;
|
||||
}
|
||||
|
||||
extension_settings.regex.forEach((script) => {
|
||||
if (script.markdownOnly && !isMarkdown) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (script.placement.includes(placement)) {
|
||||
finalString = runRegexScript(script, finalString, { characterOverride });
|
||||
}
|
||||
|
Reference in New Issue
Block a user