Skip to content

Commit

Permalink
Minor polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed Jan 21, 2025
1 parent d4de742 commit e7e8d42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion __test__/main/lib/text.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ test("extractRefPatternsInText tricky cases", () => {
expect(e("Nested weirdness <→<→inner> outer>>")).toEqual(["<→inner"]);

expect(e("<→special@chars!>")).toEqual(["special@chars!"]);
expect(e("=including 123 numbers ")).toEqual(["including"]);
expect(e("=including 123 numbers ")).toEqual(["including 123 numbers"]);
expect(e("Spaces <→ surrounded by > extra")).toEqual(["surrounded by"]);
expect(e("= leading spaces")).toEqual(["leading spaces"]);
expect(e("= spaces in the middle are kept ")).toEqual(["spaces in the middle are kept"]);
Expand Down
13 changes: 7 additions & 6 deletions src/main/lib/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,13 @@ text.extractRefPatternsInText = (input) => {
if (input[i] === "=") {
const start = i + 1;
let end = start;
while (
(end < input.length && input[end] >= "A" && input[end] <= "Z") ||
(input[end] >= "a" && input[end] <= "z") ||
input[end] === " "
) {
end++;
for (; end < input.length; end++) {
const ch = input[end];
if (ch >= "A" && ch <= "Z") continue;
if (ch >= "a" && ch <= "z") continue;
if (ch >= "0" && ch <= "9") continue;
if (ch === " ") continue;
break;
}
const w = input.slice(start, end).trim();
if (w) {
Expand Down

0 comments on commit e7e8d42

Please sign in to comment.