{"name":"posthtml","version":"0.16.7-0","description":"HTML/XML processor","keywords":["html","xml","postproccessor","parser","transform","transformations","manipulation","preprocessor","processor"],"main":"./dist/index.js","module":"./dist/index.mjs","browser":"./dist/index.global.js","types":"./types/posthtml.d.ts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.js"}},"engines":{"node":">=12.0.0"},"dependencies":{"posthtml-parser":"^0.11.0","posthtml-render":"^3.0.0"},"devDependencies":{"@commitlint/cli":"^17.8.0","@commitlint/config-angular":"^17.8.0","@swc/core":"^1.3.93","@typescript-eslint/eslint-plugin":"^6.8.0","@typescript-eslint/parser":"^6.8.0","@vitest/coverage-v8":"^0.34.6","eslint":"^8.51.0","husky":"^8.0.3","jsdoc-to-markdown":"^8.0.0","lint-staged":"^15.0.2","tsup":"^7.2.0","typescript":"^5.2.2","vitest":"^0.34.6"},"scripts":{"build":"rm -rf dist && tsup src/*.ts --format esm,cjs,iife --sourcemap --minify","prepare":"husky install && npm run build","test":"vitest run --coverage","docs:api":"jsdoc2md lib/api.js > docs/api.md","docs:core":"jsdoc2md lib/index.js > docs/core.md","lint":"eslint . --ext .ts"},"author":{"name":"Ivan Voischev","email":"voischev.ivan@ya.ru"},"contributors":[{"name":"Ivan Voischev","email":"voischev.ivan@ya.ru"},{"name":"Ivan Demidov","email":"scrum@list.ru"}],"homepage":"https://posthtml.org","repository":{"type":"git","url":"git+https://github.com/posthtml/posthtml.git"},"bugs":{"url":"https://github.com/posthtml/posthtml/issues"},"license":"MIT","readme":"[![NPM][npm]][npm-url]\n[![Tests][build]][build-url]\n[![Coverage][cover]][cover-url]\n[![Standard Code Style][code-style]][code-style-url]\n[![Twitter][twitter]][twitter-url]\n\n# 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][docs-url].\n\n### Dependencies\n\n| Name | Status | Description |\n|:----:|:------:|:-----------:|\n|[posthtml-parser][parser]|[![npm][parser-badge]][parser-npm]| Parser HTML/XML to PostHTMLTree |\n|[posthtml-render][render]|[![npm][render-badge]][render-npm]| Render PostHTMLTree to HTML/XML |\n\n\n[docs]: https://github.com/posthtml/posthtml/blob/master/docs\n\n[parser]: https://github.com/posthtml/posthtml-parser\n[parser-badge]: https://img.shields.io/npm/v/posthtml-parser.svg\n[parser-npm]: https://npmjs.com/package/posthtml-parser\n\n[render]: https://github.com/posthtml/posthtml-render\n[render-badge]: https://img.shields.io/npm/v/posthtml-render.svg\n[render-npm]: https://npmjs.com/package/posthtml-render\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 |Status|Description|\n|:-----|:-----|:----------|\n|[posthtml-pug][pug]|[![npm][pug-badge]][pug-npm]|Pug Parser|\n|[sugarml][sugar]|[![npm][sugar-badge]][sugar-npm]|SugarML Parser|\n\n\n[pug]: https://github.com/posthtml/posthtml-pug\n[pug-badge]: https://img.shields.io/npm/v/posthtml-pug.svg\n[pug-npm]: https://npmjs.com/package/posthtml-pug\n\n[sugar]: https://github.com/posthtml/sugarml\n[sugar-badge]: https://img.shields.io/npm/v/sugarml.svg\n[sugar-npm]: https://npmjs.com/package/sugarml\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\n[npm]: https://img.shields.io/npm/v/posthtml.svg\n[npm-url]: https://npmjs.com/package/posthtml\n\n[build]: https://github.com/posthtml/posthtml/workflows/Actions%20Status/badge.svg?style=flat-square\n[build-url]: https://github.com/posthtml/posthtml/actions?query=workflow%3A%22CI+tests%22\n\n[cover]: https://coveralls.io/repos/posthtml/posthtml/badge.svg?branch=master\n[cover-url]: https://coveralls.io/r/posthtml/posthtml?branch=master\n\n[code-style]: https://img.shields.io/badge/code%20style-standard-yellow.svg\n[code-style-url]: http://standardjs.com/\n\n[twitter]: https://badgen.net/twitter/follow/posthtml\n[twitter-url]: https://twitter.com/PostHTML\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[docs-url]: https://github.com/posthtml/posthtml/tree/master/docs\n","readmeFilename":"readme.md","gitHead":"1750316c1305296c1baca9a880b03cb2e6d5e7d6","_id":"posthtml@0.16.7-0","_nodeVersion":"20.2.0","_npmVersion":"9.6.6","dist":{"integrity":"sha512-UrrAHv1ojhzkxnrie9ZmEqekrKzu/CSc36PMi+xSm/p7OzwHNIYQ/mWDOoPhqs9iqfIgMCadLYvZBPmfUDDP5A==","shasum":"c26d19f9b1cedadff9f679db13d5e831535131a2","tarball":"http://registry-npm.ywwl.com/posthtml/download/posthtml-0.16.7-0.tgz","fileCount":24,"unpackedSize":769881,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA5herxYnrcyqlXBvJZvykTiVd1Oqa84m4uzW3tAY8S+AiBsijea9xiN2eF4G2bvInB6LfGU8AEm0wO0TdKsQt/Zrw=="}],"size":173025,"noattachment":false,"key":"/posthtml/-/posthtml-0.16.7-0.tgz"},"_npmUser":{"name":"scrum","email":"scrum@list.ru"},"directories":{},"maintainers":[{"name":"voischev","email":"voischev.ivan@ya.ru"},{"name":"scrum","email":"scrum@list.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/posthtml_0.16.7-0_1697794911427_0.4034884906028957"},"_hasShrinkwrap":false,"publish_time":1697794911700,"_cnpm_publish_time":1697794911700,"dist-tags":{"beta":"0.16.7-beta.0","latest":"0.16.7"}}