A markdown-it plugin to wrap images and captions in <figure> and <figcaption> tags.
npm install markdown-it-container-figureA markdown-it plugin that enables the use of and blocks in Markdown.
This plugin provides an alternative approach to markdown-it-figure, which uses a custom syntax like #Caption. Instead, it works with standard HTML or Markdown image tags inside a container block.
Supports the following formats inside :::figure blocks:
- wrapped image (with link)
- wrapped image
- tag alone
``bash`
npm install markdown-it-container-figure
or
`bash`
yarn add markdown-it-container-figure
`js
import MarkdownIt from "markdown-it";
import markdownItContainerFigure from "markdown-it-container-figure";
const md = new MarkdownIt();
md.use(markdownItContainerFigure);
`
Use a fenced block with :::figure to define a block.
`markdown`
:::figure
This is a caption for the image.
:::
Output:
`html`

`markdown`
:::figure
This is a caption for the image.
:::
Output:
`html`

`markdown`
:::figure
This is a caption for the image.
:::
Output:
`html``
