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.
@@ -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: 1
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
- # MD to DOCX
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
+ [![PyPI](https://img.shields.io/pypi/v/markdocx.svg)](https://pypi.org/project/markdocx/)
26
28
  [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
27
29
  [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](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
- **MD to DOCX** 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, and everything else properly formatted.
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 sync
65
+ uv add markdocx
62
66
 
63
67
  # Or using pip
64
- pip install -r requirements.txt
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
- python main.py input.md
72
- python main.py input.md -o output.docx
88
+ markdocx input.md
89
+ markdocx input.md -o output.docx
73
90
 
74
91
  # Convert an entire directory
75
- python main.py ./chapters/ -o ./output/
92
+ markdocx ./chapters/ -o ./output/
76
93
 
77
94
  # Recursively search subdirectories
78
- python main.py ./chapters/ -o ./output/ -r
95
+ markdocx ./chapters/ -o ./output/ -r
79
96
 
80
97
  # Verbose logging
81
- python main.py input.md -v
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 ─── LaTeX → MathML → OMML (native Word equations)
104
- ├── code_renderer.py ─── Pygments lexer → colored Word runs
105
- └── styles.py ─── fonts, colors, spacing presets
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
- md_to_docx/
129
- ├── main.py # CLI entry point
207
+ markdocx/
208
+ ├── main.py # Convenience entry point
130
209
  ├── pyproject.toml # Project metadata & dependencies
131
- ├── requirements.txt # Pip-compatible dependency list
132
- ├── converter/
133
- ├── __init__.py
134
- ├── core.py # Top-level orchestrator
135
- ├── md_parser.py # Markdown → token stream
136
- ├── math_renderer.py # LaTeXOMML (native Word math)
137
- ├── code_renderer.py # Codesyntax-highlighted Word runs
138
- ├── docx_builder.py # Token stream DOCX elements
139
- └── styles.py # Fonts, colors, and layout presets
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 # Markdowntoken stream
216
+ ├── math_renderer.py # LaTeXOMML (native Word math)
217
+ ├── code_renderer.py # Codesyntax-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 | LaTeX rendering (fallback) |
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