Skip to main content
Module

std/html/entities.ts>unescape

Deno standard library
Go to Latest
function unescape
import { unescape } from "https://deno.land/std@0.201.0/html/entities.ts";

Unescapes HTML entities in text

Examples

Example 1

import { unescape } from "https://deno.land/std@0.201.0/html/entities.ts";
import { assertEquals } from "https://deno.land/std@0.201.0/assert/assert_equals.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.201.0/html/named_entity_list.json" assert { type: "json" };
assertEquals(unescape("&thorn;&eth;", { entityList }), "þð");

Parameters

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