diff --git a/task-regex.js b/task-regex.js
index 15800b3..3a08e94 100644
--- a/task-regex.js
+++ b/task-regex.js
@@ -709,7 +709,7 @@ function shouldApplyRuleForTaskContext(rule, stage = "") {
normalizedStage === "finalPrompt" || normalizedStage === "input.finalPrompt";
const isOutputStage = OUTPUT_STAGES.has(normalizedStage);
- if (rule.markdownOnly) {
+ if (rule.markdownOnly || rule.beautificationReplace) {
return isPromptStage;
}
diff --git a/tests/task-regex.mjs b/tests/task-regex.mjs
index b6320ee..90a5869 100644
--- a/tests/task-regex.mjs
+++ b/tests/task-regex.mjs
@@ -543,6 +543,51 @@ try {
markdownFinalDebug.entries[0].appliedRules.map((item) => item.id),
["markdown-final-strip"],
);
+ const beautifyFinalPromptSettings = buildSettings({
+ sources: {
+ global: true,
+ preset: false,
+ character: false,
+ },
+ });
+ setTestContext({
+ extensionSettings: {
+ regex: [
+ createTavernRule("beautify-final-strip", "/Decor/g", "
Decor
", {
+ placement: [PLACEMENT.USER_INPUT],
+ markdownOnly: false,
+ }),
+ ],
+ preset_allowed_regex: {},
+ character_allowed_regex: [],
+ },
+ });
+ initializeHostAdapter({});
+ const beautifyFinalInspect = inspectTaskRegexReuse(
+ beautifyFinalPromptSettings,
+ "extract",
+ );
+ const beautifyFinalRule = beautifyFinalInspect.activeRules.find(
+ (rule) => rule.id === "beautify-final-strip",
+ );
+ assert.equal(beautifyFinalRule?.promptReplaceAsEmpty, true);
+ assert.equal(beautifyFinalRule?.promptStageMode, "clear");
+ const beautifyFinalDebug = { entries: [] };
+ assert.equal(
+ applyTaskRegex(
+ beautifyFinalPromptSettings,
+ "extract",
+ "input.finalPrompt",
+ "Decor",
+ beautifyFinalDebug,
+ "user",
+ ),
+ "",
+ );
+ assert.deepEqual(
+ beautifyFinalDebug.entries[0].appliedRules.map((item) => item.id),
+ ["beautify-final-strip"],
+ );
const destinationBeautifySettings = buildSettings({
sources: {
global: true,
@@ -563,7 +608,7 @@ try {
prompt: false,
display: true,
},
- markdownOnly: true,
+ markdownOnly: false,
}),
createTavernRule("destination-display-only-text", "/Plain/g", "TEXT", {
placement: [],