P
Philipp
How do I convert a string to escaped HTML? (Let's say I'm not using
DOM.) E.g. "<p>foo</p>" would become "<p>foo</p>"?
Reversely, how do I unescape a string to be HTML? E.g. "<em>"
would turn back into "<em>".
I mean a function like the following would do the job but is there a
more JS-native solution?
html = html.replace(/&/g, "&");
html = html.replace(/</g, "<");
html = html.replace(/>/g, ">");
html = html.replace(/"/g, """);
Thanks!
DOM.) E.g. "<p>foo</p>" would become "<p>foo</p>"?
Reversely, how do I unescape a string to be HTML? E.g. "<em>"
would turn back into "<em>".
I mean a function like the following would do the job but is there a
more JS-native solution?
html = html.replace(/&/g, "&");
html = html.replace(/</g, "<");
html = html.replace(/>/g, ">");
html = html.replace(/"/g, """);
Thanks!