Add "Remove Unicode Formatting" command to clean Unicode text back to ASCII

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 15:01:54 +01:00
parent e7bcc6f789
commit 1c86ac5740
3 changed files with 23 additions and 2 deletions
+5 -1
View File
@@ -1,4 +1,4 @@
import { BOLD_MAP, ITALIC_MAP, BOLD_ITALIC_MAP } from "./unicode-maps";
import { BOLD_MAP, ITALIC_MAP, BOLD_ITALIC_MAP, UNICODE_TO_ASCII_MAP } from "./unicode-maps";
export type FormatStyle = "bold" | "italic" | "bold-italic";
@@ -12,3 +12,7 @@ export function transformText(text: string, style: FormatStyle): string {
const map = STYLE_MAPS[style];
return [...text].map(ch => map[ch] ?? ch).join("");
}
export function cleanText(text: string): string {
return [...text].map(ch => UNICODE_TO_ASCII_MAP.get(ch) ?? ch).join("");
}