Skip to content

Instantly share code, notes, and snippets.

@DylanCodeCabin
Created October 7, 2016 09:38
Show Gist options
  • Save DylanCodeCabin/df6c3671dff1a851fafaa62a6d680c05 to your computer and use it in GitHub Desktop.
Save DylanCodeCabin/df6c3671dff1a851fafaa62a6d680c05 to your computer and use it in GitHub Desktop.
Decodes html entities back to normal html
function decodeHtmlEntities(str) {
console.log(str);
var special = {
"&lt;" : "<",
"&gt;" : ">",
"&quot;" : '"',
"&apos;" : "'",
"&#039;" : "'",
"&amp;" : "&",
"\\" : ""
};
for(var i in special){
while(str.indexOf(i) !== -1){
str = str.replace(i, special[i]);
}
}
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment