2.0.2 • Published 13 days ago

rehype-image-caption v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
13 days 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
2.0.2

13 days ago

2.0.1

20 days ago

2.0.0

1 month ago

1.1.0

1 month ago

1.0.0

1 month ago