md2textbook 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- md2textbook-0.1.0/LICENSE +24 -0
- md2textbook-0.1.0/PKG-INFO +110 -0
- md2textbook-0.1.0/README.md +73 -0
- md2textbook-0.1.0/pyproject.toml +60 -0
- md2textbook-0.1.0/setup.cfg +4 -0
- md2textbook-0.1.0/src/md2textbook/__init__.py +4 -0
- md2textbook-0.1.0/src/md2textbook/__main__.py +5 -0
- md2textbook-0.1.0/src/md2textbook/builder.py +530 -0
- md2textbook-0.1.0/src/md2textbook/cli.py +179 -0
- md2textbook-0.1.0/src/md2textbook/fonts/Caladea-Bold.ttf +0 -0
- md2textbook-0.1.0/src/md2textbook/fonts/Caladea-BoldItalic.ttf +0 -0
- md2textbook-0.1.0/src/md2textbook/fonts/Caladea-Italic.ttf +0 -0
- md2textbook-0.1.0/src/md2textbook/fonts/Caladea-Regular.ttf +0 -0
- md2textbook-0.1.0/src/md2textbook/fonts/OFL-Caladea.txt +93 -0
- md2textbook-0.1.0/src/md2textbook/fonts/OFL-Poppins.txt +93 -0
- md2textbook-0.1.0/src/md2textbook/fonts/Poppins-Bold.ttf +0 -0
- md2textbook-0.1.0/src/md2textbook/fonts/Poppins-Light.ttf +0 -0
- md2textbook-0.1.0/src/md2textbook/fonts/Poppins-Medium.ttf +0 -0
- md2textbook-0.1.0/src/md2textbook/fonts/Poppins-Regular.ttf +0 -0
- md2textbook-0.1.0/src/md2textbook/fonts/Poppins-SemiBold.ttf +0 -0
- md2textbook-0.1.0/src/md2textbook/mathkit.py +99 -0
- md2textbook-0.1.0/src/md2textbook/parser.py +371 -0
- md2textbook-0.1.0/src/md2textbook/theme.py +241 -0
- md2textbook-0.1.0/src/md2textbook.egg-info/PKG-INFO +110 -0
- md2textbook-0.1.0/src/md2textbook.egg-info/SOURCES.txt +30 -0
- md2textbook-0.1.0/src/md2textbook.egg-info/dependency_links.txt +1 -0
- md2textbook-0.1.0/src/md2textbook.egg-info/entry_points.txt +5 -0
- md2textbook-0.1.0/src/md2textbook.egg-info/requires.txt +10 -0
- md2textbook-0.1.0/src/md2textbook.egg-info/top_level.txt +1 -0
- md2textbook-0.1.0/tests/test_convert.py +48 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mike Degany
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
The bundled Poppins and Caladea fonts are licensed separately under the SIL
|
|
24
|
+
Open Font License 1.1; see src/md2textbook/fonts/OFL-*.txt.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: md2textbook
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Convert Markdown into a coursebook-style PDF with colored boxes, equations and highlighted code, fully offline.
|
|
5
|
+
Author: Mike Degany
|
|
6
|
+
License-Expression: MIT AND OFL-1.1
|
|
7
|
+
Project-URL: Homepage, https://github.com/MikeDegany/md2textbook
|
|
8
|
+
Project-URL: Issues, https://github.com/MikeDegany/md2textbook/issues
|
|
9
|
+
Keywords: markdown,pdf,textbook,latex,converter,reportlab
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
21
|
+
Classifier: Topic :: Printing
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
License-File: src/md2textbook/fonts/OFL-Caladea.txt
|
|
26
|
+
License-File: src/md2textbook/fonts/OFL-Poppins.txt
|
|
27
|
+
Requires-Dist: reportlab>=4.0
|
|
28
|
+
Requires-Dist: matplotlib>=3.7
|
|
29
|
+
Requires-Dist: pygments>=2.15
|
|
30
|
+
Requires-Dist: pillow>=10.0
|
|
31
|
+
Requires-Dist: numpy>=1.24
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest; extra == "dev"
|
|
34
|
+
Requires-Dist: build; extra == "dev"
|
|
35
|
+
Requires-Dist: twine; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# md2textbook
|
|
39
|
+
|
|
40
|
+
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.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pipx install md2textbook # recommended: isolated, global command
|
|
46
|
+
# or
|
|
47
|
+
pip install md2textbook
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Requires Python 3.10 or newer. Poppins and Caladea fonts are bundled; nothing else to download.
|
|
51
|
+
|
|
52
|
+
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.
|
|
53
|
+
|
|
54
|
+
## Use
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
md2textbook # opens a file chooser
|
|
58
|
+
md2textbook notes.md # writes notes.pdf next to the input and opens it
|
|
59
|
+
md2textbook notes.md -o out/book.pdf --no-open
|
|
60
|
+
md2textbook-gui # same as no arguments, without a console window on Windows
|
|
61
|
+
python -m md2textbook notes.md
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
An example input is in [`examples/sample.md`](examples/sample.md).
|
|
65
|
+
|
|
66
|
+
## Markdown support
|
|
67
|
+
|
|
68
|
+
| Markdown | Result |
|
|
69
|
+
|---|---|
|
|
70
|
+
| Front matter `title`, `subtitle`, `author`, `date` | Cover page |
|
|
71
|
+
| A single `# Title`, then `##` / `###` / `####` | Title on the cover; chapters, sections, subsections |
|
|
72
|
+
| Several `#` headings | Each `#` is a chapter |
|
|
73
|
+
| `$x^2$` and `$$ ... $$` (or a `math` fence) | Inline math and numbered display equations |
|
|
74
|
+
| Fenced code, ` ```python title="Loss" ` | Highlighted listing with line numbers and wrapping |
|
|
75
|
+
| Pipe tables, optional `Table: caption` line | Zebra tables with a repeating header |
|
|
76
|
+
| `` | Numbered figure |
|
|
77
|
+
| `> [!DEFINITION] Title` | Colored box |
|
|
78
|
+
| `> **Example:** text` | Same, shorthand form |
|
|
79
|
+
| Plain `>` quote | Quiet unlabeled note |
|
|
80
|
+
|
|
81
|
+
Box kinds: `DEFINITION`, `EXAMPLE`, `INSIGHT`, `WARNING`, `RECAP`, `OBJECTIVE`, `CODE`, `IDEA`, `REVIEW`, `BRIEF`, `MATH`, `NOTE`, plus aliases such as `TIP`, `CAUTION`, `THEOREM`, `PROOF`, `SUMMARY`.
|
|
82
|
+
|
|
83
|
+
Code fence options: `title="..."`, `nonumbers`, `start=N`.
|
|
84
|
+
|
|
85
|
+
### Limitations
|
|
86
|
+
|
|
87
|
+
- Equations use matplotlib's mathtext, so some LaTeX (matrices, `\substack`, custom macros) is unsupported and shown as source text.
|
|
88
|
+
- Remote and SVG images are skipped.
|
|
89
|
+
- No Mermaid diagrams or footnotes.
|
|
90
|
+
|
|
91
|
+
## Development
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
git clone https://github.com/MikeDegany/md2textbook
|
|
95
|
+
cd md2textbook
|
|
96
|
+
pip install -e ".[dev]"
|
|
97
|
+
pytest
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
| Module | Role |
|
|
101
|
+
|---|---|
|
|
102
|
+
| `cli.py` | Command line, file chooser, opening the result |
|
|
103
|
+
| `parser.py` | Markdown parsing and mapping onto the book |
|
|
104
|
+
| `builder.py` | ReportLab book builder (pages, boxes, code, tables) |
|
|
105
|
+
| `theme.py` | Fonts, palette, paragraph styles, inline markup |
|
|
106
|
+
| `mathkit.py` | LaTeX to PNG rendering with an on-disk cache |
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
MIT, see [LICENSE](LICENSE). The bundled Poppins and Caladea fonts are under the SIL Open Font License 1.1 (`src/md2textbook/fonts/OFL-*.txt`).
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# md2textbook
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pipx install md2textbook # recommended: isolated, global command
|
|
9
|
+
# or
|
|
10
|
+
pip install md2textbook
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires Python 3.10 or newer. Poppins and Caladea fonts are bundled; nothing else to download.
|
|
14
|
+
|
|
15
|
+
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.
|
|
16
|
+
|
|
17
|
+
## Use
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
md2textbook # opens a file chooser
|
|
21
|
+
md2textbook notes.md # writes notes.pdf next to the input and opens it
|
|
22
|
+
md2textbook notes.md -o out/book.pdf --no-open
|
|
23
|
+
md2textbook-gui # same as no arguments, without a console window on Windows
|
|
24
|
+
python -m md2textbook notes.md
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
An example input is in [`examples/sample.md`](examples/sample.md).
|
|
28
|
+
|
|
29
|
+
## Markdown support
|
|
30
|
+
|
|
31
|
+
| Markdown | Result |
|
|
32
|
+
|---|---|
|
|
33
|
+
| Front matter `title`, `subtitle`, `author`, `date` | Cover page |
|
|
34
|
+
| A single `# Title`, then `##` / `###` / `####` | Title on the cover; chapters, sections, subsections |
|
|
35
|
+
| Several `#` headings | Each `#` is a chapter |
|
|
36
|
+
| `$x^2$` and `$$ ... $$` (or a `math` fence) | Inline math and numbered display equations |
|
|
37
|
+
| Fenced code, ` ```python title="Loss" ` | Highlighted listing with line numbers and wrapping |
|
|
38
|
+
| Pipe tables, optional `Table: caption` line | Zebra tables with a repeating header |
|
|
39
|
+
| `` | Numbered figure |
|
|
40
|
+
| `> [!DEFINITION] Title` | Colored box |
|
|
41
|
+
| `> **Example:** text` | Same, shorthand form |
|
|
42
|
+
| Plain `>` quote | Quiet unlabeled note |
|
|
43
|
+
|
|
44
|
+
Box kinds: `DEFINITION`, `EXAMPLE`, `INSIGHT`, `WARNING`, `RECAP`, `OBJECTIVE`, `CODE`, `IDEA`, `REVIEW`, `BRIEF`, `MATH`, `NOTE`, plus aliases such as `TIP`, `CAUTION`, `THEOREM`, `PROOF`, `SUMMARY`.
|
|
45
|
+
|
|
46
|
+
Code fence options: `title="..."`, `nonumbers`, `start=N`.
|
|
47
|
+
|
|
48
|
+
### Limitations
|
|
49
|
+
|
|
50
|
+
- Equations use matplotlib's mathtext, so some LaTeX (matrices, `\substack`, custom macros) is unsupported and shown as source text.
|
|
51
|
+
- Remote and SVG images are skipped.
|
|
52
|
+
- No Mermaid diagrams or footnotes.
|
|
53
|
+
|
|
54
|
+
## Development
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
git clone https://github.com/MikeDegany/md2textbook
|
|
58
|
+
cd md2textbook
|
|
59
|
+
pip install -e ".[dev]"
|
|
60
|
+
pytest
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
| Module | Role |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `cli.py` | Command line, file chooser, opening the result |
|
|
66
|
+
| `parser.py` | Markdown parsing and mapping onto the book |
|
|
67
|
+
| `builder.py` | ReportLab book builder (pages, boxes, code, tables) |
|
|
68
|
+
| `theme.py` | Fonts, palette, paragraph styles, inline markup |
|
|
69
|
+
| `mathkit.py` | LaTeX to PNG rendering with an on-disk cache |
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT, see [LICENSE](LICENSE). The bundled Poppins and Caladea fonts are under the SIL Open Font License 1.1 (`src/md2textbook/fonts/OFL-*.txt`).
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "md2textbook"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Convert Markdown into a coursebook-style PDF with colored boxes, equations and highlighted code, fully offline."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT AND OFL-1.1"
|
|
12
|
+
license-files = ["LICENSE", "src/md2textbook/fonts/OFL-*.txt"]
|
|
13
|
+
authors = [{ name = "Mike Degany" }]
|
|
14
|
+
keywords = ["markdown", "pdf", "textbook", "latex", "converter", "reportlab"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Environment :: Console",
|
|
18
|
+
"Intended Audience :: Education",
|
|
19
|
+
"Intended Audience :: Science/Research",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Topic :: Text Processing :: Markup :: Markdown",
|
|
27
|
+
"Topic :: Printing",
|
|
28
|
+
]
|
|
29
|
+
dependencies = [
|
|
30
|
+
"reportlab>=4.0",
|
|
31
|
+
"matplotlib>=3.7",
|
|
32
|
+
"pygments>=2.15",
|
|
33
|
+
"pillow>=10.0",
|
|
34
|
+
"numpy>=1.24",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
dev = ["pytest", "build", "twine"]
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
md2textbook = "md2textbook.cli:main"
|
|
42
|
+
|
|
43
|
+
[project.gui-scripts]
|
|
44
|
+
md2textbook-gui = "md2textbook.cli:main"
|
|
45
|
+
|
|
46
|
+
[project.urls]
|
|
47
|
+
Homepage = "https://github.com/MikeDegany/md2textbook"
|
|
48
|
+
Issues = "https://github.com/MikeDegany/md2textbook/issues"
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.dynamic]
|
|
51
|
+
version = { attr = "md2textbook.__version__" }
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.packages.find]
|
|
54
|
+
where = ["src"]
|
|
55
|
+
|
|
56
|
+
[tool.setuptools.package-data]
|
|
57
|
+
md2textbook = ["fonts/*.ttf", "fonts/*.txt"]
|
|
58
|
+
|
|
59
|
+
[tool.pytest.ini_options]
|
|
60
|
+
testpaths = ["tests"]
|