Apply regex to parsed reasoning
| @@ -8,7 +8,7 @@ import { SlashCommand } from './slash-commands/SlashCommand.js'; | |||
| 8 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js'; | 8 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js'; |
| 9 | import { commonEnumProviders } from './slash-commands/SlashCommandCommonEnumsProvider.js'; | 9 | import { commonEnumProviders } from './slash-commands/SlashCommandCommonEnumsProvider.js'; |
| 10 | import { SlashCommandParser } from './slash-commands/SlashCommandParser.js'; | 10 | import { SlashCommandParser } from './slash-commands/SlashCommandParser.js'; |
| 11 | import { copyText, escapeRegex } from './utils.js'; | 11 | import { copyText, escapeRegex, isFalseBoolean } from './utils.js'; |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | * Gets a message from a jQuery element. | 14 | * Gets a message from a jQuery element. |
| @@ -172,13 +172,22 @@ function registerReasoningSlashCommands() { | |||
| 172 | name: 'reasoning-parse', | 172 | name: 'reasoning-parse', |
| 173 | returns: 'reasoning string', | 173 | returns: 'reasoning string', |
| 174 | helpString: t`Extracts the reasoning block from a string using the Reasoning Formatting settings.`, | 174 | helpString: t`Extracts the reasoning block from a string using the Reasoning Formatting settings.`, |
| 175 | namedArgumentList: [ | ||
| 176 | SlashCommandNamedArgument.fromProps({ | ||
| 177 | name: 'regex', | ||
| 178 | description: 'Whether to apply regex scripts to the reasoning content.', | ||
| 179 | typeList: ARGUMENT_TYPE.BOOLEAN, | ||
| 180 | defaultValue: 'true', | ||
| 181 | isRequired: false, | ||
| 182 | }), | ||
| 183 | ], | ||
| 175 | unnamedArgumentList: [ | 184 | unnamedArgumentList: [ |
| 176 | SlashCommandArgument.fromProps({ | 185 | SlashCommandArgument.fromProps({ |
| 177 | description: 'input string', | 186 | description: 'input string', |
| 178 | typeList: ARGUMENT_TYPE.STRING, | 187 | typeList: ARGUMENT_TYPE.STRING, |
| 179 | }), | 188 | }), |
| 180 | ], | 189 | ], |
| 181 | callback: (_, value) => { | 190 | callback: (args, value) => { |
| 182 | if (!value) { | 191 | if (!value) { |
| 183 | return ''; | 192 | return ''; |
| 184 | } | 193 | } |
| @@ -194,7 +203,10 @@ function registerReasoningSlashCommands() { | |||
| 194 | return ''; | 203 | return ''; |
| 195 | } | 204 | } |
| 196 | 205 | ||
| 197 | return getRegexedString(parsedReasoning.reasoning, regex_placement.REASONING); | 206 | const applyRegex = !isFalseBoolean(args.regex.toString()); |
| 207 | return applyRegex | ||
| 208 | ? getRegexedString(parsedReasoning.reasoning, regex_placement.REASONING) | ||
| 209 | : parsedReasoning.reasoning; | ||
| 198 | }, | 210 | }, |
| 199 | })); | 211 | })); |
| 200 | } | 212 | } |
| @@ -398,7 +410,7 @@ function registerReasoningAppEvents() { | |||
| 398 | 410 | ||
| 399 | // If reasoning was found, add it to the message | 411 | // If reasoning was found, add it to the message |
| 400 | if (parsedReasoning.reasoning) { | 412 | if (parsedReasoning.reasoning) { |
| 401 | message.extra.reasoning = parsedReasoning.reasoning; | 413 | message.extra.reasoning = getRegexedString(parsedReasoning.reasoning, regex_placement.REASONING); |
| 402 | } | 414 | } |
| 403 | 415 | ||
| 404 | // Update the message text if it was changed | 416 | // Update the message text if it was changed |