Metadata-Version: 2.4
Name: md2textbook
Version: 0.1.0
Summary: Convert Markdown into a coursebook-style PDF with colored boxes, equations and highlighted code, fully offline.
Author: Mike Degany
License-Expression: MIT AND OFL-1.1
Project-URL: Homepage, https://github.com/MikeDegany/md2textbook
Project-URL: Issues, https://github.com/MikeDegany/md2textbook/issues
Keywords: markdown,pdf,textbook,latex,converter,reportlab
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Text Processing :: Markup :: Markdown
Classifier: Topic :: Printing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: src/md2textbook/fonts/OFL-Caladea.txt
License-File: src/md2textbook/fonts/OFL-Poppins.txt
Requires-Dist: reportlab>=4.0
Requires-Dist: matplotlib>=3.7
Requires-Dist: pygments>=2.15
Requires-Dist: pillow>=10.0
Requires-Dist: numpy>=1.24
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# 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.

## Install

```bash
pipx install md2textbook      # recommended: isolated, global command
# or
pip install md2textbook
```

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

```bash
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
```

An example input is in [`examples/sample.md`](examples/sample.md).

## Markdown support

| Markdown | Result |
|---|---|
| Front matter `title`, `subtitle`, `author`, `date` | Cover page |
| A single `# 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 |
| `![caption](img.png)` | 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

```bash
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 |

## License

MIT, see [LICENSE](LICENSE). The bundled Poppins and Caladea fonts are under the SIL Open Font License 1.1 (`src/md2textbook/fonts/OFL-*.txt`).
