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