md2textbook
Turn a Markdown file into a coursebook-style PDF: gradient cover, table of contents, chapter banners, colored boxes, publication-quality equations and syntax-highlighted code. It runs fully offline on Windows, macOS and Linux, with no network access and no AI.
These pages come from examples/showcase.md; the resulting showcase.pdf is in the repo too.
Install
pipx install md2textbook # recommended: isolated, global command
# or
pip install md2textbook
New to terminals? Follow the step-by-step Windows guide.
Requires Python 3.10 or newer. Poppins and Caladea fonts are bundled; nothing else to download.
On Linux the file chooser needs Tk (sudo apt install python3-tk on Debian/Ubuntu, sudo dnf install python3-tkinter on Fedora). Without it the tool falls back to zenity/kdialog, or to a prompt in the terminal. Passing the file on the command line never needs any of these.
Use
md2textbook # opens a file chooser
md2textbook notes.md # writes notes.pdf next to the input and opens it
md2textbook notes.md -o out/book.pdf --no-open
md2textbook-gui # same as no arguments, without a console window on Windows
python -m md2textbook notes.md
Two example inputs are in examples/: a minimal sample.md and the feature tour showcase.md.
Markdown support
| Markdown | Result |
|---|---|
Front matter title, subtitle, author, date |
Cover page |
A first # Title (the only #, or equal to the front-matter title), then ## / ### / #### |
Title on the cover; chapters, sections, subsections |
Several # headings |
Each # is a chapter |
$x^2$ and $$ ... $$ (or a math fence) |
Inline math and numbered display equations |
Fenced code, ```python title="Loss" |
Highlighted listing with line numbers and wrapping |
Pipe tables, optional Table: caption line |
Zebra tables with a repeating header |
 |
Numbered figure |
> [!DEFINITION] Title |
Colored box |
> **Example:** text |
Same, shorthand form |
Plain > quote |
Quiet unlabeled note |
Box kinds: DEFINITION, EXAMPLE, INSIGHT, WARNING, RECAP, OBJECTIVE, CODE, IDEA, REVIEW, BRIEF, MATH, NOTE, plus aliases such as TIP, CAUTION, THEOREM, PROOF, SUMMARY.
Code fence options: title="...", nonumbers, start=N.
Limitations
- Equations use matplotlib's mathtext, so some LaTeX (matrices,
\substack, custom macros) is unsupported and shown as source text. - Remote and SVG images are skipped.
- No Mermaid diagrams or footnotes.
Development
git clone https://github.com/MikeDegany/md2textbook
cd md2textbook
pip install -e ".[dev]"
pytest
| Module | Role |
|---|---|
cli.py |
Command line, file chooser, opening the result |
parser.py |
Markdown parsing and mapping onto the book |
builder.py |
ReportLab book builder (pages, boxes, code, tables) |
theme.py |
Fonts, palette, paragraph styles, inline markup |
mathkit.py |
LaTeX to PNG rendering with an on-disk cache |
Contributing
Issues and pull requests are welcome; see CONTRIBUTING.md.
Changelog
See CHANGELOG.md.
License
MIT, see LICENSE. The bundled Poppins and Caladea fonts are under the SIL Open Font License 1.1 (src/md2textbook/fonts/OFL-*.txt).
Metadata
Release files for md2textbook 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| md2textbook-0.1.3.tar.gz | 1.8 MB | Without provenance | Details for md2textbook-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| md2textbook-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for md2textbook-0.1.3-py3-none-any.whl |
Total release size: 3.6 MB
Release files / md2textbook-0.1.3.tar.gz
| Download URL | md2textbook-0.1.3.tar.gz |
|---|---|
| Size | 1.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ea79dc4526100b8b058e8a49ae690ad8ec6be8c9ea19cc31398e9294b0c5fca
|
|
BLAKE2b-256 checksum How to use checksums |
e06461e87a9468f10cd61c34939654d0a39293de17cf525fb07f68850729fd82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / md2textbook-0.1.3-py3-none-any.whl
| Download URL | md2textbook-0.1.3-py3-none-any.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03774a2b12a18ab7dcdfe4ed8b35c75059f2a1a83f5eb0259ca3459770798552
|
|
BLAKE2b-256 checksum How to use checksums |
2cc2a9cefc477dcbe1a5f87c5530f5cf717cf6f9cb94f3d9d093de3a3532c6b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for md2textbook 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.