unescape(str: string,options?: Partial<UnescapeOptions>,): string
Unescapes HTML entities in text.
Default options only handle &<>'"
and numeric entities.
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");
str: string
The string to unescape.
optional
options: Partial<UnescapeOptions>
Options for unescaping.
The unescaped string.