rehype plugin to set captions for images in addition to alt text.
npm install rehype-image-captionrehype plugin to set captions for images in addition to alt text.
``sh`
npm install rehype-image-caption
`javascript
import remarkParse from "remark-parse";
import rehypeStringify from "rehype-stringify";
import remarkRehype from "remark-rehype";
import { unified } from "unified";
import rehypeImageCaption from "rehype-image-caption";
const processor = unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeImageCaption)
.use(rehypeStringify);
const markdown =
!alt text
!alt textcaption text
!alt text
caption text;
processor.process(markdown).then((result) => {
console.log(result.toString());
});
`
The above code will output the following:
`html`



- Type: booleantrue
- Default:
Wrap images without captions in a tag. If set to false, images without captions will not be wrapped in a tag.
`sh`
npm run build
`sh`
npm run format
or
`sh`
npm run format:check
`sh`
npm run lint
`sh`
npm run test
This repository uses Changesets to manage versioning and releases. When creating a pull request, please run the Changesets CLI and commit the changeset file.
`bash``
npx changeset