2.0.14 • Published 4 months ago

rehype-image-caption v2.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

rehype-image-caption

rehype plugin to set captions for images in addition to alt text.

Installation

npm install rehype-image-caption

Example

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:

<figure>
    <img src="image.jpg" alt="alt text">
</figure>
<figure>
    <img src="image.jpg" alt="alt text">
    <figcaption>caption text</figcaption>
</figure>
<figure>
    <img src="image.jpg" alt="alt text">
    <figcaption>caption text</figcaption>
</figure>

Development

Build

npm run build

Format

npm run format

or

npm run format:check

Lint

npm run lint

Test

npm run test

Pull Requests

This repository uses Changesets to manage versioning and releases. When creating a pull request, please run the Changesets CLI and commit the changeset file.

npx changeset
2.0.13

6 months ago

2.0.14

4 months ago

2.0.11

8 months ago

2.0.12

7 months ago

2.0.7

11 months ago

2.0.9

10 months ago

2.0.10

10 months ago

2.0.8

10 months ago

2.0.3

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.6

11 months ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago