Skip to content

Commit baa7f68

Browse files
committed
this turns out to be unnecessary
1 parent 728aeaf commit baa7f68

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

src/misc.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { distinctBy } from "@std/collections/distinct-by";
2-
import { escape as escapeHtml } from "@std/html/entities";
3-
import { escape as escapeRegex } from "@std/regexp/escape";
2+
import { escape } from "@std/regexp/escape";
43
import { Lazy } from "./cache.ts";
54

65
export const NEWLINES = /\r\n|\n|\r/g;
@@ -43,12 +42,6 @@ export const checkLocalStorage = lazy(() => {
4342
localStorage.length !== 0;
4443
}
4544
});
46-
export function newlineAsHtmlLineBreak(text: string): string {
47-
return text.replaceAll(NEWLINES, "<br/>");
48-
}
49-
export function escapeHtmlWithLineBreak(text: string): string {
50-
return newlineAsHtmlLineBreak(escapeHtml(text));
51-
}
5245
export function setIgnoreError(key: string, value: string): void {
5346
if (checkLocalStorage()) {
5447
try {
@@ -101,7 +94,7 @@ export function deduplicateErrors<T extends Error>(
10194
return distinctBy(errors, ({ message }) => message);
10295
}
10396
export function characterClass(characters: Iterable<string>): RegExp {
104-
return new RegExp(`[${escapeRegex([...characters].join(""))}]`, "u");
97+
return new RegExp(`[${escape([...characters].join(""))}]`, "u");
10598
}
10699
export function uniquePairs<T>(
107100
array: ReadonlyArray<T>,

telo_misikeke/telo_misikeke.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// @ts-self-types="./telo_misikeke.d.ts"
22

3-
import {
4-
escapeHtmlWithLineBreak,
5-
newlineAsHtmlLineBreak,
6-
} from "../src/misc.ts";
3+
import { escape } from "@std/html/entities";
74
import LINKU from "./linku_data.json" with { type: "json" };
85
import { ParserWithCallbacks } from "./Parser.js";
96
import { build_rules, getMessage } from "./rules.js";
@@ -15,10 +12,8 @@ export function errors(text) {
1512
.tokenize(text)
1613
.filter((token) => RULES[token.ruleName].category === "error")
1714
.map((token) => {
18-
const src = escapeHtmlWithLineBreak(token.text);
19-
const message = newlineAsHtmlLineBreak(
20-
getMessage(token.ruleName, token.match),
21-
);
15+
const src = escape(token.text);
16+
const message = getMessage(token.ruleName, token.match);
2217
return `"${src}" ${message}`;
2318
});
2419
}

0 commit comments

Comments
 (0)