diff --git a/static/js/script.js b/static/js/script.js
index 59d3c93..255fb40 100644
--- a/static/js/script.js
+++ b/static/js/script.js
@@ -116,31 +116,31 @@ document.addEventListener('DOMContentLoaded', function() {
const targetElement = document.getElementById('target-text');
let highlightedText = '';
- // Entferne führende und nachfolgende Leerzeichen aus dem aktuellen Text für die Anzeige
- const trimmedText = currentText.trim();
+ // Verwende den ursprünglichen Text für die Anzeige, nicht den trimmten
+ const originalText = currentText;
- for (let i = 0; i < trimmedText.length; i++) {
+ for (let i = 0; i < originalText.length; i++) {
if (i < userInput.length) {
- if (userInput[i] === trimmedText[i]) {
+ if (userInput[i] === originalText[i]) {
// Für korrekt getippte Leerzeichen und Tabulatoren: sichtbar machen
- if (trimmedText[i] === ' ') {
- highlightedText += '·';
- } else if (trimmedText[i] === '\t') {
+ if (originalText[i] === ' ') {
+ highlightedText += '·';
+ } else if (originalText[i] === '\t') {
highlightedText += '→';
} else {
- highlightedText += `${trimmedText[i]}`;
+ highlightedText += `${originalText[i]}`;
}
} else {
- highlightedText += `${trimmedText[i]}`;
+ highlightedText += `${originalText[i]}`;
}
} else {
// Für nicht eingegebene Zeichen: Einrückungen anzeigen
- if (trimmedText[i] === ' ') {
+ if (originalText[i] === ' ') {
highlightedText += '·';
- } else if (trimmedText[i] === '\t') {
+ } else if (originalText[i] === '\t') {
highlightedText += '→';
} else {
- highlightedText += trimmedText[i];
+ highlightedText += originalText[i];
}
}
}