
Security News
Next.js Patches Critical Middleware Vulnerability (CVE-2025-29927)
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
@microflash/rehype-figure
Advanced tools
rehype plugin to transform an image with alt text to a figure with caption
rehype plugin to transform an image with alt text to a figure with caption
[!IMPORTANT] Converting an image with alt text to a figure with caption is an escape hatch. Alt text, title, and captions have different intended purposes, and you should eventually enhance your content to adopt them.
This package is a unified (rehype) plugin that takes an image node with alt text (e.g., 
) and converts it to a figure element with caption.
<figure>
<img src="path-to-image.jpg" alt="Alt text">
<figcaption>Alt Text</figcaption>
</figure>
This package is ESM only.
In Node.js (16.0+), install with npm:
npm install @microflash/rehype-figure
For Node.js versions below 16.0, stick to 1.x.x versions of this plugin.
In Deno, with esm.sh:
import rehypeFigure from "https://esm.sh/@microflash/rehype-figure";
In browsers, with esm.sh:
<script type="module">
import rehypeFigure from "https://esm.sh/@microflash/rehype-figure?bundle";
</script>
Say we have the following module example.js
:
import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkGfm from "remark-gfm";
import remarkRehype from "remark-rehype";
import rehypeFigure from "@microflash/rehype-figure";
import rehypeStringify from "rehype-stringify";
main()
async function main() {
const file = await unified()
.use(remarkParse)
.use(remarkGfm)
.use(remarkRehype)
.use(rehypeFigure)
.use(rehypeStringify)
.process("");
console.log(String(file));
}
Running that with node example.js
yields:
<figure>
<img src="path-to-image.jpg" alt="Alt Text">
<figcaption>Alt Text</figcaption>
</figure>
The default export is rehypeFigure
.
The following options are available. All of them are optional.
className
: class for the wrapped figure
elementBy default, no classes are added to the figure
element.
[2.1.1] - 2024-09-07
ava
to vitest
, from Node.js 20 to 22FAQs
rehype plugin to transform an image with alt text to a figure with caption
The npm package @microflash/rehype-figure receives a total of 19,055 weekly downloads. As such, @microflash/rehype-figure popularity was classified as popular.
We found that @microflash/rehype-figure demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.