{"_id":"@apteryxxyz/html2json","name":"@apteryxxyz/html2json","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.3":{"name":"@apteryxxyz/html2json","version":"1.0.3","description":"html to json & json to html","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha","lint":"eslint -c .eslintrc.js src test bench"},"repository":{"type":"git","url":"git+https://github.com/jxck/html2json.git"},"keywords":["html","json"],"author":{"name":"Jxck"},"license":"MIT","bugs":{"url":"https://github.com/jxck/html2json/issues"},"homepage":"https://github.com/jxck/html2json#readme","devDependencies":{"eslint":"^2.6.0","mocha":"^2.4.5"},"gitHead":"184fde384f2645983e230264c54817c7b69b5bf1","_id":"@apteryxxyz/html2json@1.0.3","_nodeVersion":"18.1.0","_npmVersion":"8.8.0","dist":{"integrity":"sha512-nn4h1ZKd5FZNdC5Wji1ps8wbPFAtkptg0zw81u/+Hlr6LddPv2rHohS2TV6ADpkfQQiNUos5lO2EjSeGBE774g==","shasum":"46cd494517a350eb59d1d7296ff2c887a186f44f","tarball":"https://registry.npmjs.org/@apteryxxyz/html2json/-/html2json-1.0.3.tgz","fileCount":14,"unpackedSize":39397,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG6wNfj4JmXT0Z9iGuW7E8k2W6uiZz/b+ITorYefXo1xAiEAyIo7D4FI1ffaBnkfRb1CUUq6EPcrIDVdGU1VaItj8vk="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjJdBlACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmokDBAAkSPNc1dpCxdEd7wwWSu1OZt2UQlj85ZuS/aPEjqU60iPojcj\r\nppUIVanWke3heGuuSM438PYVR0pqzpAidI5t/ZpVI9Bmk2eSxkUInG/7goEf\r\nuHrf+SzekEHPn4Fr8BpnilGTw2P3YVBaedMqODDfgfjQ9O/SJPwZGtWggZvv\r\nV7kILmNQhEp7ekLi2HIloN0+MgNb7LX803yNRwOwp9SKBmKhmkJDL6HivZAg\r\njZha81ow8HJAbDx7i1tq73JaZICXEN8LFlfcSrNEF8fpeVd51do5emGQV8qD\r\n25rVtabH449ptsgAkSGIJZrQFegYGNKzLoN0bA57EHi+fql5deYmxII66QHH\r\nuKuGd2V9FZJ4PE17xLopRJ6z9Rl+rMOYxTPCUij4dnouXbv2LSnlVum+XUMU\r\nvu3FlzLf+dt3BM7AdfW2qunGYO3pLRmkeCHGADEU4llOvy5QuWjA4tHswGA4\r\nOwbLYc6yezc/fS2xtT+onFWSYCZPGlXEcZKvmgozFXQkBJ9nBKNQLBfCYD+g\r\n3gNpIuUKqk9IknKgDFC9xRg/wUHwiR76nZhjkBVv8YCHcU3AOL9SKUFxeUMC\r\n5+GO9PEx8C8bNS1hVXZjJSyVsKZvcQLl/KlaWWAJjzrqFTGuiSh243gOUT92\r\nE8TEf9BokfKi0uP82AWszMH+bRzyjo3tzx4=\r\n=qRUu\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"apteryxxyz","email":"apteryx.xyz@gmail.com"},"maintainers":[{"name":"apteryxxyz","email":"apteryx.xyz@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/html2json_1.0.3_1663422564877_0.8631632884078821"},"_hasShrinkwrap":false}},"time":{"created":"2022-09-17T13:49:24.830Z","1.0.3":"2022-09-17T13:49:25.021Z","modified":"2022-09-17T13:49:25.153Z"},"maintainers":[{"name":"apteryxxyz","email":"apteryx.xyz@gmail.com"}],"description":"html to json & json to html","homepage":"https://github.com/jxck/html2json#readme","keywords":["html","json"],"repository":{"type":"git","url":"git+https://github.com/jxck/html2json.git"},"author":{"name":"Jxck"},"bugs":{"url":"https://github.com/jxck/html2json/issues"},"license":"MIT","readme":"# html2json & json2html\n\nThis is a modified version of [html2json](https://github.com/Jxck/html2json) intended for myself.\n\n## How to use\n\n### browser\n\ninclude htmlparser.js & html2json.js scripts:\n\n```html\n<script src=\"https://cdn.rawgit.com/blowsie/Pure-JavaScript-HTML5-Parser/master/htmlparser.js\"></script>\n<script src=\"src/html2json.js\"></script>\n```\n\n\n### node\n\n```sh\n$ npm install html2json\n```\n\n```javascript\nvar html2json = require('html2json').html2json;\nvar json2html = require('html2json').json2html;\n```\n\n\n### API\n\n```javascript\njson === html2json(document.body.innerHTML);\nhtml === json2html(json);\n\nconsole.assert(json === html);\n```\n\n\n### JSON format\n\nevery json has `node`\n\nmembers of `node` are\n\n- `root`\n- `element`\n- `text`\n- `comment`\n\n`root` node is the root of JSON, every JSON must have only one root `root`, could have `child`.\n\n`element` node represents html element, could have `tag`, `attr`, `child`.\n\n`text` node represents text element, could have `text`.\n\n`comment` node represents commment element, could have `text`.\n\n\n### Sample\n\nhtml:\n\n```html\n<div id=\"1\" class=\"foo\">\n<h2>sample text with <code>inline tag</code></h2>\n<pre id=\"demo\" class=\"foo bar\">foo</pre>\n<pre id=\"output\" class=\"goo\">goo</pre>\n<input id=\"execute\" type=\"button\" value=\"execute\"/>\n</div>\n```\n\njson:\n\n```javascript\n{\n  node: 'root',\n  child: [\n    {\n      node: 'element',\n      tag: 'div',\n      attr: { id: '1', class: 'foo' },\n      child: [\n        {\n          node: 'element',\n          tag: 'h2',\n          child: [\n            { node: 'text', text: 'sample text with ' },\n            { node: 'element', tag: 'code', child: [{ node: 'text', text: 'inline tag' }] }\n          ]\n        },\n        {\n          node: 'element',\n          tag: 'pre',\n          attr: { id: 'demo', class: ['foo', 'bar'] },\n          child: [{ node: 'text', text: 'foo' }]\n        },\n        {\n          node: 'element',\n          tag: 'pre',\n          attr: { id: 'output', class: 'goo' },\n          child: [{ node: 'text', text: 'goo' }]\n        },\n        {\n          node: 'element',\n          tag: 'input',\n          attr: { id: 'execute', type: 'button', value: 'execute' }\n        }\n      ]\n    }\n  ]\n}\n```\n\n\n## Dependencies\n\n[htmlparser.js](https://github.com/blowsie/Pure-JavaScript-HTML5-Parser)\n\nrepositry includes this at `lib/` as git subtree.\n\n\n## CHANGELOG\n\n- 1.0.2\n - fix [#16](https://github.com/Jxck/html2json/issues/16) with merge [#17](https://github.com/Jxck/html2json/issues/17)\n- 1.0.1\n - fix [#14](https://github.com/Jxck/html2json/issues/14)\n\nbefore 1.0.0\n\n- Basically inline tag is melted into text\n- `Input`, `textarea`, `image` tags are act like block tag\n\n\n## License\n\nMIT\n","readmeFilename":"README.md"}