Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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

alt text

alt text
caption text

alt 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
```