Skip to main content

md-transformer

pipeline coverage

md-transformer is a powerful tool for dynamic documentation. It allows you to execute code cells, save snippets to files, and include live Python source code directly into your Markdown documents.

It works seamlessly with MkDocs, Zensical, or as a standalone CLI tool.

Documentation: https://md-transformer.readthedocs.io/

Core Features

  • 🚀 Live Execution: Run shell commands and include their output in your docs.
  • 💾 Snippet Management: Write code in Markdown and automatically save it to files.
  • 🐍 Python Integration: Include the source code of any importable Python object.
  • 🔧 Extensible: Create your own Markdown transformers using a simple Python API.
  • 📦 Multi-Tool Support: Use it as an MkDocs plugin, a Zensical extension, or via the CLI.

Quick Start

1. Save and Execute Python Code

Use the python-code fence to save code to a file, and bash-execute to run it and show the output.

```python-code hello.py
print("Hello from md-transformer!")
```

```bash-execute
$ python hello.py
```

Result:

# hello.py

print("Hello from md-transformer!")
$ python hello.py
Hello from md-transformer!

2. Include Python Source

Include the source code of any function or class using include-python.

```include-python md_transformer.transformer.transform
```

Result:

def transform(fh_in, fh_out, transformers, max_line_length=100):
    with MarkdownRenderer(max_line_length=max_line_length) as renderer:
        text = expand_includes(fh_in.read())
        doc = mistletoe.Document(text)
        _transform(doc, list(transformers) + [FixLinebreak()])
        print(renderer.render(doc), file=fh_out)

Installation

pip install md-transformer

Documentation

For detailed information, please refer to our full documentation:

  • 📖 Usage Guide: Detailed integration instructions for MkDocs, Zensical, and the CLI.
  • 🛠️ Technical Details: Information on execution environments and object resolution.
  • 🧩 Custom Macros: How to extend the tool with your own macros.
  • 🔌 API Reference: Full API documentation for developers.

License

This project is licensed under the MIT License.

Metadata

Release files for md-transformer 0.1.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 md-transformer 0.1.0
File Size Uploaded
md_transformer-0.1.0.tar.gz 41.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for md-transformer 0.1.0
File Interpreter ABI Platform
md_transformer-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 50.2 kB

Release files / md_transformer-0.1.0.tar.gz

Download URL md_transformer-0.1.0.tar.gz
Size 41.5 kB
Tags Source
SHA-256 checksum
How to use checksums
eb5d23c17d12f8203418f67d57d762adc8367e8d979413d496d075d7f581329c
BLAKE2b-256 checksum
How to use checksums
4dd708e817fd6dd5c1e2160d78ce8a509737fc8e5c99a149883f9c01f982b94e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.11

Release files / md_transformer-0.1.0-py3-none-any.whl

Download URL md_transformer-0.1.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4517b44a37fc23f970c767b134e70ed1f2a0578d770b9ca16a10079a22dbeb4e
BLAKE2b-256 checksum
How to use checksums
9769f8da6a11b4d0a17ac13c5476f31a77972e066142232ce58269f1531214ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.11

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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