textReplace: pad space only in string rules (#1738)
This commit is contained in:
parent
7d8f3508a8
commit
1f87d14ab2
|
@ -213,15 +213,12 @@ function applyRules(content: string): string {
|
||||||
if (content.length === 0)
|
if (content.length === 0)
|
||||||
return content;
|
return content;
|
||||||
|
|
||||||
// pad so that rules can use " word " to only match whole "word"
|
|
||||||
content = " " + content + " ";
|
|
||||||
|
|
||||||
if (stringRules) {
|
if (stringRules) {
|
||||||
for (const rule of stringRules) {
|
for (const rule of stringRules) {
|
||||||
if (!rule.find || !rule.replace) continue;
|
if (!rule.find || !rule.replace) continue;
|
||||||
if (rule.onlyIfIncludes && !content.includes(rule.onlyIfIncludes)) continue;
|
if (rule.onlyIfIncludes && !content.includes(rule.onlyIfIncludes)) continue;
|
||||||
|
|
||||||
content = content.replaceAll(rule.find, rule.replace.replaceAll("\\n", "\n"));
|
content = ` ${content} `.replaceAll(rule.find, rule.replace.replaceAll("\\n", "\n")).replace(/^\s|\s$/g, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue