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: 7 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: 2024-10-28T13:47:01.000Z (8 months ago)
- Last Synced: 2024-10-31T09:16:14.081Z (8 months ago)
- Topics: rehype, rehype-plugin, remark, unified, unifiedjs
- Language: TypeScript
- Homepage:
- Size: 557 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
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```
## 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
```