Plugins Figures

pictures, video and diagrams cite and cross-reference @mdsvex/plugin-figures@0.1.1

Figures

Figures: a figure directive around an image or anything else, with its caption

Install

pnpm add -D @mdsvex/plugin-figures

Turn it on

import { figures } from '@mdsvex/plugin-figures';

mdsvex({ unwrap_images: true, plugins: [figures()] });

What it reads

:::figure[Caption]

owns figure

An example

You write
:::figure[The score of a heading](id=fig:score)

![A heading drawn as its score](/favicon.svg)

:::

You get
A heading drawn as its score
The score of a heading
Build-time preview.

:::figure puts what is written inside it, an image, a code block, a table or a diagram, in a <figure> with the bracket text as its <figcaption>. It is the one way to make a figure: a lone image stays an image, unwrapped by unwrap_images.

:::figure[Sales by month](id=fig:sales)

![A bar chart of sales by month](./chart.png)

:::

The id is optional and stays on the <figure>, as an id you wrote, so one a heading already has fails the build. With unwrap_images an image alone in the figure has no <p>. A figure has no number of its own: a numbering plugin gives it one through plugin data, and the caption then starts with "Figure 3", or is "Figure 3" alone when the figure has no caption. An empty figure warns (empty_figure). figures({ css: false }) leaves the stylesheet out, and a figure from a directives module replaces the plugin's component.

Options, from its types 1

css?: boolean
False leaves the default stylesheet out, the markup and its class names stay the same

Components @mdsvex/plugin-figures/Figure.svelte

Stylesheet @mdsvex/plugin-figures/figures.css, or figures({ css: false }) for none

Find another plugin · Write your own

mdsvex, markdown with Svelte in it. MIT licence.