|
@@ -24,15 +24,18 @@
|
|
char = textArea.value[i];
|
|
char = textArea.value[i];
|
|
}
|
|
}
|
|
|
|
|
|
- for (const [open, close, label] of pairs) {
|
|
|
|
- const lb = escaped ? `escaped ${label}` : label;
|
|
|
|
|
|
+ if (escaped) {
|
|
|
|
+ i++;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ for (const [open, close, label] of pairs) {
|
|
if (char === open) {
|
|
if (char === open) {
|
|
- counts[lb] = (counts[lb] || 0) + 1;
|
|
|
|
|
|
+ counts[label] = (counts[label] || 0) + 1;
|
|
} else if (char === close) {
|
|
} else if (char === close) {
|
|
- counts[lb] = (counts[lb] || 0) - 1;
|
|
|
|
- if (counts[lb] < 0) {
|
|
|
|
- errors.add(`Incorrect order of ${lb}.`);
|
|
|
|
|
|
+ counts[label] = (counts[label] || 0) - 1;
|
|
|
|
+ if (counts[label] < 0) {
|
|
|
|
+ errors.add(`Incorrect order of ${label}.`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -52,21 +55,6 @@
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- for (const [open, close, label] of pairs) {
|
|
|
|
- const lb = `escaped ${label}`;
|
|
|
|
- if (counts[lb] == undefined) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const op = `\\${open}`;
|
|
|
|
- const cl = `\\${close}`;
|
|
|
|
- if (counts[lb] > 0) {
|
|
|
|
- errors.add(`${op} ... ${cl} - Detected ${counts[lb]} more opening than closing ${lb}.`);
|
|
|
|
- } else if (counts[lb] < 0) {
|
|
|
|
- errors.add(`${op} ... ${cl} - Detected ${-counts[lb]} more closing than opening ${lb}.`);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
counterElem.title = [...errors].join('\n');
|
|
counterElem.title = [...errors].join('\n');
|
|
counterElem.classList.toggle('error', errors.size !== 0);
|
|
counterElem.classList.toggle('error', errors.size !== 0);
|
|
}
|
|
}
|