Skip to content

Instantly share code, notes, and snippets.

@premasagar
Created November 13, 2012 11:30
Show Gist options
  • Save premasagar/4065325 to your computer and use it in GitHub Desktop.
Save premasagar/4065325 to your computer and use it in GitHub Desktop.
// Helper function to escape a string for HTML rendering
// from Tasket project
function escapeHTML(string) {
return string.replace(/&(?!\w+;)/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment