Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/html/entities.ts>unescape

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function unescape
import { unescape } from "https://deno.land/std@0.193.0/html/entities.ts";

Unescapes HTML entities in text

Examples

Example 1

import { unescape } from "https://deno.land/std@0.193.0/html/entities.ts";
import { assertEquals } from "https://deno.land/std@0.193.0/testing/asserts.ts";

// default options (only handles &<>'" and numeric entities)
assertEquals(unescape("&lt;&gt;&apos;&amp;&#65;&#x41;"), "<>'&AA");
assertEquals(unescape("&thorn;&eth;"), "&thorn;&eth;");

// using the full named entity list from the HTML spec (~47K unminified)
import entityList from "https://deno.land/std@0.193.0/html/named_entity_list.json" assert { type: "json" };
assertEquals(unescape("&thorn;&eth;", { entityList }), "þð");

Parameters

str: string
optional
options: Partial<UnescapeOptions> = [UNSUPPORTED]