fix(parser): Correctly handle literal less-than signs in text
Browse filesThe previous parsing logic identified any literal less-than character ('<') as the start of an tag.
This caused text containing the symbol (e.g., "p < 0.05") to be prematurely truncated when edited.
src/frontend/HighlightedTextbox.svelte
CHANGED
@@ -119,14 +119,14 @@
|
|
119 |
});
|
120 |
for (let i = 0; i < clean_marked_text.length; i++) {
|
121 |
let char = clean_marked_text[i];
|
122 |
-
if (char === "<") {
|
123 |
in_tag = true;
|
124 |
if (text) {
|
125 |
new_value.push([text, category]);
|
126 |
}
|
127 |
text = "";
|
128 |
category = null;
|
129 |
-
} else if (char === ">") {
|
130 |
in_tag = false;
|
131 |
if (tag.slice(0, 4) === "mark") {
|
132 |
let match = /class="hl ([^"]+)"/.exec(tag);
|
|
|
119 |
});
|
120 |
for (let i = 0; i < clean_marked_text.length; i++) {
|
121 |
let char = clean_marked_text[i];
|
122 |
+
if (char === "<" && (i+5) <= clean_marked_text.length && clean_marked_text.slice(i+1,i+5) === "mark") {
|
123 |
in_tag = true;
|
124 |
if (text) {
|
125 |
new_value.push([text, category]);
|
126 |
}
|
127 |
text = "";
|
128 |
category = null;
|
129 |
+
} else if (char === ">" && in_tag) {
|
130 |
in_tag = false;
|
131 |
if (tag.slice(0, 4) === "mark") {
|
132 |
let match = /class="hl ([^"]+)"/.exec(tag);
|