Ensure trailing spaces are placed outside cloze deletions

This commit is contained in:
leedoughty 2025-11-24 18:27:59 +00:00
parent 5614d20bed
commit 12f6791d86

View file

@ -4,7 +4,12 @@
import { getRange, getSelection } from "./cross-browser";
function wrappedExceptForWhitespace(text: string, front: string, back: string): string {
const match = text.match(/^(\s*)([^]*?)(\s*)$/)!;
const normalizedText = text
.replace(/ /g, " ")
.replace(/ /g, " ")
.replace(/\u00A0/g, " ");
const match = normalizedText.match(/^(\s*)([^]*?)(\s*)$/)!;
return match[1] + front + match[2] + back + match[3];
}