markdocx 1__tar.gz → 3.0.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.
- {markdocx-1 → markdocx-3.0.0}/.gitignore +12 -12
- {markdocx-1 → markdocx-3.0.0}/.python-version +1 -1
- {markdocx-1 → markdocx-3.0.0}/LICENSE +21 -21
- {markdocx-1 → markdocx-3.0.0}/PKG-INFO +109 -27
- {markdocx-1 → markdocx-3.0.0}/README.md +245 -164
- {markdocx-1 → markdocx-3.0.0}/main.py +12 -12
- {markdocx-1 → markdocx-3.0.0}/pyproject.toml +2 -1
- {markdocx-1 → markdocx-3.0.0}/requirements.txt +12 -11
- {markdocx-1 → markdocx-3.0.0}/rule/ai_gen_doc_rule.md +688 -477
- {markdocx-1 → markdocx-3.0.0}/rule/ai_gen_doc_rule_en.md +725 -476
- {markdocx-1 → markdocx-3.0.0}/src/markdocx/__init__.py +11 -11
- {markdocx-1 → markdocx-3.0.0}/src/markdocx/cli.py +116 -116
- {markdocx-1 → markdocx-3.0.0}/src/markdocx/code_renderer.py +164 -164
- {markdocx-1 → markdocx-3.0.0}/src/markdocx/core.py +130 -130
- markdocx-3.0.0/src/markdocx/diagram_renderer.py +884 -0
- {markdocx-1 → markdocx-3.0.0}/src/markdocx/docx_builder.py +749 -743
- {markdocx-1 → markdocx-3.0.0}/src/markdocx/math_renderer.py +476 -476
- {markdocx-1 → markdocx-3.0.0}/src/markdocx/md_parser.py +61 -61
- {markdocx-1 → markdocx-3.0.0}/src/markdocx/styles.py +248 -248
- {markdocx-1 → markdocx-3.0.0}/uv.lock +12 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# Python-generated files
|
|
2
|
-
__pycache__/
|
|
3
|
-
*.py[oc]
|
|
4
|
-
build/
|
|
5
|
-
dist/
|
|
6
|
-
wheels/
|
|
7
|
-
*.egg-info
|
|
8
|
-
|
|
9
|
-
# Virtual environments
|
|
10
|
-
.venv
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv
|
|
11
|
+
|
|
12
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
3.14
|
|
1
|
+
3.14
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 shynneri
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 shynneri
|
|
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.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: markdocx
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: Convert AI-generated Markdown textbooks to polished DOCX with native math equations and syntax-highlighted code
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -10,6 +10,7 @@ Requires-Dist: lxml==6.0.2
|
|
|
10
10
|
Requires-Dist: markdown-it-py==4.0.0
|
|
11
11
|
Requires-Dist: matplotlib==3.10.8
|
|
12
12
|
Requires-Dist: mdit-py-plugins==0.5.0
|
|
13
|
+
Requires-Dist: networkx>=3.6.1
|
|
13
14
|
Requires-Dist: pillow==12.1.0
|
|
14
15
|
Requires-Dist: pygments==2.19.2
|
|
15
16
|
Requires-Dist: python-docx==1.2.0
|
|
@@ -17,12 +18,13 @@ Description-Content-Type: text/markdown
|
|
|
17
18
|
|
|
18
19
|
<div align="center">
|
|
19
20
|
|
|
20
|
-
#
|
|
21
|
+
# markdocx
|
|
21
22
|
|
|
22
23
|
**A Markdown-to-Word converter built for AI-generated textbooks**
|
|
23
24
|
|
|
24
25
|
Convert Markdown files — complete with LaTeX math, syntax-highlighted code, tables, and images — into polished `.docx` documents in one command.
|
|
25
26
|
|
|
27
|
+
[](https://pypi.org/project/markdocx/)
|
|
26
28
|
[](https://www.python.org/downloads/)
|
|
27
29
|
[](LICENSE)
|
|
28
30
|
|
|
@@ -38,7 +40,7 @@ Large language models (ChatGPT, Claude, Gemini, …) produce great Markdown, but
|
|
|
38
40
|
- Code blocks lose their highlighting
|
|
39
41
|
- Tables, lists, and blockquotes need manual reformatting
|
|
40
42
|
|
|
41
|
-
**
|
|
43
|
+
**markdocx** bridges that gap. Feed it a Markdown file that follows a few simple rules and get a publication-ready `.docx` — math rendered as native Word OMML equations, code with VS Code–style colors, diagrams rendered as images, and everything else properly formatted.
|
|
42
44
|
|
|
43
45
|
## Features
|
|
44
46
|
|
|
@@ -48,6 +50,10 @@ Large language models (ChatGPT, Claude, Gemini, …) produce great Markdown, but
|
|
|
48
50
|
| **Code** | 30+ languages with Pygments syntax highlighting, VS Code light theme, language labels |
|
|
49
51
|
| **Tables** | Auto-formatted Table Grid — bold header row, left/center/right alignment, inline math in cells |
|
|
50
52
|
| **Lists** | Bullet (•◦▪) and numbered lists, up to 6 nesting levels |
|
|
53
|
+
| **Matrix** | `\`\`\`matrix` blocks → visual matrix diagrams with brackets, labels, and captions |
|
|
54
|
+
| **Charts** | `\`\`\`chart` blocks → bar, line, pie, and scatter charts via matplotlib |
|
|
55
|
+
| **Graphs** | `\`\`\`graph` blocks → network/graph diagrams with weighted edges via networkx |
|
|
56
|
+
| **Workflows** | `\`\`\`workflow` blocks → flowcharts with decision diamonds, process boxes, and arrows |
|
|
51
57
|
| **Other** | Blockquotes, horizontal rules, clickable hyperlinks, local images, footnotes |
|
|
52
58
|
|
|
53
59
|
## Quick Start
|
|
@@ -55,30 +61,53 @@ Large language models (ChatGPT, Claude, Gemini, …) produce great Markdown, but
|
|
|
55
61
|
### Installation
|
|
56
62
|
|
|
57
63
|
```bash
|
|
58
|
-
git clone https://github.com/shynerri-source/markdocx.git
|
|
59
|
-
cd markdocx
|
|
60
64
|
# Using uv (recommended)
|
|
61
|
-
uv
|
|
65
|
+
uv add markdocx
|
|
62
66
|
|
|
63
67
|
# Or using pip
|
|
64
|
-
pip install
|
|
68
|
+
pip install markdocx
|
|
65
69
|
```
|
|
66
70
|
|
|
71
|
+
<details>
|
|
72
|
+
<summary>Install from source (for development)</summary>
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/shynerri-source/markdocx.git
|
|
76
|
+
cd markdocx
|
|
77
|
+
uv sync # or: pip install -e .
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
</details>
|
|
81
|
+
|
|
67
82
|
### Usage
|
|
68
83
|
|
|
84
|
+
#### CLI
|
|
85
|
+
|
|
69
86
|
```bash
|
|
70
87
|
# Convert a single file
|
|
71
|
-
|
|
72
|
-
|
|
88
|
+
markdocx input.md
|
|
89
|
+
markdocx input.md -o output.docx
|
|
73
90
|
|
|
74
91
|
# Convert an entire directory
|
|
75
|
-
|
|
92
|
+
markdocx ./chapters/ -o ./output/
|
|
76
93
|
|
|
77
94
|
# Recursively search subdirectories
|
|
78
|
-
|
|
95
|
+
markdocx ./chapters/ -o ./output/ -r
|
|
79
96
|
|
|
80
97
|
# Verbose logging
|
|
81
|
-
|
|
98
|
+
markdocx input.md -v
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### Python API
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from markdocx import convert_file, convert_directory
|
|
105
|
+
|
|
106
|
+
# Single file
|
|
107
|
+
convert_file("input.md", "output.docx")
|
|
108
|
+
|
|
109
|
+
# Entire directory
|
|
110
|
+
results = convert_directory("./chapters/", output_dir="./output/", recursive=True)
|
|
82
111
|
```
|
|
83
112
|
|
|
84
113
|
### CLI Options
|
|
@@ -100,9 +129,10 @@ Markdown file
|
|
|
100
129
|
│
|
|
101
130
|
▼
|
|
102
131
|
docx_builder.py ─── walks the token stream, builds Word elements
|
|
103
|
-
├── math_renderer.py
|
|
104
|
-
├── code_renderer.py
|
|
105
|
-
|
|
132
|
+
├── math_renderer.py ─── LaTeX → MathML → OMML (native Word equations)
|
|
133
|
+
├── code_renderer.py ─── Pygments lexer → colored Word runs
|
|
134
|
+
├── diagram_renderer.py ─── matrix / chart / graph / workflow → PNG images
|
|
135
|
+
└── styles.py ─── fonts, colors, spacing presets
|
|
106
136
|
│
|
|
107
137
|
▼
|
|
108
138
|
.docx file ─── python-docx output
|
|
@@ -122,21 +152,72 @@ LaTeX string → latex2mathml → MathML → XSLT → OMML → Word paragraph
|
|
|
122
152
|
Source code → Pygments lexer + VS Code theme → colored Word runs inside a shaded table cell
|
|
123
153
|
```
|
|
124
154
|
|
|
155
|
+
### Diagram Pipeline
|
|
156
|
+
|
|
157
|
+
Fenced code blocks with special language identifiers (`matrix`, `chart`, `graph`, `workflow`) are rendered as PNG images via matplotlib/networkx and embedded in the document.
|
|
158
|
+
|
|
159
|
+
````markdown
|
|
160
|
+
```matrix
|
|
161
|
+
name: A
|
|
162
|
+
1 2 3
|
|
163
|
+
4 5 6
|
|
164
|
+
7 8 9
|
|
165
|
+
caption: Matrix A (3×3)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
```chart
|
|
169
|
+
type: bar
|
|
170
|
+
title: Algorithm Performance
|
|
171
|
+
labels: Bubble Sort, Merge Sort, Quick Sort
|
|
172
|
+
Time (ms): 450, 38, 35
|
|
173
|
+
caption: Figure 1: Sorting comparison
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
```graph
|
|
177
|
+
directed: true
|
|
178
|
+
title: Shortest Path
|
|
179
|
+
A -> B: 5
|
|
180
|
+
B -> C: 3
|
|
181
|
+
A -> C: 7
|
|
182
|
+
caption: Figure 2: Weighted directed graph
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
```workflow
|
|
186
|
+
title: Login Process
|
|
187
|
+
[Start]
|
|
188
|
+
<User Input>
|
|
189
|
+
(Validate Credentials)
|
|
190
|
+
{Valid?}
|
|
191
|
+
(Grant Access)
|
|
192
|
+
[End]
|
|
193
|
+
caption: Figure 3: Authentication workflow
|
|
194
|
+
```
|
|
195
|
+
````
|
|
196
|
+
|
|
197
|
+
| Block type | Formats | Rendered via |
|
|
198
|
+
|:-----------|:--------|:-------------|
|
|
199
|
+
| `matrix` | Simple text or JSON | matplotlib |
|
|
200
|
+
| `chart` | Simple key-value or JSON — bar, line, pie, scatter | matplotlib |
|
|
201
|
+
| `graph` | Edge list (`A -> B: 5`) or JSON — directed/undirected | matplotlib + networkx |
|
|
202
|
+
| `workflow` | Step notation (`[Start]`, `(Process)`, `{Decision}`, `<I/O>`) or JSON | matplotlib |
|
|
203
|
+
|
|
125
204
|
## Project Structure
|
|
126
205
|
|
|
127
206
|
```
|
|
128
|
-
|
|
129
|
-
├── main.py #
|
|
207
|
+
markdocx/
|
|
208
|
+
├── main.py # Convenience entry point
|
|
130
209
|
├── pyproject.toml # Project metadata & dependencies
|
|
131
|
-
├──
|
|
132
|
-
|
|
133
|
-
│
|
|
134
|
-
│
|
|
135
|
-
│
|
|
136
|
-
│
|
|
137
|
-
│
|
|
138
|
-
│
|
|
139
|
-
│
|
|
210
|
+
├── src/
|
|
211
|
+
│ └── markdocx/ # Installable package
|
|
212
|
+
│ ├── __init__.py # Public API (convert_file, convert_directory)
|
|
213
|
+
│ ├── cli.py # CLI entry point (markdocx command)
|
|
214
|
+
│ ├── core.py # Top-level orchestrator
|
|
215
|
+
│ ├── md_parser.py # Markdown → token stream
|
|
216
|
+
│ ├── math_renderer.py # LaTeX → OMML (native Word math)
|
|
217
|
+
│ ├── code_renderer.py # Code → syntax-highlighted Word runs
|
|
218
|
+
│ ├── diagram_renderer.py # Matrix / Chart / Graph / Workflow → PNG
|
|
219
|
+
│ ├── docx_builder.py # Token stream → DOCX elements
|
|
220
|
+
│ └── styles.py # Fonts, colors, and layout presets
|
|
140
221
|
└── rule/
|
|
141
222
|
├── ai_gen_doc_rule.md # AI writing rules (Vietnamese)
|
|
142
223
|
└── ai_gen_doc_rule_en.md # AI writing rules (English)
|
|
@@ -152,8 +233,9 @@ md_to_docx/
|
|
|
152
233
|
| [latex2mathml](https://github.com/roniemartinez/latex2mathml) | 3.78.1 | LaTeX → MathML conversion |
|
|
153
234
|
| [lxml](https://lxml.de/) | 6.0.2 | XML/XSLT processing |
|
|
154
235
|
| [Pygments](https://pygments.org/) | 2.19.2 | Syntax highlighting |
|
|
155
|
-
| [matplotlib](https://matplotlib.org/) | 3.10.8 |
|
|
236
|
+
| [matplotlib](https://matplotlib.org/) | 3.10.8 | Chart, matrix, workflow rendering |
|
|
156
237
|
| [Pillow](https://python-pillow.org/) | 12.1.0 | Image processing |
|
|
238
|
+
| [networkx](https://networkx.org/) | 3.4+ | Graph/network diagram layouts |
|
|
157
239
|
|
|
158
240
|
## AI Writing Rules
|
|
159
241
|
|