MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / escapeHtml

Function escapeHtml

packages/playground/src/util/Dom.ts:5–22  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

3}
4
5export function escapeHtml(value: unknown): string {
6 return String(value).replace(/[&<>"']/g, c => {
7 switch (c) {
8 case '&':
9 return '&amp;';
10 case '<':
11 return '&lt;';
12 case '>':
13 return '&gt;';
14 case '"':
15 return '&quot;';
16 case "'":
17 return '&#39;';
18 default:
19 return c;
20 }
21 });
22}
23
24export function html(strings: TemplateStringsArray, ...values: unknown[]): string {
25 return String.raw({ raw: strings }, ...values.map(v => escapeHtml(v)));

Callers 2

constructorMethod · 0.90
htmlFunction · 0.85

Calls 2

StringClass · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected