{"bugs":{"url":"https://github.com/developit/preact-markup/issues"},"dist":{"shasum":"4889d1cc4340abf80155bf4d9c89cddecc53d4a6","tarball":"https://registry.npmjs.org/preact-markup/-/preact-markup-2.0.0.tgz","fileCount":19,"integrity":"sha512-1yPS+IuqJI6k9CoOLDj5x68W9rYp6cY4UqRNCXKt2QSRFcWhGrAZhv3fyz8i8urMu2zLuOrMJIxV4lhpVHHF/w==","signatures":[{"sig":"MEUCIAgWrsAd5sr3M6rwXHZX6pOJ2faB1AdY3MZbYkmsXTwJAiEAoCfhkPyo+bJSXtR+VUY5e2QhrRDgSEclF+j1d+9f0Lc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":74508,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdLN0rCRA9TVsSAnZWagAAoIoP/1Vkd8R0tOqGicBN1Sex\nxSG4LbiuGjfdGF5Rgt3SJ+uOdZAs3p1bDKGdTrKuY4SCLmdUYXK540RiVX2F\njjJ7lb/w8d3rIOwbz7xlSfG3PsmIp67G+5Pb+JrDPCQyqCbPJqejlOfwDceP\nnvgEgvwpZYgECSKH4dVnxnyOAeilNmr9j7x8cZj/07WZWzjFSZlj+Rofjb5y\n0ilCN8fCPzz790hQ/igpK9YgaEVT/1efdt7vx+aP+uV/jAXXMjwX+19kgrJs\nU1Foj66uvogs/QwJH3g3yRKzncRKaTGE9DdprQj7kW/c4e3+PIlMw6liBTY4\nA3zUcMvZbxlFWDJSwk+njzpiV/pRTCBQCLgfWV/vAh5Lwt6fPiYjGj9GpTN0\n7iRZhuRMjFopgsZ+lIqVQrQqpxw0hXTo7hFyd6OIj85yvUNpDEHMjZCTJ5Co\njyiXNM3TGlkKfldnlN3bTWYIeNl5Z15jxHSqqNcA4c4VqO83XH6TcCmoGMMu\nZH3Z0i4CAx6BDQjZvZ/yTmtgHgmAclbcaTmsBH+BJ1MQ3ff61ys+tozSEg2l\nQylh4rb+EFCKliUJXxFxYUWnLfb0CjWilo2y3fLBknvReIogr2Y6cny+3A1R\n8bbT9Ud0YxZBnFMLP0rYOzxdf+pCP5yXAFTAdtUwkeYb8eJh8KJICcL+9hnn\nS482\r\n=A1CE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/preact-markup.js","name":"preact-markup","author":{"name":"Jason Miller","email":"jason@developit.ca"},"module":"dist/preact-markup.module.js","readme":"# preact-markup [![NPM](http://img.shields.io/npm/v/preact-markup.svg)](https://www.npmjs.com/package/preact-markup) [![travis-ci](https://travis-ci.org/developit/preact-markup.svg)](https://travis-ci.org/developit/preact-markup)\n\nA `<Markup>` component that renders HTML (or XML) using Virtual DOM, mapping a set of element names to Components. Works beautifully with [Preact].\n\n> **Think of this like an HTML5 renderer where Web Components are implemented as [Preact] Components**.\n\n### :zap: **[JSFiddle Demo](https://jsfiddle.net/developit/narb8qmo/)** :zap:\n\n<img src=\"https://i.gyazo.com/f98be3c0d3a40c50d151dbc72f317f2f.gif\" alt=\"demo preview\" width=\"425\" height=\"255\" />\n\n\n\n## Use Cases\n\n- Rendering Markdown in VDOM - see [preact-markdown](https://github.com/laggingreflex/preact-markdown)\n- Component-base app design and/or layout via HTML\n- Define app structure using a standard HTML CMS\n- Support arbitrary component extensions by allowing safe HTML\n- Build using Custom Elements, implemented using React's API\n\n\n---\n\n\n### Overview\n\nThe `<Markup />` component takes some `markup`, an optional mapping of custom element names to `components`, and an optional `type` of either `xml` or `html`.\n\nIn it's simplest form, `<Markup />` is just a diffing XML/HTML renderer. It only re-renders when you change the `markup` prop.\n\n```js\nimport Markup from 'preact-markup';\n\nlet html = `<h1>hello</h1> <p>Testing 1 2 3...</p>`;\nrender(<Markup markup={html} />, document.body);\n```\n\n> **Note:** by default, content is parsed as XML, which may be too strict for your content but is the fastest option. Pass `type=\"html\"` to parse as HTML.\n\n\n### Custom Elements via Components\n\nThe real value of `<Markup />` is seen when passing a `components` prop. This prop is an Object that lets us map any HTML/XML element name to a preact Component. The mapped component is injected and rendered as if it had been referenced from within JSX. HTML attributes defined on the custom element in `markup` get passed to the mapped Component as `props`.\n\n```js\nimport Markup from 'preact-markup';\n\nconst Sidebar = ({ title, children }) => (\n\t<aside class=\"sidebar\">\n\t\t<h2>{ title }</h2>\n\t\t{ children }\n\t</aside>\n);\n\nlet html = `\n<h1>Hello, World</h1>\n<sidebar title=\"My Sidebar!\">\n\t<p>Sidebar contents.</p>\n</sidebar>\n`;\nrender(<Markup markup={html} components={{ Sidebar }} />, document.body);\n```\n\nWhen `render()` is invoked, Our `<Sidebar />` component is substituted for the `<sidebar>` element, which means it gets mounted and rendered like a normal Preact Component.  The result is this HTML DOM:\n\n```html\n<div class=\"markup\">\n\t<h1>Hello, World</h1>\n\t<aside class=\"sidebar\">\n\t\t<h2>My Sidebar!</h2>\n\t\t<p>Sidebar contents.</p>\n\t</aside>\n</div>\n```\n\nSubsequent `render()`s diff against that DOM just like a normal JSX rendering flow would.\n\n### Optional properties\n\n`type` - By default, content is parsed as XML. Pass `type=\"html\"` to use an HTML parser.\n\n`trim` - Trimming tries to emulate HTML semantics by default, but these differ from JSX semantics. Pass `false` to retain all whitespace, or `all` to omit all whitespace.\n\n`onError` - Suppress XML/HTML parse errors and instead pass them to this function.\n\n`allow-scripts` - By default, preact-markup sanitizes the rendered HTML by removing script tags. The `allow-scripts` property re-enables script tags, _executing any JavaScript code within them_.\n\n> ##### Example\n>\n> ```js\n> let markup = `<em>hello!</em><h1>asdflkj</h1><script>alert(\"Hello world\");</script>`;\n> render(<Markup markup={markup} allow-scripts />, document.body);\n> ```\n\n---\n\n\n### License\n\n[MIT]\n\n\n[Preact]: https://github.com/developit/preact\n[MIT]: http://choosealicense.com/licenses/mit/\n","source":"src/index.js","amdName":"preactMarkup","gitHead":"6f7427407de28911cae02365aee28cbfc7b66cda","license":"MIT","scripts":{"lint":"eslint {src,test}/*.js","test":"npm run -s lint && npm run -s test:karma","build":"microbundle build --raw","release":"npm run -s build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish","test:karma":"karma start --single-run","prepublishOnly":"npm-run-all build test"},"_npmUser":{"name":"developit","email":"jason@developit.ca"},"homepage":"https://github.com/developit/preact-markup","keywords":["preact","rich text","input"],"umd:main":"dist/preact-markup.umd.js","repository":{"url":"git+https://github.com/developit/preact-markup.git","type":"git"},"_npmVersion":"6.9.0","description":"Render HTML/XML using VDOM, with Custom Elements mapped to Components.","directories":{},"maintainers":[{"name":"developit","email":"jason@developit.ca"}],"_nodeVersion":"10.15.0","_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","diff":"^4.0.1","karma":"^4.1.0","mocha":"^6.1.4","sinon":"^7.3.2","eslint":"^6.0.1","preact":"^10.0.0-beta.3","rollup":"^1.16.7","webpack":"^4.35.3","karma-chai":"^0.1.0","sinon-chai":"^3.3.0","@babel/core":"^7.5.4","karma-mocha":"^1.0.1","microbundle":"^0.11.0","npm-run-all":"^4.1.5","babel-eslint":"^10.0.2","babel-loader":"^8.0.6","karma-webpack":"^4.0.2","preact-jsx-chai":"^3.0.0","karma-chai-sinon":"^0.1.5","@babel/preset-env":"^7.5.4","karma-mocha-reporter":"^2.0.3","karma-chrome-launcher":"^2.2.0","karma-sourcemap-loader":"^0.3.7","@babel/plugin-transform-react-jsx":"^7.3.0"},"peerDependencies":{"preact":"10.x"},"_npmOperationalInternal":{"tmp":"tmp/preact-markup_2.0.0_1563221290490_0.28169053349985984","host":"s3://npm-registry-packages"},"_id":"preact-markup@2.0.0","version":"2.0.0"}