UNPKG

xml_schema_to_json

Version:

npm module to convert xml schemas to json - format

31 lines (30 loc) 678 B
/** * Escape special characters in the given string of html. * * @param {String} html * @return {String} */ module.exports = { escape: function(html) { return String(html) .replace(/&/g, '&amp;') .replace(/"/g, '&quot;') .replace(/'/g, '&#39;') .replace(/</g, '&lt;') .replace(/>/g, '&gt;'); }, /** * Unescape special characters in the given string of html. * * @param {String} html * @return {String} */ unescape: function(html) { return String(html) .replace(/&amp;/g, '&') .replace(/&quot;/g, '"') .replace(/&#39;/g, '\'') .replace(/&lt;/g, '<') .replace(/&gt;/g, '>'); } };