Created
October 19, 2020 11:55
-
-
Save meirkl/19d545d9025196741e260c75ad9c4632 to your computer and use it in GitHub Desktop.
Decoding HTML entities with vanilla JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @param html encoded html | |
* example: | |
* <p>In this course, you&rsquo;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