{"name":"posthtml","version":"0.6.0","description":"HTML/XML processor","keywords":["html","xml","postproccessor","parser","transform","transformations","manipulation","preprocessor","processor"],"author":{"name":"Anton Winogradov","email":"winogradovaa@gmail.com"},"contributors":[{"name":"Ivan Voischev","email":"voischev.ivan@ya.ru"},{"name":"Anton Winogradov","email":"winogradovaa@gmail.com"},{"name":"Alexej Yaroshevich","email":"zxqfox@gmail.com"}],"dependencies":{"htmlparser2":"^3.8.3"},"peerDependencies":{},"devDependencies":{"chai":"^3.0.0","chai-as-promised":"^5.1.0","chai-subset":"^1.1.0","conventional-changelog":"0.0.17","gulp":"^3.9.0","gulp-babel":"^5.1.0","gulp-json-editor":"^2.2.1","isparta":"^3.0.3","jscs":"^2.1.1","jshint":"^2.8.0","mocha":"^2.2.5","mversion":"^1.10.0","babel":"^5.8.21"},"main":"lib/posthtml","scripts":{"test":"npm run lint && npm run mocha && npm run coverage","mocha":"_mocha","clean":"rm -rf build coverage","build":"npm run clean && npm run test && gulp build","coverage":"babel-node node_modules/.bin/isparta cover --report text --report html --report lcov node_modules/.bin/_mocha","lint":"jshint . && jscs -v .","release-patch":"mversion patch","release-minor":"mversion minor","release-major":"mversion major"},"repository":{"type":"git","url":"git://github.com/posthtml/posthtml.git"},"license":"MIT","bugs":{"url":"https://github.com/posthtml/posthtml/issues"},"homepage":"https://github.com/posthtml/posthtml","_id":"posthtml@0.6.0","_shasum":"2955ba9bd2294e0562aa9a649158687b8762a6b4","_from":"build","_resolved":"file:build","_npmVersion":"2.14.6","_nodeVersion":"4.1.2","_npmUser":{"name":"voischev","email":"voischev.ivan@ya.ru"},"dist":{"shasum":"2955ba9bd2294e0562aa9a649158687b8762a6b4","tarball":"http://registry-npm.ywwl.com/posthtml/download/posthtml-0.6.0.tgz","integrity":"sha512-Ya/XppfrWtGijQLqKnwZx5LUe1KEMzfzjIupMYGm9gekxVA3BPWbpo6+1Cn65PuV9Ek4eaf2bvpL4kpXu5UaQA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCzndVSapEZQvyY+AFovTpkGc3/T2HJQAe4Dqx7yGhOxAIgcSTkwxbe5oQg7VDg8MqEyzlK+5DeBPsU0dT1pHoKvTk="}],"size":9045,"noattachment":false,"key":"/posthtml/-/posthtml-0.6.0.tgz"},"maintainers":[{"name":"voischev","email":"voischev.ivan@ya.ru"},{"name":"verybigman","email":"winogradovaa@gmail.com"},{"name":"qfox","email":"zxqfox@gmail.com"}],"directories":{},"readme":"# PostHTML <img align=\"right\" width=\"220\" height=\"200\" title=\"PostHTML\" src=\"http://posthtml.github.io/posthtml/logo.svg\">\n\nPostHTML is a tool for transforming HTML/XML with JS plugins. PostHTML itself is very small. It includes only a HTML parser, a HTML node tree API and a node tree stringifier.\n\nAll HTML transformations are made by plugins. And these plugins are just small plain JS functions, which receive a HTML node tree, transform it, and return a modified tree.\n\nFor more detailed information about PostHTML in general take a look at the [docs](https://github.com/posthtml/posthtml/tree/master/docs).\n\n### Dependencies\n\n| Name | Description |\n|:----:|:-----------:|\n|[posthtml-parser](https://github.com/posthtml/posthtml-parser)| Parser HTML/XML to PostHTMLTree |\n|[posthtml-render](https://github.com/posthtml/posthtml-render)| Render PostHTMLTree to HTML/XML |\n\n## Create to your project\n\n```bash\nnpm init posthtml\n```\n\n## Install\n\n```bash\nnpm i -D posthtml\n```\n\n## Usage\n\n### API\n\n**Sync**\n\n```js\nimport posthtml from 'posthtml'\n\nconst html = `\n  <component>\n    <title>Super Title</title>\n    <text>Awesome Text</text>\n  </component>\n`\n\nconst result = posthtml()\n  .use(require('posthtml-custom-elements')())\n  .process(html, { sync: true })\n  .html\n\nconsole.log(result)\n```\n\n```html\n<div class=\"component\">\n  <div class=\"title\">Super Title</div>\n  <div class=\"text\">Awesome Text</div>\n</div>\n```\n\n> :warning: Async Plugins can't be used in sync mode and will throw an Error. It's recommended to use PostHTML asynchronously whenever possible.\n\n**Async**\n\n```js\nimport posthtml from 'posthtml'\n\nconst html = `\n  <html>\n    <body>\n      <p class=\"wow\">OMG</p>\n    </body>\n  </html>\n`\n\nposthtml(\n  [\n    require('posthtml-to-svg-tags')(),\n    require('posthtml-extend-attrs')({\n      attrsTree: {\n        '.wow' : {\n          id: 'wow_id',\n          fill: '#4A83B4',\n          'fill-rule': 'evenodd',\n          'font-family': 'Verdana'\n        }\n      }\n    })\n  ])\n  .process(html/*, options */)\n  .then((result) =>  console.log(result.html))\n```\n\n```html\n<svg xmlns=\"http://www.w3.org/2000/svg\">\n  <text\n    class=\"wow\"\n    id=\"wow_id\"\n    fill=\"#4A83B4\"\n    fill-rule=\"evenodd\" font-family=\"Verdana\">\n      OMG\n  </text>\n</svg>\n```\n\n**Directives**\n\n```js\nimport posthtml from 'posthtml'\n\nconst php = `\n  <component>\n    <title><?php echo $title; ?></title>\n    <text><?php echo $article; ?></text>\n  </component>\n`\n\nconst result = posthtml()\n  .use(require('posthtml-custom-elements')())\n  .process(html, {\n    directives: [\n      { name: '?php', start: '<', end: '>' }\n    ]\n  })\n  .html\n\nconsole.log(result)\n```\n\n```html\n<div class=\"component\">\n  <div class=\"title\"><?php echo $title; ?></div>\n  <div class=\"text\"><?php echo $article; ?></div>\n</div>\n```\n\n### [CLI](https://npmjs.com/package/posthtml-cli)\n\n```bash\nnpm i posthtml-cli\n```\n\n```json\n\"scripts\": {\n  \"posthtml\": \"posthtml -o output.html -i input.html -c config.json\"\n}\n```\n\n```bash\nnpm run posthtml\n```\n\n### [Gulp](https://gulpjs.com)\n\n```bash\nnpm i -D gulp-posthtml\n```\n\n```js\nimport tap from 'gulp-tap'\nimport posthtml from 'gulp-posthtml'\nimport { task, src, dest } from 'gulp'\n\ntask('html', () => {\n  let path\n\n  const plugins = [ require('posthtml-include')({ root: `${path}` }) ]\n  const options = {}\n\n  src('src/**/*.html')\n    .pipe(tap((file) => path = file.path))\n    .pipe(posthtml(plugins, options))\n    .pipe(dest('build/'))\n})\n```\n\nCheck [project-stub](https://github.com/posthtml/project-stub) for an example with Gulp\n\n### [Grunt](https://gruntjs.com)\n\n```bash\nnpm i -D grunt-posthtml\n```\n\n```js\nposthtml: {\n  options: {\n    use: [\n      require('posthtml-doctype')({ doctype: 'HTML 5' }),\n      require('posthtml-include')({ root: './', encoding: 'utf-8' })\n    ]\n  },\n  build: {\n    files: [\n      {\n        dot: true,\n        cwd: 'html/',\n        src: ['*.html'],\n        dest: 'tmp/',\n        expand: true,\n      }\n    ]\n  }\n}\n```\n\n### [Webpack](https://webpack.js.org)\n\n```bash\nnpm i -D html-loader posthtml-loader\n```\n\n#### v1.x\n\n**webpack.config.js**\n\n```js\nconst config = {\n  module: {\n    loaders: [\n      {\n        test: /\\.html$/,\n        loader: 'html!posthtml'\n      }\n    ]\n  },\n  posthtml: (ctx) => ({\n    parser: require('posthtml-pug'),\n    plugins: [\n      require('posthtml-bem')()\n    ]\n  })\n}\n\nexport default config\n```\n\n#### v2.x\n\n**webpack.config.js**\n\n```js\nimport { LoaderOptionsPlugin } from 'webpack'\n\nconst config = {\n  module: {\n    rules: [\n      {\n        test: /\\.html$/,\n        use: [\n          {\n            loader: 'html-loader',\n            options: { minimize: true }\n          },\n          {\n            loader: 'posthtml-loader'\n          }\n        ]\n      }\n    ]\n  },\n  plugins: [\n    new LoaderOptionsPlugin({\n      options: {\n        posthtml(ctx) {\n          return {\n            parser: require('posthtml-pug'),\n            plugins: [\n              require('posthtml-bem')()\n            ]\n          }\n        }\n      }\n    })\n  ]\n}\n\nexport default config\n```\n\n### [Rollup](https://rollupjs.org/)\n\n```bash\n$ npm i rollup-plugin-posthtml -D\n# or\n$ npm i rollup-plugin-posthtml-template -D\n```\n\n```js\nimport { join } from 'path';\n\nimport posthtml from 'rollup-plugin-posthtml-template';\n// or\n// import posthtml from 'rollup-plugin-posthtml';\n\nimport sugarml from 'posthtml-sugarml';  // npm i posthtml-sugarml -D\nimport include from 'posthtml-include';  // npm i posthtml-include -D\n\nexport default {\n  entry: join(__dirname, 'main.js'),\n  dest: join(__dirname, 'bundle.js'),\n  format: 'iife',\n  plugins: [\n    posthtml({\n      parser: sugarml(),\n      plugins: [include()],\n      template: true  // only rollup-plugin-posthtml-template\n    })\n  ]\n};\n```\n\n## Parser\n\n```js\nimport pug from 'posthtml-pug'\n\nposthtml().process(html, { parser: pug(options) }).then((result) => result.html)\n```\n\n| Name |Description|\n|:-----|:----------|\n|[posthtml-pug](https://github.com/posthtml/posthtml-pug)|Pug Parser|\n|[sugarml](https://github.com/posthtml/sugarml)|SugarML Parser|\n\n\n## Plugins\n\nIn case you want to develop your own plugin, we recommend using [posthtml-plugin-starter][plugin] to get started.\n\n- [posthtml-plugins](http://maltsev.github.io/posthtml-plugins)\n- [awesome-posthtml](https://github.com/posthtml/awesome-posthtml)\n\n[plugin]: https://github.com/posthtml/posthtml-plugin-starter\n\n## Maintainers\n\n<table>\n  <tbody>\n   <tr>\n    <td align=\"center\">\n      <img width=\"150 height=\"150\"\n      src=\"https://avatars0.githubusercontent.com/u/2789192?s=460&v=4\">\n      <br />\n      <a href=\"https://github.com/scrum\">Ivan Demidov</a>\n    </td>\n    <td align=\"center\">\n      <img width=\"150 height=\"150\"\n      src=\"https://avatars.githubusercontent.com/u/1510217?v=3&s=150\">\n      <br />\n      <a href=\"https://github.com/voischev\">Ivan Voischev</a>\n    </td>\n   </tr>\n  <tbody>\n</table>\n\n## Contributors\n\n<a href=\"https://github.com/posthtml/posthtml/graphs/contributors\"><img src=\"https://opencollective.com/posthtml/contributors.svg?width=890&button=false\" /></a>\n\n## Backers\n\nThank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/posthtml#backer)]\n\n<a href=\"https://opencollective.com/posthtml#backers\" target=\"_blank\"><img src=\"https://opencollective.com/posthtml/backers.svg?width=885&button=false\"></a>\n\n[chat]: https://badges.gitter.im/posthtml/PostHTML.svg\n[chat-url]: https://gitter.im/posthtml/posthtml?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge\"\n","publish_time":1445090289784,"_cnpm_publish_time":1445090289784,"dist-tags":{"beta":"0.16.7-beta.0","latest":"0.16.7"}}