letzter Stand

This commit is contained in:
2025-12-08 00:19:32 +01:00
parent 37badea913
commit c63955f8a5

View File

@@ -4329,8 +4329,16 @@ function sanitizeAIComment(text) {
return ''; return '';
} }
let cleaned = text
.replace(/[\u200b-\u200f\u202a-\u202e\ufeff]/g, '') // strip zero-width/control spacing
.replace(/\u00a0/g, ' '); // normalize NBSP
// Strip leading label noise some models prepend (e.g. "**Kommentar**, **Inhalt**:")
const markerPattern = /^(?:\s*(?:\*\*|__)?\s*(kommentar|inhalt|text|content)\s*(?:\*\*|__)?\s*[,;:.\-–—`'"]*\s*)+/i;
cleaned = cleaned.replace(markerPattern, '');
// Clean up AI output: drop hidden tags, replace dashes, normalize spacing. // Clean up AI output: drop hidden tags, replace dashes, normalize spacing.
return text return cleaned
.replace(/<think>[\s\S]*?<\/think>/gi, '') .replace(/<think>[\s\S]*?<\/think>/gi, '')
.replace(/[-–—]+/g, (match, offset, full) => { .replace(/[-–—]+/g, (match, offset, full) => {
const prev = full[offset - 1]; const prev = full[offset - 1];
@@ -4339,6 +4347,7 @@ function sanitizeAIComment(text) {
const nextIsWord = next && /[A-Za-z0-9ÄÖÜäöüß]/.test(next); const nextIsWord = next && /[A-Za-z0-9ÄÖÜäöüß]/.test(next);
return prevIsWord && nextIsWord ? match : ', '; return prevIsWord && nextIsWord ? match : ', ';
}) })
.replace(/^[\s,;:.\-–—!?\u00a0"'`]+/, '')
.replace(/\s{2,}/g, ' ') .replace(/\s{2,}/g, ' ')
.trim(); .trim();
} }