pymd-gadgets
Small Python-Markdown extensions that make Markdown more pleasant to write. They work anywhere Python-Markdown is used, including MkDocs and Material for MkDocs.
compact_lists: start a list right after a line of text, without a blank line in between.yamltable: write tables as YAML instead of hand-aligning pipes.
Installation
pip install pymd-gadgets
Requires Python 3.10+. Installs Markdown and PyYAML as dependencies.
Usage
MkDocs
# mkdocs.yml
markdown_extensions:
- tables # needed by yamltable
- compact_lists
- yamltable
The full module paths pymd_gadgets.compact_lists and
pymd_gadgets.yamltable work as well.
Python
import markdown
html = markdown.markdown(
text,
extensions=["tables", "compact_lists", "yamltable"],
)
You can also pass extension instances:
from pymd_gadgets import CompactListsExtension, YamlTableExtension
markdown.markdown(text, extensions=["tables", CompactListsExtension(), YamlTableExtension()])
compact_lists
Python-Markdown needs a blank line between a paragraph and a list.
Pros:
- Fast
- Simple
By default, this renders as a single paragraph: Pros: - Fast - Simple.
With compact_lists enabled, it renders as expected:
<p>Pros:</p>
<ul>
<li>Fast</li>
<li>Simple</li>
</ul>
It follows the CommonMark rules for lists that may interrupt a paragraph:
-,*and+bullet lists and ordered lists starting at1.or1)are recognized. A line such as2024. was a good yearstays paragraph text.- Multi-line items, nested lists and lazy continuation lines stay part of the same list, so the list stays tight.
- Content inside fenced code blocks (
```or~~~) is left alone.
yamltable
Add a #| yamltable line to a fenced yaml block (usually the first line).
It is replaced with a Markdown table.
The tables extension must be enabled to render the result.
The data can be written row by row under rows:
```yaml
#| yamltable
header:
tool:
name: Tool
align: right
use: Purpose
rows:
- tool: "[MkDocs](https://www.mkdocs.org/)"
use: Static site generator
license: BSD-2-Clause
- tool: "`pymd-gadgets`"
use: Markdown extensions
license: MIT
```
or column by column under columns:
```yaml
#| yamltable
header:
tool:
name: Tool
align: right
use: Purpose
columns:
tool:
- "[MkDocs](https://www.mkdocs.org/)"
- "`pymd-gadgets`"
use:
- Static site generator
- Markdown extensions
license:
- BSD-2-Clause
- MIT
```
Both render as:
| Tool | Purpose | license |
|---|---|---|
| MkDocs | Static site generator | BSD-2-Clause |
pymd-gadgets |
Markdown extensions | MIT |
headeris optional. It maps column keys to a display name, or to a mapping withnameandalign(left,centerorright). Configured columns come first; other keys found in the data follow in order of appearance.- Use either
rowsorcolumnsper block, not both. In column-first data, shorter columns are padded with empty cells.
Blocks without the marker are rendered as ordinary YAML code blocks.
Development
uv sync
uv run pytest
Tests are driven by fixture files in tests/fixtures/, each with an
--- input --- and an --- expected --- section.
License
Release files for pymd-gadgets 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pymd_gadgets-0.2.0.tar.gz | 7.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pymd_gadgets-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.9 kB
Release files / pymd_gadgets-0.2.0.tar.gz
| Download URL | pymd_gadgets-0.2.0.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d43f2f3ea11f0e6dda7fcfe56de22ecec35b4a2fbcf32266631be4eccdd77103
|
|
BLAKE2b-256 checksum How to use checksums |
2d03433dd2f6e597139cb67f08850e612330fe3767c1c3fe65cd91b634bf0ab6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.11
|
Release files / pymd_gadgets-0.2.0-py3-none-any.whl
| Download URL | pymd_gadgets-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f63fe59156ef791837c9356db875005c4bb0155c2ada469a786b74562129fac7
|
|
BLAKE2b-256 checksum How to use checksums |
2895c1a439382774154026a955d7ba74f1c200aaaf12817a5f1f9f9ae1fb9d21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.11
|