Skip to main content

Keep markdown files up-to-date.

Project description

mdup

Build

Keep markdown files up-to-date by injecting code or script output between special blocks.

There are no external dependencies, i.e. apart from Python stdlib.

Install

pip install mdup

How does it work?

The blocks are defined using HTML comments. Specifically, the begin block is of the form:

<!-- MDUP:BEG ({CMD}:{CONTENTS}) -->

where {CMD} can be either:

  • SRC: to just include the contents of {CONTENTS}
  • RUN: to execute the script from {CONTENTS} and inject its stdout in the block

NOTES

  • For SRC and RUN commands, the {CONTENTS} must be a path, relative to the md file.
  • The blocks must be defined as the sole contents of the line, i.e. matching ^ and $ anchors.

Usage

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

options:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        Input file.
  -o OUTPUT, --output OUTPUT
                        Output file. If not specified, it will edit in place.

Running mdup -i <input.md> -o <output.md> will replace the contents between each block with the appropriate action as defined above. This means that you can keep files up-to-date by simply rerunning mdup.

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

For example, the cmdline usage block above is automatically generated by defining:

<!-- MDUP:BEG (RUN:./scripts/help.sh) -->
<!-- MDUP:END -->

then running mdup -i README.md.

[^1]: Inspired by DavidWells/markdown-magic.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdup-0.1.1.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

mdup-0.1.1-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page