{"id":24983654,"url":"https://github.com/posthtml/posthtml-replace","last_synced_at":"2025-07-01T13:08:19.695Z","repository":{"id":57328852,"uuid":"198245484","full_name":"posthtml/posthtml-replace","owner":"posthtml","description":null,"archived":false,"fork":false,"pushed_at":"2020-06-18T22:23:19.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-13T23:27:22.317Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/posthtml.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-22T14:56:39.000Z","updated_at":"2020-09-15T08:52:09.000Z","dependencies_parsed_at":"2022-09-13T06:02:59.735Z","dependency_job_id":null,"html_url":"https://github.com/posthtml/posthtml-replace","commit_stats":null,"previous_names":["damon4/posthtml-replace"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/posthtml/posthtml-replace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-replace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-replace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-replace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-replace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posthtml","download_url":"https://codeload.github.com/posthtml/posthtml-replace/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-replace/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260532664,"owners_count":23023551,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-04T09:20:03.789Z","updated_at":"2025-07-01T13:08:19.674Z","avatar_url":"https://github.com/posthtml.png","language":"JavaScript","readme":"# PostHTML Plugin Boilerplate \u003cimg align=\"right\" width=\"220\" height=\"200\" title=\"PostHTML logo\" src=\"http://posthtml.github.io/posthtml/logo.svg\"\u003e\n\n[![NPM][npm]][npm-url]\n[![Deps][deps]][deps-url]\n[![Build][build]][build-badge]\n[![Coverage][cover]][cover-badge]\n[![Standard Code Style][style]][style-url]\n[![Chat][chat]][chat-badge]\n\nClone this repo and explain what your plugin do and why thousands of people need it ;)\n\nBefore:\n``` html\n\u003c!doctype html\u003e\n\u003chead\u003e\n\t\u003clink rel=\"stylesheet\" href=\"/assets/css/main.css\"\u003e\n\t\u003cscript src=\"/assets/js/main.js\"\u003e\u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003cp\u003e\n\t\u003cimg src=\"/assets/images/main.png\" alt=\"\"\u003e\n\u003c/p\u003e\n\u003c/body\u003e\n```\n\nAfter:\n``` html\n\u003c!doctype html\u003e\n\u003chead\u003e\n\t\u003clink rel=\"stylesheet\" href=\"./assets/css/main.css\"\u003e\n\t\u003cscript src=\"./assets/js/main.js\"\u003e\u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003cp\u003e\n\t\u003cimg src=\"./assets/images/main.png\" alt=\"\"\u003e\n\u003c/p\u003e\n\u003c/body\u003e\n```\n\n## Install\n\nDescribe how big guys can install your plugin.\n\n\u003e npm i posthtml-replace --save-dev\n\n## Usage\n\nPlugin for html attribute replacing.\n\n``` js\nconst fs = require('fs');\nconst posthtml = require('posthtml');\nconst posthtmlReplace = require('posthtml-replace');\n\nposthtml()\n    .use(posthtmlReplace([\n         {\n           match: {\n             tag: 'link'\n           },\n           attrs: {\n             href: {\n               from: '/assets/css/',\n               to: './assets/css/'\n             }\n           }\n         },\n         {\n           match: {\n             tag: 'script'\n           },\n           attrs: {\n             src: {\n               from: '/assets/js/',\n               to: './assets/js/'\n             }\n           }\n         },\n         {\n           match: {\n             tag: 'img'\n           },\n           attrs: {\n             src: {\n               from: '/assets/images/',\n               to: './assets/images/'\n             }\n           }\n         }\n       ], {} ))\n    .process(html/*, options */)\n    .then(result =\u003e fs.writeFileSync('./after.html', result.html));\n```\n\n## Options\n\nDescribe all features of your plugin with examples of usage.\n\n### Feature\nBefore:\n``` html\n\u003chtml\u003e\n  \u003cbody\u003e\n    \u003cp\u003eOMG\u003c/p\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\nAdd option:\n``` js\nconst fs = require('fs');\nconst posthtml = require('posthtml');\nconst posthtmlPlugin = require('posthtml-plugin');\n\nposthtml()\n    .use(posthtmlPlugin({ feature: 'wow' }))\n    .process(html/*, options */)\n    .then(result =\u003e fs.writeFileSync('./after.html', result.html));\n```\nAfter:\n``` html\n\u003chtml\u003e\n  \u003cbody\u003e\n    \u003cp class=\"wow\"\u003eOMG\u003c/p\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Contributing\n\nSee [PostHTML Guidelines](https://github.com/posthtml/posthtml/tree/master/docs) and [contribution guide](CONTRIBUTING.md).\n\n### License [MIT](LICENSE)\n\n[npm]: https://img.shields.io/npm/v/posthtml.svg\n[npm-url]: https://npmjs.com/package/posthtml-replace\n\n[deps]: https://david-dm.org/posthtml/posthtml.svg\n[deps-url]: https://david-dm.org/posthtml/posthtml\n\n[style]: https://img.shields.io/badge/code%20style-standard-yellow.svg\n[style-url]: http://standardjs.com/\n\n[build]: https://travis-ci.org/posthtml/posthtml.svg?branch=master\n[build-badge]: https://travis-ci.org/posthtml/posthtml?branch=master\n\n[cover]: https://coveralls.io/repos/posthtml/posthtml/badge.svg?branch=master\n[cover-badge]: https://coveralls.io/r/posthtml/posthtml?branch=master\n\n\n[chat]: https://badges.gitter.im/posthtml/posthtml.svg\n[chat-badge]: https://gitter.im/posthtml/posthtml?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge\"\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-replace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthtml%2Fposthtml-replace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-replace/lists"}