Skip to content

Instantly share code, notes, and snippets.

@meirkl
Created October 19, 2020 11:55
Show Gist options
  • Save meirkl/19d545d9025196741e260c75ad9c4632 to your computer and use it in GitHub Desktop.
Save meirkl/19d545d9025196741e260c75ad9c4632 to your computer and use it in GitHub Desktop.
Decoding HTML entities with vanilla JavaScript
/**
*
* @param html encoded html
* example:
* <p>In this course, you’ll learn:</p>
* wiill get decoded to:
* <p>In this course, you'll learn:</p>
*/
function decode(html: string) {
var txt = document.createElement('textarea');
txt.innerHTML = html;
return txt.value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment