-
-
Save saber-nyan/fed9fb8057912b0a3254baf9aa14022c to your computer and use it in GitHub Desktop.
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
function escapeHtml(in_) { | |
return in_.replace(/((?!<span style="background-color: #([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})">|<\/span>)[&<>"'/])/g, s => { | |
const entityMap = { | |
'&': '&', | |
'<': '<', | |
'>': '>', | |
'"': '"', | |
'\'': ''', | |
'/': '/', | |
}; | |
return entityMap[s]; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment