Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions frontend/__tests__/utils/strings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,17 @@ describe("string utils", () => {
expect(Strings.splitIntoCharacters("t𐑩e")).toEqual(["t", "𐑩", "e"]);
});
});
describe("cleanTypographySymbols", () => {
it.each([
["„Hallo“", '"Hallo"'],
["ἀπ᾽", "ἀπ'"],
["„one“ „two“ ᾽᾽", '"one" "two" \'\''],
["plain text, 123!", "plain text, 123!"],
])("converts %s to %s", (input, expected) => {
expect(Strings.cleanTypographySymbols(input)).toBe(expected);
});
});

describe("replaceControlCharacters", () => {
it.each([
// Basic tab conversions
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/utils/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export function cleanTypographySymbols(textToClean: string): string {
"᾽": "'",
};
return textToClean.replace(
/[“”’‘—,…«»–\u2007\u202F\u00A0]/g,
/[“”„’‘᾽—,…«»–\u2007\u202F\u00A0]/g,
(char) => specials[char as keyof typeof specials] || "",
);
}
Expand Down
Loading