Skip to main content

mdup

Tests PyPI version

mdup is a command-line tool for keeping markdown files up-to-date by injecting code, script or command output between special blocks. One immediate use case is keeping documentation up-to-date without having to manually update markdown files with info from code snippets, scripts or command outputs 1.

mdup does not depend on anything apart from Python stdlib.

Install

pip install mdup

or easier usage via uv:

uv tool run mdup

Usage

usage: mdup [-h] -i INPUT [-o OUTPUT] [-v]

options:
  -h, --help           show this help message and exit
  -i, --input INPUT    input markdown file
  -o, --output OUTPUT  output markdown file; if not specified, the input file
                       will be edited in place
  -v, --version        show program's version number and exit

mdup will replace the contents between each block with the command output (see details below). You can keep files up-to-date by simply rerunning mdup.

Omitting the -o option will edit the file in-place.

For example, the command-line usage block above is automatically generated by defining the following block in the README.md:

<!-- MDUP:BEG uv run mdup --help -->
<!-- MDUP:END -->

then running mdup -i README.md which executes uv run mdup --help and injects the output inside the block.

Block definition

The blocks are defined using HTML comments.

Begin

<!-- MDUP:BEG (command) (; pre) -->

Examples:

<!-- MDUP:BEG cat ./mdup.py ; py -->
<!-- MDUP:BEG ls -lh -->

If you want to add a markdown language tag (pre, like py in the first example), then it must follow the command, separated by a semicolon.

Paths are relative to the markdown file containing the blocks.

End

<!-- MDUP:END -->

The blocks must be defined as the sole contents of the line, i.e. matching ^ and $ anchors.

Examples

For examples, see tests.

One real-world use case is my Advent of Code README.md, in which I use mdup to automatically update year progress badges.

⚠️ Disclaimer

I created this tool primarily to meet my own needs -- it's very simple and ad-hoc. While I don't anticipate it gaining too much adoption, always beware when running mdup on markdown files of unknown origin (which can be malicious), e.g.:

<!-- MDUP:BEG rm -rf / -->
<!-- MDUP:END -->

This tool should only be used for simple tasks, e.g. keeping simple documentation up-to-date.

  1. Inspired by DavidWells/markdown-magic. ↩

Metadata

Release files for mdup 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mdup 0.3.0
File Size Uploaded
mdup-0.3.0.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mdup 0.3.0
File Interpreter ABI Platform
mdup-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / mdup-0.3.0.tar.gz

Download URL mdup-0.3.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f642d621c4903a16e7d362da59fc53c07341425c99e65e91e301e756173022b9
BLAKE2b-256 checksum
How to use checksums
aba1a2ac2121b80bd1e345dc1d64c51dc347d6c2a2a5ad227ae1d6f20a47b853
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release files / mdup-0.3.0-py3-none-any.whl

Download URL mdup-0.3.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dddf60731b421065302fed73323f0a168f08fa15303e4cfb605607ae7f03324a
BLAKE2b-256 checksum
How to use checksums
1300f7475c82ad778924dc68015fb43016fef54e14b0787314e72c1ed4af36e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.1

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page