Skip to content

Commit

Permalink
[fix] customReplace(): error when search contains like \.\!\?
Browse files Browse the repository at this point in the history
  • Loading branch information
Benature committed Mar 14, 2024
1 parent 966af6b commit 5aafcdc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## 🏗️ developed
> to be updated in the next version
- [fix] `customReplace()`: error when search contains like `\.\!\?`
- [updated] `Chinese-punctuation`: select modification at last
- [updated] `math mode`:
- calculation support `=` and Greek letters
Expand Down
3 changes: 2 additions & 1 deletion src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@ export function extraDoubleSpaces(editor: Editor, view: MarkdownView): void {

export function customReplace(text: string, s: customReplaceSetting): string {
s.data.forEach(data => {
text = text.replace(new RegExp(JSON.parse(`"${data.search}"`), "g"), JSON.parse(`"${data.replace}"`))
const re = new RegExp(data.search, "g");
text = text.replace(re, JSON.parse(`"${data.replace}"`))
})
return text;
}
Expand Down

0 comments on commit 5aafcdc

Please sign in to comment.