oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.26k stars 2.69k forks source link

Implement `unescapeHTML` #1467

Open Electroid opened 1 year ago

Electroid commented 1 year ago

This should do the opposite of escapeHTML, and is useful for scenarios where text is extracted from HTMLRewriter, but needs to be unescaped.

eligrey commented 1 year ago

I don't think this is possible

Jarred-Sumner commented 1 year ago

@robobun

import React from 'react';
console.log(
  <div>hello</div>
);
robobun commented 1 year ago

@Jarred-Sumner Here is the output of the code you provided.

  error: Unexpected &
  &lt;div&gt;hello&lt;/div&gt;
  ^
/tmp/bun-ZnwRNs/index.ts:3:3 44

Code was run using the latest build of Bun.

Jarred-Sumner commented 1 year ago

@robobun

import React from 'react';
console.log(
  <div>hello</div>
);
robobun commented 1 year ago

@Jarred-Sumner here you go!

<div>hello</div>
Code ```tsx import React from 'react'; console.log(
hello
); ```

Ran using the latest build of Bun, an all-in-one JavaScript runtime.