Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
Last synced: 24 days 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 (8 months ago)
- Default Branch: main
- Last Pushed: 2024-04-12T00:40:37.000Z (7 months ago)
- Last Synced: 2024-04-14T06:49:06.242Z (7 months ago)
- Language: TypeScript
- Size: 85.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
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 = `
![alt text](image.jpg)![alt text](image.jpg)*caption text*
![alt text](image.jpg)
*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
```