{"_id":"@cheapsteak/hast-util-find-and-replace","_rev":"2-908c4c50f56b7443270719e5664f8c7f","name":"@cheapsteak/hast-util-find-and-replace","dist-tags":{"latest":"3.0.1"},"versions":{"3.0.0":{"name":"@cheapsteak/hast-util-find-and-replace","version":"3.0.0","description":"hast utility to find and replace text in a tree","license":"MIT","keywords":["unist","hast","hast-util","util","utility","html","find","replace"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/hast-util-find-and-replace.git"},"bugs":{"url":"https://github.com/syntax-tree/hast-util-find-and-replace/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"dependencies":{"escape-string-regexp":"^2.0.0","unist-util-is":"4.0.2","unist-util-visit-parents":"^3.0.0"},"devDependencies":{"browserify":"^16.0.0","hastscript":"^5.0.0","nyc":"^15.0.0","prettier":"^2.0.0","remark-cli":"^8.0.0","remark-preset-wooorm":"^7.0.0","tape":"^5.0.0","tinyify":"^2.0.0","xo":"^0.32.0"},"scripts":{"format":"remark . -qfo && prettier . --write && xo --fix","build-bundle":"browserify . -s hastUtilFindAndReplace > hast-util-find-and-replace.js","build-mangle":"browserify . -s hastUtilFindAndReplace -p tinyify > hast-util-find-and-replace.min.js","build":"npm run build-bundle && npm run build-mangle","test-api":"node test","test-coverage":"nyc --reporter lcov tape test.js","test":"npm run format && npm run build && npm run test-coverage"},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true,"esnext":false,"rules":{"unicorn/prefer-type-error":"off","guard-for-in":"off"},"ignores":["hast-util-find-and-replace.js"]},"nyc":{"check-coverage":true,"lines":100,"functions":100,"branches":100},"remarkConfig":{"plugins":["preset-wooorm"]},"gitHead":"ff4a6e3765cce9c2417d97f3f82d09f93c7d677b","homepage":"https://github.com/syntax-tree/hast-util-find-and-replace#readme","_id":"@cheapsteak/hast-util-find-and-replace@3.0.0","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","_npmUser":{"name":"cheapsteak","email":"garnwraly@gmail.com"},"dist":{"integrity":"sha512-GzMjb3Ci2bBmha120jcIBtZB3AwZ/AsPg/14S178akq2JqrIp/W3l7VfLoEs9G3uH8rYfeOMHgnJx8hsfb8MBw==","shasum":"beca646c827223616ab0038f5c1ae31613cdb736","tarball":"https://registry.npmjs.org/@cheapsteak/hast-util-find-and-replace/-/hast-util-find-and-replace-3.0.0.tgz","fileCount":4,"unpackedSize":12606,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfPZguCRA9TVsSAnZWagAA7JcQAJjdWGfEoRPNcY4LpQTM\nKaYRQAo+1K7xGMXjCsm13ze2ON2Tb8a5Hx8KY9qxYOVBLVlV5+2tIUrhTP6Q\nbmD5N/pOPlbJb5n7LXQFQRKhY2K2hjRHcxPMh/GAKmKoOS3nCGNUS5OQzbgK\nMMPpeTuKWm9R2nqYBesBjDnFMbdtiJAmSbaN5evU2iGPsiH7u7VcyLMG/w4r\nsPF5hyKT0K5nlmqY7ahNx4mUtOZvn94JwC2wc27khcrEF/qemCd41mMkxWaH\nb4uZRqNBwrrldnvI/flC59rZ4YYrTEXsDTBS2YoKfGuHlc4swx8jm4KUD871\n2nz7Ts4x59+y53eYTmOA8pxnQYjCxBTda+9g/mNlu9acijyMdV29GKpXYs/W\nZktBtR3ChMCnQi4lyVeAEAYFttybvsap3l9U+893cX9wR70K5I7OmSq4Nkda\nxG2BfMpY0R8qn4Ps1Pg2v1Cw4bheEL/9BGs+MrepJC0i4da7x1yIAFuN5dIj\nIhjWDx1wJzdZ5EtBCiEeG/51OKXdAX9e59O6ZsUz7zpFwRG1P9cfkHkKeR3P\n/dXoqfs2gIalW5p5vmDWyo6Cn9+LslMnb3eZMp/N3O0jcscDeoX0YHap/1BS\nI5cT4uMl2yTseehoMGbNqTR+uhGf0FrKoKz/0x//34E5w5ri9An9AI+NYEUG\ndz8T\r\n=GSvr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC7PltC6w5U7k2K/fw4rMWR3aSPC/8oDVqmnMBJE4tkAwIgJB80Lt/LgqM3Td4/CvYNrONVsuGS+CErsCNfbr9TYVQ="}]},"maintainers":[{"name":"cheapsteak","email":"garnwraly@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hast-util-find-and-replace_3.0.0_1597872174221_0.4979405747660197"},"_hasShrinkwrap":false},"3.0.1":{"name":"@cheapsteak/hast-util-find-and-replace","version":"3.0.1","description":"hast utility to find and replace text in a tree","license":"MIT","keywords":["unist","hast","hast-util","util","utility","html","find","replace"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/hast-util-find-and-replace.git"},"bugs":{"url":"https://github.com/syntax-tree/hast-util-find-and-replace/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"dependencies":{"escape-string-regexp":"^2.0.0","unist-util-is":"4.0.2","unist-util-visit-parents":"^3.0.0"},"devDependencies":{"browserify":"^16.0.0","hastscript":"^5.0.0","nyc":"^15.0.0","prettier":"^2.0.0","remark-cli":"^8.0.0","remark-preset-wooorm":"^7.0.0","tape":"^5.0.0","tinyify":"^2.0.0","xo":"^0.32.0"},"scripts":{"format":"remark . -qfo && prettier . --write && xo --fix","build-bundle":"browserify . -s hastUtilFindAndReplace > hast-util-find-and-replace.js","build-mangle":"browserify . -s hastUtilFindAndReplace -p tinyify > hast-util-find-and-replace.min.js","build":"npm run build-bundle && npm run build-mangle","test-api":"node test","test-coverage":"nyc --reporter lcov tape test.js","test":"npm run format && npm run build && npm run test-coverage"},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true,"esnext":false,"rules":{"unicorn/prefer-type-error":"off","guard-for-in":"off"},"ignores":["hast-util-find-and-replace.js"]},"nyc":{"check-coverage":true,"lines":100,"functions":100,"branches":100},"remarkConfig":{"plugins":["preset-wooorm"]},"gitHead":"1dd0251f49bb40ea82818704f4074840b13d5175","homepage":"https://github.com/syntax-tree/hast-util-find-and-replace#readme","_id":"@cheapsteak/hast-util-find-and-replace@3.0.1","_nodeVersion":"12.16.1","_npmVersion":"6.13.4","_npmUser":{"name":"cheapsteak","email":"garnwraly@gmail.com"},"dist":{"integrity":"sha512-MCaR5CYCwrTAXk6ySD1X8kxe7+sG1eM0Kg6wC54YTh5E2ciqhlcWiakChyDb6PFoQ7ruXAHy+qkYt6WBbLP7cw==","shasum":"8ca68a547d4ac753aba9425e3a70a94c713a9c6e","tarball":"https://registry.npmjs.org/@cheapsteak/hast-util-find-and-replace/-/hast-util-find-and-replace-3.0.1.tgz","fileCount":4,"unpackedSize":12606,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfPeDzCRA9TVsSAnZWagAAAbMQAIyjyqEVv1wWnzTV6Ohu\n93+KoS7RUS0oBWggPMgMs0mdb/b6kPtSUZ5QLQZM7rG8yWCy7PH0xMqUMLl3\niXxBRAu0pS3yanDTnY5vQgPq1Sen5lZSvFLaektj14hLnnMQa0WBA9Fe89hD\nMK14QUjpXS5sgCgaD1s6DqBVxJRRbjp7O55lT/fp9jZ6Z+TOV/Moj6i3b/BQ\nMFk4MtPpmh6FFVivZYWFiPFqdsEsovx/JPtq2TSzInzWJC/i2k/WD7B+BZs7\npxe7ASBDHC+HCUc3SBfeOXkYJ7ZehOSc1BQ1M+Qpvw1/Imqb0IwKS8nFqN9F\nNFM7/m/bB0mVYr8D8Ik4p/wtO4vR5YUV3OEoQmgnXtrUGLWAqSzMf5Cx8SWo\nVsz9wYvPg+TowDd/vFWAyznPMyIGW6RwdjFdvI+4XyqUoqMx4unkGFvLhhaY\nC2Lr+L7YO9up0wS4T8zBphTAq68zYzOIVyQnIvX0fS78k+uck9IUGZ7buBMK\nVz+gh40WkI+hF5xPvNz9Pk901UPEs4/UR23O/sucMWpJLqk8g8RRZU49cwQb\nBN+S/bcwZe7VHkM+Wept+fl8m/bIseBiD3PI8xjACTVaIuhHgghCnbk/6GKT\nl6LCO0ifAyjIDdJlW+k1VW4Mum6sRBtyjLTufR3y7B7BOvkex9Xt1sPNIZA1\n5bHd\r\n=YZFx\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCOK0YRVByIiGf0O+aIvap9xXd2HP5OMU+HRxln3rGFNQIhAInSZEWlpfovciAU50OPlDaF44lDoDQ4Ii0YV52eL3rH"}]},"maintainers":[{"name":"cheapsteak","email":"garnwraly@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hast-util-find-and-replace_3.0.1_1597890803272_0.3145115060903414"},"_hasShrinkwrap":false}},"time":{"created":"2020-08-19T21:22:54.188Z","3.0.0":"2020-08-19T21:22:54.338Z","modified":"2022-04-04T22:34:39.543Z","3.0.1":"2020-08-20T02:33:23.393Z"},"maintainers":[{"name":"cheapsteak","email":"garnwraly@gmail.com"}],"description":"hast utility to find and replace text in a tree","homepage":"https://github.com/syntax-tree/hast-util-find-and-replace#readme","keywords":["unist","hast","hast-util","util","utility","html","find","replace"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/hast-util-find-and-replace.git"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"bugs":{"url":"https://github.com/syntax-tree/hast-util-find-and-replace/issues"},"license":"MIT","readme":"# hast-util-find-and-replace\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[**hast**][hast] utility to find and replace text in a [*tree*][tree].\n\n## Install\n\n[npm][]:\n\n```sh\nnpm install hast-util-find-and-replace\n```\n\n## Use\n\n```js\nvar h = require('hastscript')\nvar inspect = require('unist-util-inspect')\nvar findAndReplace = require('hast-util-find-and-replace')\n\nvar tree = h('p', [\n  'Some ',\n  h('em', 'emphasis'),\n  ', ',\n  h('strong', 'importance'),\n  ', and ',\n  h('code', 'code'),\n  '.'\n])\n\nfindAndReplace(tree, 'and', 'or')\n\nfindAndReplace(tree, {emphasis: 'em', importance: 'strong'})\n\nfindAndReplace(tree, {\n  code: function($0) {\n    return h('a', {href: '//example.com#' + $0}, $0)\n  }\n})\n\nconsole.log(inspect(tree))\n```\n\nYields:\n\n```txt\nelement[9] [tagName=\"p\"]\n├─ text: \"Some \"\n├─ element[1] [tagName=\"em\"]\n│  └─ text: \"em\"\n├─ text: \", \"\n├─ element[1] [tagName=\"strong\"]\n│  └─ text: \"strong\"\n├─ text: \", \"\n├─ text: \"or\"\n├─ text: \" \"\n├─ element[1] [tagName=\"code\"]\n│  └─ element[1] [tagName=\"a\"][properties={\"href\":\"//example.com#code\"}]\n│     └─ text: \"code\"\n└─ text: \".\"\n```\n\n## API\n\n### `findAndReplace(tree, find[, replace][, options])`\n\nFind and replace text in a [**hast**][hast] [*tree*][tree].\nThe algorithm searches the tree in [*preorder*][preorder] for complete values\nin [`Text`][text] nodes.\nPartial matches are not supported.\n\n###### Signatures\n\n*   `findAndReplace(tree, find, replace[, options])`\n*   `findAndReplace(tree, search[, options])`\n\n###### Parameters\n\n*   `tree` ([`Node`][node])\n    — [**hast**][hast] [*tree*][tree]\n*   `find` (`string` or `RegExp`)\n    — Value to find and remove.\n    When `string`, escaped and made into a global `RegExp`\n*   `replace` (`string` or `Function`)\n    — Value to insert.\n    When `string`, turned into a [`Text`][text] node.\n    When `Function`, invoked with the results of calling `RegExp.exec` as\n    arguments, in which case it can return a [`Node`][node] or a `string`, which\n    is in the latter case wrapped in a [`Text`][text] node\n*   `search` (`Object` or `Array`)\n    — Perform multiple find-and-replace’s.\n    When `Array`, each entry is a tuple (`Array`) of a `find` (at `0`) and\n    `replace` (at `1`).\n    When `Object`, each key is a `find` (in string form) and each value is a\n    `replace`\n*   `options.ignore` (`Array`, default: `['title', 'script', 'style', 'svg',\n    'math']`)\n    — Tag-names of elements *not* to search.\n    This list can be accessed at `findAndReplace.ignore`\n\n###### Returns\n\nThe given, modified, `tree`.\n\n## Security\n\nImproper use of the `replace` can open you up to a\n[cross-site scripting (XSS)][xss] attack as the value of `replace` is injected\ninto the syntax tree.\nThe following example shows how a script is injected that runs when loaded in a\nbrowser.\n\n```js\nfindAndReplace(h('p', 'This and that.'), 'and', function() {\n  return h('script', 'alert(1)')\n})\n```\n\nYields:\n\n```html\n<p>This <script>alert(1)</script> that.</p>\n```\n\nDo not use user input in `replace` or use [`hast-util-santize`][sanitize].\n\n## Related\n\n*   [`hast-util-select`](https://github.com/syntax-tree/hast-util-select)\n    — `querySelector`, `querySelectorAll`, and `matches`\n*   [`unist-util-select`](https://github.com/syntax-tree/unist-util-select)\n    — select unist nodes with CSS-like selectors\n\n## Contribute\n\nSee [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get\nstarted.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n<!-- Definition -->\n\n[build-badge]: https://img.shields.io/travis/syntax-tree/hast-util-find-and-replace.svg\n\n[build]: https://travis-ci.org/syntax-tree/hast-util-find-and-replace\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-find-and-replace.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/hast-util-find-and-replace\n\n[downloads-badge]: https://img.shields.io/npm/dm/hast-util-find-and-replace.svg\n\n[downloads]: https://www.npmjs.com/package/hast-util-find-and-replace\n\n[size-badge]: https://img.shields.io/bundlephobia/minzip/hast-util-find-and-replace.svg\n\n[size]: https://bundlephobia.com/result?p=hast-util-find-and-replace\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-spectrum-7b16ff.svg\n\n[chat]: https://spectrum.chat/unified/syntax-tree\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md\n\n[hast]: https://github.com/syntax-tree/hast\n\n[node]: https://github.com/syntax-tree/hast#ndoes\n\n[tree]: https://github.com/syntax-tree/unist#tree\n\n[preorder]: https://github.com/syntax-tree/unist#preorder\n\n[text]: https://github.com/syntax-tree/hast#text\n\n[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[sanitize]: https://github.com/syntax-tree/hast-util-sanitize\n","readmeFilename":"readme.md"}