{"_id":"rehype-unwrap-images","_rev":"1-219e42a732c71c973f6f9c5421ba39ac","name":"rehype-unwrap-images","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"rehype-unwrap-images","version":"1.0.0","keywords":["hast","html","image","plugin","rehype-plugin","rehype","unified","unwrap"],"author":{"url":"https://wooorm.com","name":"Titus Wormer","email":"tituswormer@gmail.com"},"license":"MIT","_id":"rehype-unwrap-images@1.0.0","maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"contributors":[{"url":"https://wooorm.com","name":"Titus Wormer","email":"tituswormer@gmail.com"}],"homepage":"https://github.com/rehypejs/rehype-unwrap-images#readme","bugs":{"url":"https://github.com/rehypejs/rehype-unwrap-images/issues"},"xo":{"prettier":true},"dist":{"shasum":"7e6ae5bddffdf7ad439cc2e4ca1820e85a031a79","tarball":"https://registry.npmjs.org/rehype-unwrap-images/-/rehype-unwrap-images-1.0.0.tgz","fileCount":9,"integrity":"sha512-wzW5Mk9IlVF2UwXC5NtIZsx1aHYbV8+bLWjJnlZaaamz5QU52RppWtq1uEZJqGo8d9Y4RuDqidB6r9RFpKugIg==","signatures":[{"sig":"MEQCIH7iNZN4/gHo7veNxk7Y2QatKF9J9eq7yqjjlrnDcfrcAiABUTzYSvVROdQ91eyKqbUJ/3DQyrDMertiCi0omRTKxw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11886},"type":"module","types":"./index.d.ts","exports":"./index.js","funding":{"url":"https://opencollective.com/unified","type":"opencollective"},"gitHead":"bbea37ff890a6dab6d7bd2ea85ee70aadb614bcd","scripts":{"test":"npm run build && npm run format && npm run test-coverage","build":"tsc --build --clean && tsc --build && type-coverage","format":"remark . --frail --output --quiet && prettier . --log-level warn --write && xo --fix","prepack":"npm run build && npm run format","test-api":"node --conditions development test.js","test-coverage":"c8 --100 --reporter lcov npm run test-api"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"prettier":{"semi":false,"useTabs":false,"tabWidth":2,"singleQuote":true,"trailingComma":"none","bracketSpacing":false},"repository":{"url":"git+https://github.com/rehypejs/rehype-unwrap-images.git","type":"git"},"_npmVersion":"10.9.0","description":"rehype plugin to remove the wrapping paragraph (`<p>`) for images (`<img>`)","directories":{},"sideEffects":false,"_nodeVersion":"22.7.0","dependencies":{"@types/hast":"^3.0.0","unist-util-visit":"^5.0.0","hast-util-whitespace":"^3.0.0","hast-util-interactive":"^3.0.0"},"remarkConfig":{"plugins":["remark-preset-wooorm"]},"typeCoverage":{"detail":true,"strict":true,"atLeast":100,"ignoreCatch":true},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","xo":"^0.59.0","unified":"^11.0.0","prettier":"^3.0.0","remark-cli":"^12.0.0","typescript":"^5.0.0","@types/node":"^22.0.0","rehype-parse":"^9.0.0","remark-parse":"^11.0.0","remark-rehype":"^11.0.0","type-coverage":"^2.0.0","rehype-stringify":"^10.0.0","remark-preset-wooorm":"^10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/rehype-unwrap-images_1.0.0_1728648722661_0.20099083755479508","host":"s3://npm-registry-packages"}}},"time":{"created":"2024-10-11T12:12:02.660Z","modified":"2024-10-12T08:46:02.349Z","1.0.0":"2024-10-11T12:12:02.855Z"},"bugs":{"url":"https://github.com/rehypejs/rehype-unwrap-images/issues"},"author":{"url":"https://wooorm.com","name":"Titus Wormer","email":"tituswormer@gmail.com"},"license":"MIT","homepage":"https://github.com/rehypejs/rehype-unwrap-images#readme","keywords":["hast","html","image","plugin","rehype-plugin","rehype","unified","unwrap"],"repository":{"url":"git+https://github.com/rehypejs/rehype-unwrap-images.git","type":"git"},"description":"rehype plugin to remove the wrapping paragraph (`<p>`) for images (`<img>`)","contributors":[{"url":"https://wooorm.com","name":"Titus Wormer","email":"tituswormer@gmail.com"}],"maintainers":[{"email":"remcohaszing@gmail.com","name":"remcohaszing"},{"email":"tituswormer@gmail.com","name":"wooorm"},{"email":"keith@mcknig.ht","name":"kmck"}],"readme":"# rehype-unwrap-images\n\n[![Build][badge-build-image]][badge-build-url]\n[![Coverage][badge-coverage-image]][badge-coverage-url]\n[![Downloads][badge-downloads-image]][badge-downloads-url]\n[![Size][badge-size-image]][badge-size-url]\n[![Sponsors][badge-sponsors-image]][badge-collective-url]\n[![Backers][badge-backers-image]][badge-collective-url]\n[![Chat][badge-chat-image]][badge-chat-url]\n\n**[rehype][github-rehype]** plugin to remove the wrapping paragraph (`<p>`) for\nimages (`<img>`).\n\n## Contents\n\n* [What is this?](#what-is-this)\n* [When should I use this?](#when-should-i-use-this)\n* [Install](#install)\n* [Use](#use)\n* [API](#api)\n* [Types](#types)\n* [Compatibility](#compatibility)\n* [Security](#security)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis package is a [unified][github-unified]\n([rehype][github-rehype])\nplugin that searches for paragraphs which contain only images\n(possibly in links)\nand nothing else,\nand then removes those surrounding paragraphs.\n\n## When should I use this?\n\nWhen working with markdown,\nthis project can make it simpler to style images with CSS,\nfor example displaying them at the full available width,\nbecause paragraph styles no longer interfere with them.\n\n## Install\n\nThis package is [ESM only][github-gist-esm].\nIn Node.js (version 16+), install with [npm][npm-install]:\n\n```sh\nnpm install rehype-unwrap-images\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport rehypeUnwrapImages from 'https://esm.sh/rehype-unwrap-images@1'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import rehypeUnwrapImages from 'https://esm.sh/rehype-unwrap-images@1?bundle'\n</script>\n```\n\n## Use\n\nSay we have the following file `example.html`.\n\n```html\n<h1>Saturn</h1>\n<p>Saturn is the sixth planet from the Sun and the second-largest in the Solar\nSystem, after Jupiter.</p>\n<p><img alt=\"Saturn\" src=\"//upload.wikimedia.org/wikipedia/commons/thumb/c/c7/Saturn_during_Equinox.jpg/300px-Saturn_during_Equinox.jpg\"></p>\n```\n\n…and a module `example.js`:\n\n```js\nimport rehypeParse from 'rehype-parse'\nimport rehypeStringify from 'rehype-stringify'\nimport rehypeUnwrapImages from 'rehype-unwrap-images'\nimport {read} from 'to-vfile'\nimport {unified} from 'unified'\n\nconst file = await read('example.html')\n\nawait unified()\n  .use(rehypeParse, {fragment: true})\n  .use(rehypeUnwrapImages)\n  .use(rehypeStringify)\n  .process(file)\n\nconsole.log(String(file))\n```\n\n…then running `node example.js` yields:\n\n```html\n<h1>Saturn</h1>\n<p>Saturn is the sixth planet from the Sun and the second-largest in the Solar\nSystem, after Jupiter.</p>\n<img alt=\"Saturn\" src=\"//upload.wikimedia.org/wikipedia/commons/thumb/c/c7/Saturn_during_Equinox.jpg/300px-Saturn_during_Equinox.jpg\">\n```\n\n## API\n\nThis package exports no identifiers.\nThe default export is [`rehypeUnwrapImages`][api-rehype-unwrap-images].\n\n#### `unified().use(rehypeUnwrapImages)`\n\nRemove the wrapping paragraph for images.\n\n###### Parameters\n\nThere are no parameters.\n\n###### Returns\n\nTransform ([`Transformer`][github-unified-transformer]).\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports no additional types.\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `rehype-unwrap-images@1`,\ncompatible with Node.js 16.\n\nThis plugin works with `unified` version 6+ and `rehype` version 1+.\n\n## Security\n\nUse of `rehype-unwrap-images` does not change the tree other than sometimes\nremoving `<p>`.\nUse of this plugin does not open you up for a\n[cross-site scripting (XSS)][wiki-xss] attack.\nWhen in doubt,\nuse [`rehype-sanitize`][github-rehype-sanitize].\n\n## Contribute\n\nSee [`contributing.md`][health-contributing] in [`rehypejs/.github`][health]\nfor ways to get started.\nSee [`support.md`][health-support] for ways to get help.\n\nThis project has a [code of conduct][health-coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][file-license] © [Titus Wormer][wooorm]\n\n<!-- Definitions -->\n\n[api-rehype-unwrap-images]: #unifieduserehypeunwrapimages\n\n[badge-backers-image]: https://opencollective.com/unified/backers/badge.svg\n\n[badge-build-image]: https://github.com/rehypejs/rehype-unwrap-images/actions/workflows/main.yml/badge.svg\n\n[badge-build-url]: https://github.com/rehypejs/rehype-unwrap-images/actions\n\n[badge-collective-url]: https://opencollective.com/unified\n\n[badge-coverage-image]: https://img.shields.io/codecov/c/github/rehypejs/rehype-unwrap-images.svg\n\n[badge-coverage-url]: https://codecov.io/github/rehypejs/rehype-unwrap-images\n\n[badge-downloads-image]: https://img.shields.io/npm/dm/rehype-unwrap-images.svg\n\n[badge-downloads-url]: https://www.npmjs.com/package/rehype-unwrap-images\n\n[badge-size-image]: https://img.shields.io/bundlejs/size/rehype-unwrap-images\n\n[badge-size-url]: https://bundlejs.com/?q=rehype-unwrap-images\n\n[badge-sponsors-image]: https://opencollective.com/unified/sponsors/badge.svg\n\n[badge-chat-image]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[badge-chat-url]: https://github.com/rehypejs/rehype/discussions\n\n[esmsh]: https://esm.sh\n\n[file-license]: license\n\n[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[github-rehype]: https://github.com/rehypejs/rehype\n\n[github-rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize\n\n[github-unified]: https://github.com/unifiedjs/unified\n\n[github-unified-transformer]: https://github.com/unifiedjs/unified#transformer\n\n[health-coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md\n\n[health-contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md\n\n[health-support]: https://github.com/rehypejs/.github/blob/main/support.md\n\n[health]: https://github.com/rehypejs/.github\n\n[npm-install]: https://docs.npmjs.com/cli/install\n\n[typescript]: https://www.typescriptlang.org\n\n[wooorm]: https://wooorm.com\n\n[wiki-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n","readmeFilename":"readme.md"}