unescape
import { unescape } from "jsr:@ende/html";function
function unescape(str: string, options: Partial<UnescapeOptions> = [UNSUPPORTED]): stringUnescapes HTML entities in text.
Default options only handle &<>'" and numeric entities.
str: stringThe string to unescape.
options: Partial<UnescapeOptions> = [UNSUPPORTED]Options for unescaping.
Returns
The unescaped string.
Example: Basic usage
import { unescape } from "@ende/html/entities";
import { assertEquals } from "@ende/assert";
assertEquals(unescape("<>'&AA"), "<>'&AA");
assertEquals(unescape("þð"), "þð");
Example: Using a custom entity list
This uses the full named entity list from the HTML spec (~47K un-minified)
import { unescape } from "@ende/html/entities";
import entityList from "@ende/html/named-entity-list.json" with { type: "json" };
import { assertEquals } from "@ende/assert";
assertEquals(unescape("<>'&AA", { entityList }), "<>'&AA");