html-to-json-parser
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -17,3 +17,8 @@ # CHANGELOG | ||
## v2.0.1 | ||
#### Dependency Updates | ||
- Update `xmldom` to the latest version `@xmldom/xmldom` | ||
## v2.0.0 | ||
@@ -20,0 +25,0 @@ |
@@ -1,2 +0,2 @@ | ||
import{DOMParser as t}from"xmldom";async function e(e,n=!1){return await new Promise((r,o)=>{try{const o={};let s;if("string"==typeof e){const n=(new t).parseFromString(e,"text/xml");n.firstChild&&(s=n.firstChild)}else s=e;const i=(t,e=o)=>{e.type=t.nodeName;const n=t.childNodes;if(null!==n&&n.length){e.content=[];for(let t=0;t<n.length;t++)3===n[t].nodeType?n[t].nodeValue&&e.content.push(n[t].nodeValue):(e.content.push({}),i(n[t],e.content[e.content.length-1]))}if(null!==t.attributes&&t.attributes.length){e.attributes={};for(let n=0;n<t.attributes.length;n++)e.attributes[t.attributes[n].nodeName]=t.attributes[n].nodeValue}};i(s),r(n?JSON.stringify(o):o)}catch(t){o(t)}})}async function n(e,n=!0){return await new Promise((r,o)=>{try{let o=e;"string"==typeof e&&(o=JSON.parse(e));const s=t=>{let e=`<${t.type}`;return t.attributes&&Object.entries(t.attributes).forEach(([t,n])=>{e+=` ${t}="${n}"`}),e+=">",t.content&&t.content.forEach(t=>{e+="string"==typeof t?t:s(t)}),e+=`</${t.type}>`,e},i=s(o);r(n?i:(new t).parseFromString(i,"text/xml"))}catch(t){o(t)}})}export{e as HTMLToJSON,n as JSONToHTML}; | ||
import{DOMParser as t}from"@xmldom/xmldom";async function e(e,n=!1){return await new Promise((r,o)=>{try{const o={};let s;if("string"==typeof e){const n=(new t).parseFromString(e,"text/xml");n.firstChild&&(s=n.firstChild)}else s=e;const i=(t,e=o)=>{e.type=t.nodeName;const n=t.childNodes;if(null!==n&&n.length){e.content=[];for(let t=0;t<n.length;t++)3===n[t].nodeType?n[t].nodeValue&&e.content.push(n[t].nodeValue):(e.content.push({}),i(n[t],e.content[e.content.length-1]))}if(null!==t.attributes&&t.attributes.length){e.attributes={};for(let n=0;n<t.attributes.length;n++)e.attributes[t.attributes[n].nodeName]=t.attributes[n].nodeValue}};i(s),r(n?JSON.stringify(o):o)}catch(t){o(t)}})}async function n(e,n=!0){return await new Promise((r,o)=>{try{let o=e;"string"==typeof e&&(o=JSON.parse(e));const s=t=>{let e=`<${t.type}`;return t.attributes&&Object.entries(t.attributes).forEach(([t,n])=>{e+=` ${t}="${n}"`}),e+=">",t.content&&t.content.forEach(t=>{e+="string"==typeof t?t:s(t)}),e+=`</${t.type}>`,e},i=s(o);r(n?i:(new t).parseFromString(i,"text/xml"))}catch(t){o(t)}})}export{e as HTMLToJSON,n as JSONToHTML}; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import{DOMParser as t}from"xmldom";var e=function(e,r){void 0===r&&(r=!1);try{return Promise.resolve(new Promise(function(n,o){try{var i,a={};if("string"==typeof e){var s=(new t).parseFromString(e,"text/xml");s.firstChild&&(i=s.firstChild)}else i=e;!function t(e,r){void 0===r&&(r=a),r.type=e.nodeName;var n=e.childNodes;if(null!==n&&n.length){r.content=[];for(var o=0;o<n.length;o++)3===n[o].nodeType?n[o].nodeValue&&r.content.push(n[o].nodeValue):(r.content.push({}),t(n[o],r.content[r.content.length-1]))}if(null!==e.attributes&&e.attributes.length){r.attributes={};for(var i=0;i<e.attributes.length;i++)r.attributes[e.attributes[i].nodeName]=e.attributes[i].nodeValue}}(i),n(r?JSON.stringify(a):a)}catch(t){o(t)}}))}catch(t){return Promise.reject(t)}},r=function(e,r){void 0===r&&(r=!0);try{return Promise.resolve(new Promise(function(n,o){try{var i=e;"string"==typeof e&&(i=JSON.parse(e));var a=function t(e){var r="<"+e.type;return e.attributes&&Object.entries(e.attributes).forEach(function(t){r+=" "+t[0]+'="'+t[1]+'"'}),r+=">",e.content&&e.content.forEach(function(e){r+="string"==typeof e?e:t(e)}),r+="</"+e.type+">"}(i);n(r?a:(new t).parseFromString(a,"text/xml"))}catch(t){o(t)}}))}catch(t){return Promise.reject(t)}};export{e as HTMLToJSON,r as JSONToHTML}; | ||
import{DOMParser as t}from"@xmldom/xmldom";var e=function(e,r){void 0===r&&(r=!1);try{return Promise.resolve(new Promise(function(n,o){try{var i,a={};if("string"==typeof e){var s=(new t).parseFromString(e,"text/xml");s.firstChild&&(i=s.firstChild)}else i=e;!function t(e,r){void 0===r&&(r=a),r.type=e.nodeName;var n=e.childNodes;if(null!==n&&n.length){r.content=[];for(var o=0;o<n.length;o++)3===n[o].nodeType?n[o].nodeValue&&r.content.push(n[o].nodeValue):(r.content.push({}),t(n[o],r.content[r.content.length-1]))}if(null!==e.attributes&&e.attributes.length){r.attributes={};for(var i=0;i<e.attributes.length;i++)r.attributes[e.attributes[i].nodeName]=e.attributes[i].nodeValue}}(i),n(r?JSON.stringify(a):a)}catch(t){o(t)}}))}catch(t){return Promise.reject(t)}},r=function(e,r){void 0===r&&(r=!0);try{return Promise.resolve(new Promise(function(n,o){try{var i=e;"string"==typeof e&&(i=JSON.parse(e));var a=function t(e){var r="<"+e.type;return e.attributes&&Object.entries(e.attributes).forEach(function(t){r+=" "+t[0]+'="'+t[1]+'"'}),r+=">",e.content&&e.content.forEach(function(e){r+="string"==typeof e?e:t(e)}),r+="</"+e.type+">"}(i);n(r?a:(new t).parseFromString(a,"text/xml"))}catch(t){o(t)}}))}catch(t){return Promise.reject(t)}};export{e as HTMLToJSON,r as JSONToHTML}; | ||
//# sourceMappingURL=index.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("xmldom")):"function"==typeof define&&define.amd?define(["exports","xmldom"],e):e((t||self).htmlToJsonParser={},t.xmldom)}(this,function(t,e){t.HTMLToJSON=function(t,n){void 0===n&&(n=!1);try{return Promise.resolve(new Promise(function(r,o){try{var i,s={};if("string"==typeof t){var a=(new e.DOMParser).parseFromString(t,"text/xml");a.firstChild&&(i=a.firstChild)}else i=t;!function t(e,n){void 0===n&&(n=s),n.type=e.nodeName;var r=e.childNodes;if(null!==r&&r.length){n.content=[];for(var o=0;o<r.length;o++)3===r[o].nodeType?r[o].nodeValue&&n.content.push(r[o].nodeValue):(n.content.push({}),t(r[o],n.content[n.content.length-1]))}if(null!==e.attributes&&e.attributes.length){n.attributes={};for(var i=0;i<e.attributes.length;i++)n.attributes[e.attributes[i].nodeName]=e.attributes[i].nodeValue}}(i),r(n?JSON.stringify(s):s)}catch(t){o(t)}}))}catch(t){return Promise.reject(t)}},t.JSONToHTML=function(t,n){void 0===n&&(n=!0);try{return Promise.resolve(new Promise(function(r,o){try{var i=t;"string"==typeof t&&(i=JSON.parse(t));var s=function t(e){var n="<"+e.type;return e.attributes&&Object.entries(e.attributes).forEach(function(t){n+=" "+t[0]+'="'+t[1]+'"'}),n+=">",e.content&&e.content.forEach(function(e){n+="string"==typeof e?e:t(e)}),n+="</"+e.type+">"}(i);r(n?s:(new e.DOMParser).parseFromString(s,"text/xml"))}catch(t){o(t)}}))}catch(t){return Promise.reject(t)}}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@xmldom/xmldom")):"function"==typeof define&&define.amd?define(["exports","@xmldom/xmldom"],e):e((t||self).htmlToJsonParser={},t.xmldom)}(this,function(t,e){t.HTMLToJSON=function(t,n){void 0===n&&(n=!1);try{return Promise.resolve(new Promise(function(r,o){try{var i,s={};if("string"==typeof t){var a=(new e.DOMParser).parseFromString(t,"text/xml");a.firstChild&&(i=a.firstChild)}else i=t;!function t(e,n){void 0===n&&(n=s),n.type=e.nodeName;var r=e.childNodes;if(null!==r&&r.length){n.content=[];for(var o=0;o<r.length;o++)3===r[o].nodeType?r[o].nodeValue&&n.content.push(r[o].nodeValue):(n.content.push({}),t(r[o],n.content[n.content.length-1]))}if(null!==e.attributes&&e.attributes.length){n.attributes={};for(var i=0;i<e.attributes.length;i++)n.attributes[e.attributes[i].nodeName]=e.attributes[i].nodeValue}}(i),r(n?JSON.stringify(s):s)}catch(t){o(t)}}))}catch(t){return Promise.reject(t)}},t.JSONToHTML=function(t,n){void 0===n&&(n=!0);try{return Promise.resolve(new Promise(function(r,o){try{var i=t;"string"==typeof t&&(i=JSON.parse(t));var s=function t(e){var n="<"+e.type;return e.attributes&&Object.entries(e.attributes).forEach(function(t){n+=" "+t[0]+'="'+t[1]+'"'}),n+=">",e.content&&e.content.forEach(function(e){n+="string"==typeof e?e:t(e)}),n+="</"+e.type+">"}(i);r(n?s:(new e.DOMParser).parseFromString(s,"text/xml"))}catch(t){o(t)}}))}catch(t){return Promise.reject(t)}}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "html-to-json-parser", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "This library converts HTML to JSON or JSON to HTML tree", | ||
@@ -65,4 +65,4 @@ "type": "module", | ||
"dependencies": { | ||
"xmldom": "^0.6.0" | ||
"@xmldom/xmldom": "^0.8.10" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
46996
+ Added@xmldom/xmldom@^0.8.10
+ Added@xmldom/xmldom@0.8.10(transitive)
- Removedxmldom@^0.6.0
- Removedxmldom@0.6.0(transitive)