https://github.com/robot-inventor/rehype-image-caption
rehype plugin to set captions for images in addition to alt text.
https://github.com/robot-inventor/rehype-image-caption
rehype rehype-plugin remark unified unifiedjs
Last synced: 3 months ago
JSON representation
rehype plugin to set captions for images in addition to alt text.
- Host: GitHub
- URL: https://github.com/robot-inventor/rehype-image-caption
- Owner: Robot-Inventor
- License: mit
- Created: 2024-03-17T17:44:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-08T19:29:00.000Z (3 months ago)
- Last Synced: 2025-08-08T21:25:52.021Z (3 months ago)
- Topics: rehype, rehype-plugin, remark, unified, unifiedjs
- Language: TypeScript
- Homepage:
- Size: 551 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# rehype-image-caption
rehype plugin to set captions for images in addition to alt text.
## Installation
```sh
npm install rehype-image-caption
```
## Example
```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 = `

*caption text*

*caption text*
`;
processor.process(markdown).then((result) => {
console.log(result.toString());
});
```
The above code will output the following:
```html

caption text
caption text
```
## Options
### `wrapImagesWithoutCaptions`
- Type: `boolean`
- Default: `true`
Wrap images without captions in a `` tag. If set to `false`, images without captions will not be wrapped in a `` tag.
## Development
### Build
```sh
npm run build
```
### Format
```sh
npm run format
```
or
```sh
npm run format:check
```
### Lint
```sh
npm run lint
```
### Test
```sh
npm run test
```
### Pull Requests
This repository uses [Changesets](https://github.com/changesets/changesets) to manage versioning and releases. When creating a pull request, please run the Changesets CLI and commit the changeset file.
```bash
npx changeset
```