diff options
| author | Dennis Fink | 2026-07-23 00:19:28 +0200 |
|---|---|---|
| committer | Dennis Fink | 2026-07-23 00:19:28 +0200 |
| commit | 2fc36e151300550b155fe37713429e365e8ec776 (patch) | |
| tree | 9eebd7f759227f301fb780a390cfd41f87b5ff15 /packages/markdown-figure/README.md | |
| parent | 1fe1d13c600b7dfe421b3b99b833b7d5d1232724 (diff) | |
| download | dennisfink.me-2fc36e151300550b155fe37713429e365e8ec776.tar.gz dennisfink.me-2fc36e151300550b155fe37713429e365e8ec776.zip | |
Add Markdown figure support
This adds a project-local Markdown figure plugin so blog posts can use
semantic `<figure>` blocks with arbitrary CSS classes, optional
captions, and Markdown inside captions.
The image CSS is also updated so figures share the existing width,
breakout, float, centering, and rounded-image utilities while keeping
captions styled and spaced consistently with the rest of the article
layout.
Diffstat (limited to '')
| -rw-r--r-- | packages/markdown-figure/README.md | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/packages/markdown-figure/README.md b/packages/markdown-figure/README.md new file mode 100644 index 0000000..a063f3c --- /dev/null +++ b/packages/markdown-figure/README.md @@ -0,0 +1,63 @@ +# Lektor Markdown Figure + +A project-local Lektor plugin providing semantic Markdown figures with: + +- any whitespace-separated CSS classes; +- an optional caption; +- Markdown parsing inside the caption; +- Lektor's normal attachment-relative image URL resolution. + +## Installation + +Place this directory at: + +```text +packages/markdown-figure/ +``` + +Restart `lektor server` after adding it. + +## Syntax + +```markdown +:::figure right w50 breakout-sm + + +A caption with *emphasis*, **strong text**, [links](https://example.com/), +and other Markdown. +::: +``` + +The first non-empty line must be the Markdown image. Everything after that is +the optional caption. + +Without a caption: + +```markdown +:::figure center w75 + +::: +``` + +This produces no `<figcaption>` element. + +## Output + +```html +<figure class="right w50 breakout-sm"> + <img src="example.jpg" alt="Alternative text" title="Optional image title"> + <figcaption> + <p>A caption with <em>emphasis</em>, …</p> + </figcaption> +</figure> +``` + +The class names are not allow-listed or transformed. They are copied to the +`class` attribute after HTML escaping and whitespace normalisation. + +## Notes + +- The opening marker is `:::figure`, followed by zero or more CSS classes. +- The closing marker is `:::` on its own line. +- Nested figure directives inside captions are intentionally not parsed. +- A matched figure block whose first content line is not an image fails with a clear `ValueError`. |
