{"_id":"@bradleyburgess/img-figcaptions","_rev":"3-384862113351a9751ba79d298338807b","name":"@bradleyburgess/img-figcaptions","dist-tags":{"latest":"1.1.2"},"versions":{"1.0.0":{"name":"@bradleyburgess/img-figcaptions","version":"1.0.0","description":"Easily add captions to HTML images with `<figure>` and `<figcaption>`","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsc","lint":"eslint src __tests__","test":"jest","test:watch":"jest --watch"},"repository":{"type":"git","url":"git+https://github.com/bradleyburgess/img-figcaptions.git"},"keywords":["html","images","image captions","figure","figcaption","captions"],"author":{"name":"Bradley Burgess"},"license":"MIT","bugs":{"url":"https://github.com/bradleyburgess/img-figcaptions/issues"},"homepage":"https://github.com/bradleyburgess/img-figcaptions#readme","devDependencies":{"@types/jest":"^28.1.2","@typescript-eslint/eslint-plugin":"^5.28.0","@typescript-eslint/parser":"^5.28.0","codecov":"^3.8.3","eslint":"^8.17.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","jest":"^28.1.1","prettier":"^2.7.1","ts-jest":"^28.0.5","typescript":"^4.7.4"},"dependencies":{"cheerio":"^1.0.0-rc.11"},"gitHead":"1b1c2faf0751d0b0b4713d07411c87bca31e3a67","_id":"@bradleyburgess/img-figcaptions@1.0.0","_nodeVersion":"16.15.1","_npmVersion":"8.12.2","dist":{"integrity":"sha512-WzX1AF3Bdl+1fmNWMgvqIDUWqJAeF2mzsk4MaFkkQXP75rsQyMTo52kl1vR6ZK0O4mthGE6kJopBesNsVDZblg==","shasum":"2153011bf46dd592ddec49a6182e761312c171c9","tarball":"https://registry.npmjs.org/@bradleyburgess/img-figcaptions/-/img-figcaptions-1.0.0.tgz","fileCount":16,"unpackedSize":26735,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAafueCAR9JisKrobFhptEKI8jxIeRs+jbLRp9PjmcGfAiEAyaanRi02+0GISkkFzy5PjephuMTVdSoCh7QWn4HBUVk="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJishFLACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoD3Q/+LBGYsNER82l75hM9YuOQ5Q78ksM7N8ZTARjRiliYFX6lNaKt\r\nE0qOq83FhGAdqj93+2pEE2JYFdvv2lNyKaswZ02mr1C3xBTfyjUUqsSLWY2P\r\nHacmApI5ccZWhCGSRVxbDTEtwP24lC94f2MgsHhhHGSn2V2xe9ss5y5SSZO1\r\nidZXqA9U3sBq08KDDAAMk7e0OMiHGJnLaxkWgqxRix96P1G5LzmNn3wo9eMX\r\nDcPGg0wIK67voodjmAOMPcwtc7VawxAGxOZw/eVpCv6ERoI+Ezts/mi0IA2h\r\nlZTDpo8sNOQepEDTJ7z4wwfGcKWVBcq8x7gbujy4E4cJJbGenKuFygqG2F76\r\n6z5DAIkDhuXFvcxhk4fh26r9gfcVOcMq+ODMjPevB6onY8riHIjfgSx1+y/G\r\n9f7ytMIWA6nN7VCRJGuuQCSAxjfpoDaGNl1ms/anNeeB5ic8KTvu1ObbU3yI\r\nEi2DGu/CtR/VkrpeAJrxSQIK+SXmi4/QQsPnPGvs63HBgbotM/MoJ7qpUUzr\r\ngkHZw/OvjR2qgDLUfKGDTf3kVJABvGQ9g7fWXHcbTgA3Y+pXL8G5zWUyjzIA\r\ns/sV/RZGAy03qLWxWotDRVoVwOv4JwFKi1EiKJetJ6A6y/VPatYPivbA1j3r\r\nX64lwyhXcGVn2xBU0JcuYM2meauId/Jf6EI=\r\n=+hxK\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"bradleyburgess","email":"bradleyburgess@gmail.com"},"directories":{},"maintainers":[{"name":"bradleyburgess","email":"bradleyburgess@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/img-figcaptions_1.0.0_1655837003338_0.7357902299959629"},"_hasShrinkwrap":false},"1.1.0":{"name":"@bradleyburgess/img-figcaptions","version":"1.1.0","description":"Easily add captions to HTML images with `<figure>` and `<figcaption>`","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsc","lint":"eslint src __tests__","test":"jest","test:watch":"jest --watch"},"repository":{"type":"git","url":"git+https://github.com/bradleyburgess/img-figcaptions.git"},"keywords":["html","images","image captions","figure","figcaption","captions"],"author":{"name":"Bradley Burgess"},"license":"MIT","bugs":{"url":"https://github.com/bradleyburgess/img-figcaptions/issues"},"homepage":"https://github.com/bradleyburgess/img-figcaptions#readme","devDependencies":{"@types/jest":"^28.1.2","@typescript-eslint/eslint-plugin":"^5.28.0","@typescript-eslint/parser":"^5.28.0","codecov":"^3.8.3","eslint":"^8.17.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","jest":"^28.1.1","prettier":"^2.7.1","ts-jest":"^28.0.5","typescript":"^4.7.4"},"dependencies":{"cheerio":"^1.0.0-rc.11"},"gitHead":"ed347c030bd83b38d69232fdb85ae72f30236231","_id":"@bradleyburgess/img-figcaptions@1.1.0","_nodeVersion":"16.15.1","_npmVersion":"8.13.0","dist":{"integrity":"sha512-pQp3aOmWEPhDAUMIgJi3V8UYwOlde6pKvvrbmfvjW0/8M0+mRzwW/TT2YrL8rOBW/tXrSe16geKqJqnpJDhkcA==","shasum":"e00bdb1f2bac1004b841b1f67133651d9d45bde1","tarball":"https://registry.npmjs.org/@bradleyburgess/img-figcaptions/-/img-figcaptions-1.1.0.tgz","fileCount":16,"unpackedSize":28385,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDu5IlFE2ds0rvgupnTEG8pY2eOfSKLC1kie5fIXHyZfgIhAPedI/Ef0I9HwCjZnpfkYj55lc6ENDfQUZbnODtxQsKv"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJitIv3ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqM6A/8DYBriD5ck1d9V1mUIXrNCuYay6aACDU2+x/JWOcwemHDD/mx\r\nO0TkKsIVHFIzVhPsiWI290a0UYliu7IXmY77KQxTJc56Uk1jdlqNZegUuMQ3\r\nDSeZlgIlejpU9dxqcxcdvJDbZqdL0zlx4P69dDaCunzQuHsVvYSnTT/t5xw/\r\n8E+Pm6QL7oVX4cQMgX9ikMr7p5rIQ7jxN73rje5gZcvXW14fN4d27zXJ26JI\r\n0BvuKJxjXtVoLYqN81qLauvZU/dgOjf3BHolSTx9BBO7Pd4zncDAJVkeORXA\r\nazXO2XWs7Iw0Hq0gJYyiJeooJjXfzGVE3fvjcsyIWnT3tcPz1A0lktEH1JWr\r\nvPHMPhhw++gP7LlzFt74jbF+rT4vckiiRcpe2S8S7fAVYTjbhOzomv1BUdpy\r\nLjKntGUEZK/5Fc9DSBOwFbVKgaQY7GOSdO+xfnAFdaiETEcTHCxHfW/GgJcl\r\nJ8H14tEcYOKUciF7qPXcnpEOr10Wiw5xbQ29FN8LF+BXN/rYsz3NNBhTi3Ix\r\n/LC/A2RHnaG9Bu3itkPeqYoOCwiCgOzwlRNHXMVQ3I0lCKMTl+A3Cs0p4wqT\r\ng64xznmQSjL/9QUL+bQnuRMksOAUYXNlhUKT1yeUHus0VrvlL/hYmcHr8lpN\r\nEBwELzsHw2XLPC61X9N+zbHxoe+uSNg2lw8=\r\n=DhBc\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"bradleyburgess","email":"bradleyburgess@gmail.com"},"directories":{},"maintainers":[{"name":"bradleyburgess","email":"bradleyburgess@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/img-figcaptions_1.1.0_1655999479467_0.10784506658806348"},"_hasShrinkwrap":false},"1.1.1":{"name":"@bradleyburgess/img-figcaptions","version":"1.1.1","description":"Easily add captions to HTML images with `<figure>` and `<figcaption>`","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsc","lint":"eslint src __tests__","test":"jest","test:watch":"jest --watch"},"repository":{"type":"git","url":"git+https://github.com/bradleyburgess/img-figcaptions.git"},"keywords":["html","images","image captions","figure","figcaption","captions"],"author":{"name":"Bradley Burgess"},"license":"MIT","bugs":{"url":"https://github.com/bradleyburgess/img-figcaptions/issues"},"homepage":"https://github.com/bradleyburgess/img-figcaptions#readme","devDependencies":{"@types/jest":"^28.1.2","@typescript-eslint/eslint-plugin":"^5.28.0","@typescript-eslint/parser":"^5.28.0","codecov":"^3.8.3","eslint":"^8.17.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","jest":"^28.1.1","prettier":"^2.7.1","ts-jest":"^28.0.5","typescript":"^4.7.4"},"dependencies":{"cheerio":"^1.0.0-rc.11"},"gitHead":"924b3443ebb757ede92099fca927599f63598706","_id":"@bradleyburgess/img-figcaptions@1.1.1","_nodeVersion":"16.15.1","_npmVersion":"8.13.0","dist":{"integrity":"sha512-VXVV1mibYhtumMwezoqine8+ao3Nhdo9efSCC7W6mxMDYYr5HAWhwkcKV4BkGS3/gYZF1I+Se0aAyMq/rIQ9XA==","shasum":"05f5b364321f44a212c09e5d9f768f848f1f1fdb","tarball":"https://registry.npmjs.org/@bradleyburgess/img-figcaptions/-/img-figcaptions-1.1.1.tgz","fileCount":16,"unpackedSize":28490,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB0PeScM9x2yZU6Ajullz7O82w6M1UDulvPZHDQYNbP7AiBUaf/SYGZvTzu6w6laxVZo3qy2Gz6tF4+Z7u4KmODeQw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJitfDcACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpT2A//QICWjyikCiqMwXrwTT5XCIiD09opj/dG14p5+6LBlemgQzI3\r\nPzbE/7MUM0xI5YwJvuVJyPEHbbwGkol/y55SfXLOvWnYZe5wvE4D6fAW0x0R\r\n8LEt4ihAjOfA+hLJLrcHgDVkqSeljlNB+u8rKLgoN7kGSPjifYqWXVMXluMe\r\ni4s6fe11StnCm/RzqtFbdgvFHPXl8Ig2l1xCPZEEpjPCo+t27lxlidafxj94\r\nfYp7CV3XO53E5BSMqxtr0cjY9oTeSnJOEO3/MOJAd4gmbw2CO/srdOQYBxB8\r\n0RzMH3gRQLQ/0TeB4fcXL87UISBCeZSszwk3pUfyuzc8CRt/d0aTMIxwNhqy\r\n/o/CTSHJkz7HxGVErjWH2UwHD0VWZKlEuBcT4+/NvJ6rRycvCm/u1HLMCXBh\r\nFOKC8cmEZqF8YMuQVBLuWIb7Aaae7R7ptyxJPgcl6E0RElT6j2GDCgPDdWz8\r\noWRifeXa/CSzmQ/QxbD49fhZI7kbdaorjO117c3ZNGwU88B9l0+cOy+Ojnyi\r\n0fMWeosdP73BAcfhfdwf+PDBs6BOO1x4hOS8r2XzYlMYinwArixx2BgY11RP\r\nynMrRk+wFyRHdv8/jCz2Ci/qDgwbmoF9/2Z5k/6+0JdV19X+QliXTkW4lvA9\r\nIRjh2dowzLoWicOl1dMDp4dwzumypTuEILY=\r\n=Xbwd\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"bradleyburgess","email":"bradleyburgess@gmail.com"},"directories":{},"maintainers":[{"name":"bradleyburgess","email":"bradleyburgess@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/img-figcaptions_1.1.1_1656090844341_0.05202086351468593"},"_hasShrinkwrap":false},"1.1.2":{"name":"@bradleyburgess/img-figcaptions","version":"1.1.2","description":"Easily add captions to HTML images with `<figure>` and `<figcaption>`","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsc","lint":"eslint src __tests__","test":"jest","test:watch":"jest --watch"},"repository":{"type":"git","url":"git+https://github.com/bradleyburgess/img-figcaptions.git"},"keywords":["html","images","image captions","figure","figcaption","captions"],"author":{"name":"Bradley Burgess"},"license":"MIT","bugs":{"url":"https://github.com/bradleyburgess/img-figcaptions/issues"},"homepage":"https://github.com/bradleyburgess/img-figcaptions#readme","devDependencies":{"@types/jest":"^28.1.2","@typescript-eslint/eslint-plugin":"^5.28.0","@typescript-eslint/parser":"^5.28.0","codecov":"^3.8.3","eslint":"^8.17.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","jest":"^28.1.1","prettier":"^2.7.1","ts-jest":"^28.0.5","typescript":"^4.7.4"},"dependencies":{"cheerio":"^1.0.0-rc.11"},"gitHead":"777693c7520f569d57eacbf45158cfccf41bcffa","_id":"@bradleyburgess/img-figcaptions@1.1.2","_nodeVersion":"16.15.1","_npmVersion":"8.13.0","dist":{"integrity":"sha512-Q2TmGvqmIf0ITeXckMf134DgsgX7h24q8tSkvGhNEq3SUVd/ageIFRx5l6K2XBGEelOMp3H5uyujDyREwPRcfQ==","shasum":"fd0c5f869b5ab255a68b416fcaa38ad97ff22172","tarball":"https://registry.npmjs.org/@bradleyburgess/img-figcaptions/-/img-figcaptions-1.1.2.tgz","fileCount":16,"unpackedSize":28839,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCeqczmQioCMBc9lpjI6GZeTV279afTzlp7dbWcXYikuQIgERpFFv514mm1sVUhgqDEF2bmX0nujDpWs1Mi3XdZY5E="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJitfG3ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmor/g/+I5gXF/Sm0gRLmXXQ9U9KCDHiY8g8FRKaN1wBvA4e/nebe+Vb\r\n1xn8g1l8PylxmCVIS1SePU/MV9R4kK3HEqCUDguTzFBiWgnZf3vxPDnLyNB0\r\nyb3+qX/iped19MsTYyHb/5Wqw3pGEK2qiwnXnvVhzYm7mM9/Tz26CpThjn+E\r\nvbGAATq7h0+0sBshhGBUsa3Z2/RWrkm2zscYhVvMtjEZlUM/SJ0wCO7aAOIi\r\niW31DDmtWCutOVk27D04cWb8QUBIyMlsQAT3Us5zNd3L0YDz88z21GCWQVH9\r\nexZsm3uTTljLyAI0cAlDW/2iBR37bUeEGoeCo0dweYNrSi7wiganKHfSvdnC\r\n1iQNJ74eV3aQoWzVIpVd/GjP7Oo6knfqHF2r9YUKgy6KCATtxzdiUjXu9lpd\r\n3tjeMRieXSxJtYRatEprd61vQvRdycLR9jysvibeKFhWWbV+0drUixd1JKsd\r\nMLmHhwsKIEFbabjNoJOt6AfBjJnClVw7TsbmiUtkbm0o24IpC//88jsx+fcK\r\n3eMTfLnx6GKzEBxY5nAqbI9xn6XzRmjGDdlAsry9sZ/7WvgpH36Q0fKI44VP\r\nrp/g6NXpBV/tQP9F7qSOKWOE2vWMmIjy+JdKz+oczhB6GIh7/t7v91SSfkkH\r\nNYv/OnW1P5tqVjTv+ogUXHDue/vldNWIvjI=\r\n=LZRY\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"bradleyburgess","email":"bradleyburgess@gmail.com"},"directories":{},"maintainers":[{"name":"bradleyburgess","email":"bradleyburgess@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/img-figcaptions_1.1.2_1656091063583_0.24830779465013197"},"_hasShrinkwrap":false}},"time":{"created":"2022-06-21T18:43:23.273Z","1.0.0":"2022-06-21T18:43:23.502Z","modified":"2022-06-24T17:17:43.857Z","1.1.0":"2022-06-23T15:51:19.684Z","1.1.1":"2022-06-24T17:14:04.545Z","1.1.2":"2022-06-24T17:17:43.782Z"},"maintainers":[{"name":"bradleyburgess","email":"bradleyburgess@gmail.com"}],"description":"Easily add captions to HTML images with `<figure>` and `<figcaption>`","homepage":"https://github.com/bradleyburgess/img-figcaptions#readme","keywords":["html","images","image captions","figure","figcaption","captions"],"repository":{"type":"git","url":"git+https://github.com/bradleyburgess/img-figcaptions.git"},"author":{"name":"Bradley Burgess"},"bugs":{"url":"https://github.com/bradleyburgess/img-figcaptions/issues"},"license":"MIT","readme":"# `img-figcaptions`\n\n[![npm](https://img.shields.io/npm/v/@bradleyburgess/img-figcaptions?style=for-the-badge)](https://www.npmjs.com/package/@bradleyburgess/img-figcaptions)\n![License: MIT](https://img.shields.io/github/license/bradleyburgess/img-figcaptions?color=yellow&style=for-the-badge)\n![Codecov](https://img.shields.io/codecov/c/github/bradleyburgess/img-figcaptions?style=for-the-badge)\n\n## Table of contents\n\n- [Overview](#overview)\n- [Features](#features)\n- [Motivation](#motivation)\n- [Installation and use](#installation-and-use)\n  - [Options](#options)\n- [Examples of input / output](#examples-of-input--output)\n  - [Using title attribute](#using-title-attribute)\n  - [Neighboring text node](#neighboring-text-node)\n  - [Neighboring paragraph](#neighboring-paragraph)\n  - [Neighboring paragraph with nested image](#neighboring-paragraph-with-nested-image)\n  - [Markdown examples](#markdown-examples)\n- [Issues / Roadmap](#issues--roadmap)\n- [Contributing](#contributing)\n\n## Overview\n\nEasily add user-friendly captions to HTML images with `<figure>` and\n`<figcaption>`, using user-friendly \"Caption: \" blocks.\n\nThis module is intended to be used in a Node.js environment, e.g. in a static\nsite generator pipeline or workflow. It takes an HTML string and parses\nplain-text captions into semantic elements. HTML comes in, and HTML goes out.\nSimple.\n\n## Features\n\n- captions can be easily be indicated in 4 potential places (in decreasing order\n  of priority):\n  1. `title` attribute on the image\n  2. The next text node after the image\n  3. The next `<p>` element after the image\n  4. If the `<img>` is in a paragraph, the parent's next sibling `<p>`\n- works with `<img>` as well as `<picture>` images\n- works with images wrapped in `<a>` tags\n- case-insensitive:\n  - `Caption: `\n  - `caption: `\n  - `CAPTION: `\n\n## Motivation\n\nWhen working with a CMS or writing markdown, it can be tricky for non-technical\ncontent creators / editors to indicate captions for images. There do exist\nplugins and packages that will transform `title` attributes into captions, but\nit can be hard for non-technical writers to get that markdown syntax right\neverytime. This can result in broken or mis-rendered content, which no one\nwants.\n\nThis module allows easy creation of captions by adding a `title` attribute to\nthe image, or by indicating caption text next to or below the image itself with\n\"Caption: …\"\n\nFor instance, you could write this in markdown:\n\n```markdown\n![alt text](example.jpg)\n\nCaption: An example caption\n\nI took this picture on my trip to South Africa, when I had the opportunity to\nclimb Table Mountain. (Rest of flow content ...)\n```\n\n… parse that markdown with e.g. `markdown-it`, and this module would then give\nyou:\n\n```html\n<figure>\n  <img src=\"example.jpg\" alt=\"alt text\" />\n  <figcaption>An example caption</figcaption>\n</figure>\n<p>\n  I took this picture on my trip to South Africa, when I had the opportunity to climb Table\n  Mountain. (Rest of flow content ...)\n</p>\n```\n\nMarkdown is possibly the most common source for content coming to a SSG, but I\ndidn't want to make any assumptions about where the content was coming from, and\ntherefore what shape the HTML would be. That is why I decided to design this\nmodule to make transformations on raw `html`, and not make e.g. a `markdown-it`\nextension, which would limit the functionality to parsing markdown only.\nDifferent CMS work differently, and this allows the most flexibility.\n\n## Installation and use\n\nTo install:\n\n```bash\n# using NPM:\nnpm install @bradleyburgess/img-figcaptions\n\n# using yarn:\nyarn add @bradleyburgess/img-figcaptions\n```\n\nTo use in your project, import the module, and pass the function the HTML string\nyou want to transform. You can optionally supply an options object, shown here\nwith the defaults:\n\n```js\nconst imgFigcaptions = require(\"@bradleyburgess/img-figcaptions\");\nconst content = getHtmlContentFromSomewhere; // html string\n\nconst options = { \n  addFigureToAllImgs: true,\n  removeTitle: false,\n  replaceEmptyParagraph: true,\n};\n\nconst output = imgFigcaptions(content, options); // transformed html string\n```\n\n### Options\n\n`addFigureToAllImgs` will wrap all images (`<picture>` if appropriate) in\n`<figure>` tags, regardless of whether there is a caption or not. **The default\nis true.**\n\n`replaceEmptyParagraph` will remove a parent `<p>` if the only child is the\nresulting `<figure>` element containing the image and caption. **The default is\ntrue**.\n\n`removeTitle` set to `true` will strip the `title` attribute from an image if\nthe caption comes from that attribute. **The default is false**.\n\n## Examples of input / output\n\n### Using title attribute\n\n```html\n<!-- input: -->\n<img src=\"example.jpg\" title=\"I have a caption\" />\n\n<!-- output: -->\n<!-- You can also retain the title, which is the default behavior -->\n<figure>\n  <img src=\"example.jpg\" />\n  <figcaption>I have a caption</figcaption>\n</figure>\n```\n\n### Neighboring text node\n\n```html\n<!-- input: -->\n<div>\n  <img src=\"example1.jpg\" />caption: I have a caption\n  <img src=\"example2.jpg\" />\n  CAPTION: I also have a caption\n</div>\n\n<!-- output: -->\n<div>\n  <figure>\n    <img src=\"example1.jpg\" />\n    <figcaption>I have a caption</figcaption>\n  </figure>\n  <figure>\n    <img src=\"example2.jpg\" />\n    <figcaption>I also have a caption</figcaption>\n  </figure>\n</div>\n```\n\n### Neighboring paragraph\n\n```html\n<!-- input: -->\n<img src=\"puppy.jpg\" />\n<p>Caption: What a cute puppy!</p>\n\n<!-- output: -->\n<figure>\n  <img src=\"puppy.jpg\" />\n  <figcaption>What a cute puppy!</figcaption>\n</figure>\n```\n\n### Neighboring paragraph, with nested image\n\n```html\n<!-- input: \n     This is a typical example that would come from parsing markdown -->\n<p>\n  <img src=\"puppy.jpg\" />\n</p>\n<p>Caption: What a cute puppy!</p>\n\n<!-- output: -->\n<!-- Note: you can leave the image parent <p> tag if you want,\n     which is the default behavior -->\n<figure>\n  <img src=\"puppy.jpg\" />\n  <figcaption>What a cute puppy!</figcaption>\n</figure>\n```\n\n### Picture tag example\n\nThe module treats `<img>` and `<picture>` tags almost interchangeably. Meaning,\nif the parent of an `<img>` is a `<picture>`, the module will wrap the parent\n`<picture>` instead of the actual `<img>`. The functionality is the same for\nboth, and the same options apply in terms of where the caption can be indicated.\n\nInput:\n\n```html\n<picture>\n  <source ...>\n  <img src=\"example.jpg\" />\n</picture>\n<p>Caption: This is my caption</p>\n```\n\nOutput:\n\n```html\n<figure>\n  <picture>\n    <source ...>\n    <img src=\"example.jpg\" />\n  </picture>\n  <figcaption>This is my caption</figcaption>\n</figure>\n```\n\n### Markdown example\n\nInput:\n\n```markdown\n<!-- any of these inputs will work, and have the same result: -->\n\n<!-- same line -->\n\n![alt text](image.jpg) Caption: My fancy caption\n\n<!-- or on the next line: -->\n\n![alt text](image.jpg)\nCaption: My fancy caption\n\n<!-- or with a line in between: -->\n\n![alt text](image.jpg)\n\nCaption: My fancy caption\n```\n\nResult:\n\n```html\n<figure>\n  <img src=\"image.jpg\" alt=\"alt text\" />\n  <figcaption>My fancy caption</figcaption>\n</figure>\n```\n\n## Issues / Roadmap\n\nThere are two current main limitations:\n\n1\\. `<br />` elements are not ignored, and therefore will often return \"false\"\nnegatives that don't transform captions. Ideally, when searching for the next\nsibling text node, break tags will be removed if the text node following the\nbreak tag has the caption. This will be implemented at a future time.\n\n2\\. The resulting HTML can be a bit untidy. The one assumption I've made is that\nthis will be part of a pipeline, where HTML will ultimately be cleaned up and/or\nminified (using `prettier` or `html-minifier` e.g.). So little attempt has been\nmade to tidy the HTML. One exception is the removal of whitespace before an\nelement that is removed, so as to not have unnecessary empty lines.\n\n- [x] Get caption from title attribute\n- [x] Get caption from next text node\n- [x] Get caption from next paragraph tag\n- [x] Get caption from next paragraph tag, if image is nested in a paragraph\n- [x] Works with `<picture>` tags\n- [x] Works if the image is wrapped in an `<a>` tag.\n- [ ] Works if `<br />` tags are in the next text node.\n\n## Contributing\n\nPlease feel free to file an issue or a pull request!\n","readmeFilename":"README.md"}