Desktop publishing in YAML with Python
Project description
Desktop publishing with YAML
The technology of the year 2000…today!
YMPrint is a Python-based PDF authoring application geared towards professionals who need to generate lots of PDF documents. You write the content of your report in YAML (as opposed to Markdown) and YMPrint renders it to PDF with near-instant speeds. YMPrint lets you use Python scripting within your document, create variables, render variable values, and pass live Python objects between report blocks to create a truly expressive authoring system—the likes of which have not been created before.
Site inspection report:
- >
This is the first paragraph. The `>` character tells YAML you are entering a
multi-line string that should be word-wrapped. Leave a blank line to start a
new paragraph.
- Findings:
- Bullets:
- The handrail is loose on the north stair.
- Two ceiling tiles are water-stained in the lobby.
- Items observed:
- Item Number: 12.01
Description: There is a problem here. This report documents it.
Location: Under the stairs
ym convert report.yml
# ✍️ .... 📝 ... PDF created: report.pdf
Why YMPrint?
- Readable source. Your document is the outline. YAML nesting is the document hierarchy — no markup soup, no LaTeX, no HTML.
- Batteries included. Bundled fonts, sensible default styles, and a set of blocks for the content markdown can't express.
- Dynamic content. Interpolate variables with Jinja, execute
_pyblocks, load JSON, embed matplotlib figures, and auto-fill PDF form fields. - Custom templates. Overlay your document onto a designed PDF background and auto-populate its form fields from document variables.
Installation
Requires Python 3.14+.
# With uv (recommended) — installs the `ym` command
uv tool install ymprint
# Or with pip
pip install ymprint
From source:
git clone https://github.com/StructuralPython/yamlreports.git
cd yamlreports
uv sync
uv run ym --help
Usage
YMPrint installs a single command, ym, with two subcommands.
ym convert — render once
ym convert report.yml # writes report.pdf next to the source
ym convert report.yml out/doc.pdf # choose an output path
ym live — hot-reload preview
Renders the PDF, opens it in the Okular viewer, and rebuilds on every save. Great for drafting.
ym live report.yml
Core concepts
-
Keys are headings. A mapping key whose value is content becomes a heading; the value is laid out underneath it. Lists render in order, lists of mappings render as tables.
-
Configuration lives in underscore-prefixed front matter —
_doc(page template),_style(text styles), and_tablestyle(table styles) — resolved across three inheriting priority levels: internal defaults → project config → document front matter. -
Variables are defined in
_vars, interpolated into text with Jinja ({{name}}), and passed as real Python objects into blocks with the$namesyntax. -
Blocks are underscore-prefixed keys that expand into custom content:
Block Purpose _imgEmbed an image with a caption _matplotfigEmbed a matplotlib figure _info/_warning/_danger/_tip/_noteAdmonition callouts _blockquoteA quotation with attribution _codeA non-executable, syntax-highlighted code block _pyExecute Python and optionally show the source _loadjsonLoad variables from a JSON file _pagebreakForce a page break _hruleA configurable horizontal rule _spacerInsert vertical whitespace
Examples
The Examples/ directory contains a runnable report for each major feature —
a simple document, document configuration, variables, PDF backgrounds, Python execution,
and the full set of blocks. Render any of them with ym convert.
Documentation
The full documentation site lives in docs/ (Sphinx + the Shibuya theme). Build it
locally with:
uv run --with-requirements docs/requirements.txt \
sphinx-build -b html docs docs/_build/html
Then open docs/_build/html/index.html. See docs/README.md for details.
License
See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ymprint-0.1.0.tar.gz.
File metadata
- Download URL: ymprint-0.1.0.tar.gz
- Upload date:
- Size: 10.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Pop!_OS","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c35881432fdd124113492d3cb65feaf4e9a5d324f36717cb1e6f2c2a967875a
|
|
| MD5 |
195ddcbfd94acd0d6039d54363faa96d
|
|
| BLAKE2b-256 |
7ba166f1bb7e952a89b2f158b8747f547ce1e637fa72c03b5dfbb1c0a5c11032
|
File details
Details for the file ymprint-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ymprint-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Pop!_OS","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
470a3aa2fea1ea3dfc9fc68b7e5776b7feb7f521f6f7ab7444ad17d889ee1965
|
|
| MD5 |
69da74c7e12b60e208ba2edc2f2d259d
|
|
| BLAKE2b-256 |
246d581086709319339289c2fdb73d51ff812ce9899bec558a0189a27a314ea1
|