File tree Expand file tree Collapse file tree 2 files changed +5
-17
lines changed Expand file tree Collapse file tree 2 files changed +5
-17
lines changed Original file line number Diff line number Diff line change 1
1
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" ;
4
3
import { Lazy } from "./cache.ts" ;
5
4
6
5
export const NEWLINES = / \r \n | \n | \r / g;
@@ -43,12 +42,6 @@ export const checkLocalStorage = lazy(() => {
43
42
localStorage . length !== 0 ;
44
43
}
45
44
} ) ;
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
- }
52
45
export function setIgnoreError ( key : string , value : string ) : void {
53
46
if ( checkLocalStorage ( ) ) {
54
47
try {
@@ -101,7 +94,7 @@ export function deduplicateErrors<T extends Error>(
101
94
return distinctBy ( errors , ( { message } ) => message ) ;
102
95
}
103
96
export function characterClass ( characters : Iterable < string > ) : RegExp {
104
- return new RegExp ( `[${ escapeRegex ( [ ...characters ] . join ( "" ) ) } ]` , "u" ) ;
97
+ return new RegExp ( `[${ escape ( [ ...characters ] . join ( "" ) ) } ]` , "u" ) ;
105
98
}
106
99
export function uniquePairs < T > (
107
100
array : ReadonlyArray < T > ,
Original file line number Diff line number Diff line change 1
1
// @ts -self-types="./telo_misikeke.d.ts"
2
2
3
- import {
4
- escapeHtmlWithLineBreak ,
5
- newlineAsHtmlLineBreak ,
6
- } from "../src/misc.ts" ;
3
+ import { escape } from "@std/html/entities" ;
7
4
import LINKU from "./linku_data.json" with { type : "json" } ;
8
5
import { ParserWithCallbacks } from "./Parser.js" ;
9
6
import { build_rules , getMessage } from "./rules.js" ;
@@ -15,10 +12,8 @@ export function errors(text) {
15
12
. tokenize ( text )
16
13
. filter ( ( token ) => RULES [ token . ruleName ] . category === "error" )
17
14
. 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 ) ;
22
17
return `"${ src } " ${ message } ` ;
23
18
} ) ;
24
19
}
You can’t perform that action at this time.
0 commit comments