Skip to content

Commit

Permalink
impr(custom text): add checkbox to toggle control character replacing…
Browse files Browse the repository at this point in the history
… (Shuja-Mahmood) (#4648)
  • Loading branch information
Shuja-Mahmood committed Sep 25, 2023
1 parent 2508d9d commit aee1cc1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 7 additions & 4 deletions frontend/src/ts/popups/custom-text-popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,13 @@ function apply(): void {
//replace zero width characters
text = text.replace(/[\u200B-\u200D\u2060\uFEFF]/g, "");

text = text.replace(/\\\\t/gm, "\t");
text = text.replace(/\\\\n/gm, "\n");
text = text.replace(/\\t/gm, "\t");
text = text.replace(/\\n/gm, "\n");
if ($(`${popup} .replaceControlCharacters input`).prop("checked")) {
text = text.replace(/\\\\t/gm, "\t");
text = text.replace(/\\\\n/gm, "\n");
text = text.replace(/\\t/gm, "\t");
text = text.replace(/\\n/gm, "\n");
}

text = text.replace(/ +/gm, " ");
// text = text.replace(/(\r\n)+/g, "\r\n");
// text = text.replace(/(\n)+/g, "\n");
Expand Down
8 changes: 8 additions & 0 deletions frontend/static/html/popups.html
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,14 @@
Standardises typography symbols (for example “ and ” become ")
</div>
</label>
<label class="checkboxWithSub replaceControlCharacters">
<input type="checkbox" checked />
<div>Replace control characters</div>
<div class="sub">
Replace control characters (\n becomes a new line and \t becomes a
tab)
</div>
</label>
<label class="checkboxWithSub delimiterCheck">
<input type="checkbox" />
<div>Pipe Delimiter</div>
Expand Down

0 comments on commit aee1cc1

Please sign in to comment.