mdtoolkit 1.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.
- mdtoolkit-1.0.0/LICENSE +21 -0
- mdtoolkit-1.0.0/PKG-INFO +231 -0
- mdtoolkit-1.0.0/README.md +171 -0
- mdtoolkit-1.0.0/mdtoolkit/__init__.py +30 -0
- mdtoolkit-1.0.0/mdtoolkit/__main__.py +199 -0
- mdtoolkit-1.0.0/mdtoolkit/colors.py +29 -0
- mdtoolkit-1.0.0/mdtoolkit/extractor.py +102 -0
- mdtoolkit-1.0.0/mdtoolkit/github.py +263 -0
- mdtoolkit-1.0.0/mdtoolkit/py.typed +0 -0
- mdtoolkit-1.0.0/mdtoolkit/renderer.py +149 -0
- mdtoolkit-1.0.0/mdtoolkit/tables.py +102 -0
- mdtoolkit-1.0.0/mdtoolkit.egg-info/PKG-INFO +231 -0
- mdtoolkit-1.0.0/mdtoolkit.egg-info/SOURCES.txt +18 -0
- mdtoolkit-1.0.0/mdtoolkit.egg-info/dependency_links.txt +1 -0
- mdtoolkit-1.0.0/mdtoolkit.egg-info/entry_points.txt +2 -0
- mdtoolkit-1.0.0/mdtoolkit.egg-info/requires.txt +7 -0
- mdtoolkit-1.0.0/mdtoolkit.egg-info/top_level.txt +1 -0
- mdtoolkit-1.0.0/pyproject.toml +64 -0
- mdtoolkit-1.0.0/setup.cfg +4 -0
- mdtoolkit-1.0.0/tests/test_core.py +0 -0
mdtoolkit-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anand Venkataraman
|
|
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.
|
mdtoolkit-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mdtoolkit
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: CLI toolkit to extract code, export tables, generate styled HTML/PDF from Markdown — with GitHub repo support
|
|
5
|
+
Author-email: Anand Venkataraman <vand3dup@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Anand Venkataraman
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/anandvenkataraman/mdtoolkit
|
|
29
|
+
Project-URL: Documentation, https://github.com/anandvenkataraman/mdtoolkit#readme
|
|
30
|
+
Project-URL: Repository, https://github.com/anandvenkataraman/mdtoolkit
|
|
31
|
+
Project-URL: Bug Tracker, https://github.com/anandvenkataraman/mdtoolkit/issues
|
|
32
|
+
Project-URL: Changelog, https://github.com/anandvenkataraman/mdtoolkit/blob/main/CHANGELOG.md
|
|
33
|
+
Keywords: markdown,cli,code-extraction,pdf,html,github,tables,csv,xlsx,developer-tools
|
|
34
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
35
|
+
Classifier: Environment :: Console
|
|
36
|
+
Classifier: Intended Audience :: Developers
|
|
37
|
+
Classifier: Intended Audience :: Education
|
|
38
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
39
|
+
Classifier: Operating System :: OS Independent
|
|
40
|
+
Classifier: Programming Language :: Python :: 3
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
44
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
45
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
46
|
+
Classifier: Topic :: Documentation
|
|
47
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
48
|
+
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
49
|
+
Classifier: Topic :: Utilities
|
|
50
|
+
Requires-Python: >=3.8
|
|
51
|
+
Description-Content-Type: text/markdown
|
|
52
|
+
License-File: LICENSE
|
|
53
|
+
Requires-Dist: markdown>=3.4.0
|
|
54
|
+
Requires-Dist: openpyxl>=3.1.0
|
|
55
|
+
Provides-Extra: dev
|
|
56
|
+
Requires-Dist: build>=1.0.0; extra == "dev"
|
|
57
|
+
Requires-Dist: twine>=5.0.0; extra == "dev"
|
|
58
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
59
|
+
Dynamic: license-file
|
|
60
|
+
|
|
61
|
+
# 📄 Markdown Toolkit — `mdtoolkit`
|
|
62
|
+
|
|
63
|
+
> A powerful CLI toolkit to extract code blocks, export tables, generate styled HTML/PDF, and process entire GitHub repositories — all from your Markdown files.
|
|
64
|
+
|
|
65
|
+
[](LICENSE)
|
|
66
|
+
[](https://www.python.org/)
|
|
67
|
+
[](mailto:vand3dup@gmail.com)
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## ✨ Features
|
|
72
|
+
|
|
73
|
+
| Feature | Description |
|
|
74
|
+
|---|---|
|
|
75
|
+
| 🗂 **Code Extraction** | Extracts all fenced code blocks; named from markdown hint or `code_line<N>.ext` |
|
|
76
|
+
| 📊 **Table Export** | Exports Markdown tables to CSV or styled XLSX workbooks |
|
|
77
|
+
| 🎨 **Styled HTML** | Generates dark-themed professional HTML with embedded CSS |
|
|
78
|
+
| 📄 **PDF Export** | Renders PDF via `wkhtmltopdf` or headless Chrome |
|
|
79
|
+
| 🐙 **GitHub Mode** | Clones any public repo, discovers all `.md` files, lets you pick and process |
|
|
80
|
+
| 🔍 **File Summary** | Quick stats — headings, code blocks, tables, word count |
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 🚀 Quick Start
|
|
85
|
+
|
|
86
|
+
### Installation
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Clone the repo
|
|
90
|
+
git clone https://github.com/cgmafia/mdtoolkit.git
|
|
91
|
+
cd mdtoolkit
|
|
92
|
+
|
|
93
|
+
# Install dependencies
|
|
94
|
+
pip install -r requirements.txt
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Usage
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Process a local Markdown file directly
|
|
101
|
+
python3 tool.py README.md
|
|
102
|
+
|
|
103
|
+
# Interactive launcher (local file OR GitHub mode)
|
|
104
|
+
python3 tool.py
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 📋 Menu Options
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
[1] 🗂 Extract Code Blocks named from markdown or code_line<N>.ext
|
|
113
|
+
[2] 📊 Export Tables -> CSV one .csv per table
|
|
114
|
+
[3] 📊 Export Tables -> XLSX all tables in one styled workbook
|
|
115
|
+
[4] 🎨 Export Styled HTML dark-themed HTML with embedded CSS
|
|
116
|
+
[5] 📄 Export PDF via wkhtmltopdf or Chrome headless
|
|
117
|
+
[6] 🚀 Do Everything run all 5 actions at once
|
|
118
|
+
[7] 🔍 File Summary headings, code blocks, tables count
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 🐙 GitHub Mode
|
|
124
|
+
|
|
125
|
+
When you run `python3 tool.py` without arguments, you get a launch menu with a **GitHub repository** option. Accepts any URL format:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
https://github.com/owner/repo
|
|
129
|
+
https://github.com/owner/repo/tree/develop
|
|
130
|
+
https://github.com/owner/repo/tree/feature/my-branch
|
|
131
|
+
git@github.com:owner/repo.git
|
|
132
|
+
owner/repo
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The tool will:
|
|
136
|
+
1. Clone the repo (depth 1 for speed), with ZIP fallback
|
|
137
|
+
2. Scan for all `.md` / `.markdown` files (skipping `node_modules`, `.git`, etc.)
|
|
138
|
+
3. Present an interactive picker (README.md always listed first)
|
|
139
|
+
4. Process the chosen file — or **all files** at once
|
|
140
|
+
5. Cache the clone and offer to reuse it on repeat runs
|
|
141
|
+
|
|
142
|
+
Output is written to:
|
|
143
|
+
```
|
|
144
|
+
md_toolkit_output/
|
|
145
|
+
github_output/
|
|
146
|
+
owner_repo/
|
|
147
|
+
README/
|
|
148
|
+
code/
|
|
149
|
+
tables/
|
|
150
|
+
README.html
|
|
151
|
+
README.pdf
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 🗂 Code Block Naming
|
|
157
|
+
|
|
158
|
+
| Fence in Markdown | Saved As |
|
|
159
|
+
|---|---|
|
|
160
|
+
| ` ```java:SecurityConfig.java ` | `SecurityConfig.java` |
|
|
161
|
+
| ` ```python ` at line 42 | `code_line42.py` |
|
|
162
|
+
| ` ```sql ` at line 87 | `code_line87.sql` |
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 📦 Dependencies
|
|
167
|
+
|
|
168
|
+
| Package | Purpose | Required? |
|
|
169
|
+
|---|---|---|
|
|
170
|
+
| `markdown` | MD → HTML conversion | Recommended |
|
|
171
|
+
| `openpyxl` | XLSX table export | For XLSX feature |
|
|
172
|
+
| `wkhtmltopdf` | PDF rendering (system tool) | For PDF feature |
|
|
173
|
+
|
|
174
|
+
Install Python packages:
|
|
175
|
+
```bash
|
|
176
|
+
pip install markdown openpyxl
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Install `wkhtmltopdf` (system):
|
|
180
|
+
```bash
|
|
181
|
+
# Ubuntu / Debian
|
|
182
|
+
sudo apt install wkhtmltopdf
|
|
183
|
+
|
|
184
|
+
# macOS
|
|
185
|
+
brew install wkhtmltopdf
|
|
186
|
+
|
|
187
|
+
# Windows — download installer from:
|
|
188
|
+
# https://wkhtmltopdf.org/downloads.html
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 🖥 Platform Support
|
|
194
|
+
|
|
195
|
+
| Platform | Status |
|
|
196
|
+
|---|---|
|
|
197
|
+
| Linux | ✅ Fully supported |
|
|
198
|
+
| macOS | ✅ Fully supported |
|
|
199
|
+
| Windows | ✅ Works (use `python tool.py` not `python3`) |
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## 🤝 Contributing
|
|
204
|
+
|
|
205
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
206
|
+
|
|
207
|
+
1. Fork the repository
|
|
208
|
+
2. Create your feature branch: `git checkout -b feature/amazing-feature`
|
|
209
|
+
3. Commit your changes: `git commit -m 'Add amazing feature'`
|
|
210
|
+
4. Push to the branch: `git push origin feature/amazing-feature`
|
|
211
|
+
5. Open a Pull Request
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## 📄 License
|
|
216
|
+
|
|
217
|
+
This project is licensed under the **MIT License** — see the [LICENSE](LICENSE) file for details.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## 👤 Author
|
|
222
|
+
|
|
223
|
+
**Anand Venkataraman**
|
|
224
|
+
- 📧 Email: [vand3dup@gmail.com](mailto:vand3dup@gmail.com)
|
|
225
|
+
- 🐙 GitHub: [@cgmafia](https://github.com/cgmafia)
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## ⭐ Show Your Support
|
|
230
|
+
|
|
231
|
+
If this tool helped you, please consider giving it a ⭐ on GitHub!
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# 📄 Markdown Toolkit — `mdtoolkit`
|
|
2
|
+
|
|
3
|
+
> A powerful CLI toolkit to extract code blocks, export tables, generate styled HTML/PDF, and process entire GitHub repositories — all from your Markdown files.
|
|
4
|
+
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://www.python.org/)
|
|
7
|
+
[](mailto:vand3dup@gmail.com)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## ✨ Features
|
|
12
|
+
|
|
13
|
+
| Feature | Description |
|
|
14
|
+
|---|---|
|
|
15
|
+
| 🗂 **Code Extraction** | Extracts all fenced code blocks; named from markdown hint or `code_line<N>.ext` |
|
|
16
|
+
| 📊 **Table Export** | Exports Markdown tables to CSV or styled XLSX workbooks |
|
|
17
|
+
| 🎨 **Styled HTML** | Generates dark-themed professional HTML with embedded CSS |
|
|
18
|
+
| 📄 **PDF Export** | Renders PDF via `wkhtmltopdf` or headless Chrome |
|
|
19
|
+
| 🐙 **GitHub Mode** | Clones any public repo, discovers all `.md` files, lets you pick and process |
|
|
20
|
+
| 🔍 **File Summary** | Quick stats — headings, code blocks, tables, word count |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 🚀 Quick Start
|
|
25
|
+
|
|
26
|
+
### Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Clone the repo
|
|
30
|
+
git clone https://github.com/cgmafia/mdtoolkit.git
|
|
31
|
+
cd mdtoolkit
|
|
32
|
+
|
|
33
|
+
# Install dependencies
|
|
34
|
+
pip install -r requirements.txt
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Usage
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Process a local Markdown file directly
|
|
41
|
+
python3 tool.py README.md
|
|
42
|
+
|
|
43
|
+
# Interactive launcher (local file OR GitHub mode)
|
|
44
|
+
python3 tool.py
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 📋 Menu Options
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
[1] 🗂 Extract Code Blocks named from markdown or code_line<N>.ext
|
|
53
|
+
[2] 📊 Export Tables -> CSV one .csv per table
|
|
54
|
+
[3] 📊 Export Tables -> XLSX all tables in one styled workbook
|
|
55
|
+
[4] 🎨 Export Styled HTML dark-themed HTML with embedded CSS
|
|
56
|
+
[5] 📄 Export PDF via wkhtmltopdf or Chrome headless
|
|
57
|
+
[6] 🚀 Do Everything run all 5 actions at once
|
|
58
|
+
[7] 🔍 File Summary headings, code blocks, tables count
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 🐙 GitHub Mode
|
|
64
|
+
|
|
65
|
+
When you run `python3 tool.py` without arguments, you get a launch menu with a **GitHub repository** option. Accepts any URL format:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
https://github.com/owner/repo
|
|
69
|
+
https://github.com/owner/repo/tree/develop
|
|
70
|
+
https://github.com/owner/repo/tree/feature/my-branch
|
|
71
|
+
git@github.com:owner/repo.git
|
|
72
|
+
owner/repo
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The tool will:
|
|
76
|
+
1. Clone the repo (depth 1 for speed), with ZIP fallback
|
|
77
|
+
2. Scan for all `.md` / `.markdown` files (skipping `node_modules`, `.git`, etc.)
|
|
78
|
+
3. Present an interactive picker (README.md always listed first)
|
|
79
|
+
4. Process the chosen file — or **all files** at once
|
|
80
|
+
5. Cache the clone and offer to reuse it on repeat runs
|
|
81
|
+
|
|
82
|
+
Output is written to:
|
|
83
|
+
```
|
|
84
|
+
md_toolkit_output/
|
|
85
|
+
github_output/
|
|
86
|
+
owner_repo/
|
|
87
|
+
README/
|
|
88
|
+
code/
|
|
89
|
+
tables/
|
|
90
|
+
README.html
|
|
91
|
+
README.pdf
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 🗂 Code Block Naming
|
|
97
|
+
|
|
98
|
+
| Fence in Markdown | Saved As |
|
|
99
|
+
|---|---|
|
|
100
|
+
| ` ```java:SecurityConfig.java ` | `SecurityConfig.java` |
|
|
101
|
+
| ` ```python ` at line 42 | `code_line42.py` |
|
|
102
|
+
| ` ```sql ` at line 87 | `code_line87.sql` |
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 📦 Dependencies
|
|
107
|
+
|
|
108
|
+
| Package | Purpose | Required? |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| `markdown` | MD → HTML conversion | Recommended |
|
|
111
|
+
| `openpyxl` | XLSX table export | For XLSX feature |
|
|
112
|
+
| `wkhtmltopdf` | PDF rendering (system tool) | For PDF feature |
|
|
113
|
+
|
|
114
|
+
Install Python packages:
|
|
115
|
+
```bash
|
|
116
|
+
pip install markdown openpyxl
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Install `wkhtmltopdf` (system):
|
|
120
|
+
```bash
|
|
121
|
+
# Ubuntu / Debian
|
|
122
|
+
sudo apt install wkhtmltopdf
|
|
123
|
+
|
|
124
|
+
# macOS
|
|
125
|
+
brew install wkhtmltopdf
|
|
126
|
+
|
|
127
|
+
# Windows — download installer from:
|
|
128
|
+
# https://wkhtmltopdf.org/downloads.html
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 🖥 Platform Support
|
|
134
|
+
|
|
135
|
+
| Platform | Status |
|
|
136
|
+
|---|---|
|
|
137
|
+
| Linux | ✅ Fully supported |
|
|
138
|
+
| macOS | ✅ Fully supported |
|
|
139
|
+
| Windows | ✅ Works (use `python tool.py` not `python3`) |
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## 🤝 Contributing
|
|
144
|
+
|
|
145
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
146
|
+
|
|
147
|
+
1. Fork the repository
|
|
148
|
+
2. Create your feature branch: `git checkout -b feature/amazing-feature`
|
|
149
|
+
3. Commit your changes: `git commit -m 'Add amazing feature'`
|
|
150
|
+
4. Push to the branch: `git push origin feature/amazing-feature`
|
|
151
|
+
5. Open a Pull Request
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 📄 License
|
|
156
|
+
|
|
157
|
+
This project is licensed under the **MIT License** — see the [LICENSE](LICENSE) file for details.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## 👤 Author
|
|
162
|
+
|
|
163
|
+
**Anand Venkataraman**
|
|
164
|
+
- 📧 Email: [vand3dup@gmail.com](mailto:vand3dup@gmail.com)
|
|
165
|
+
- 🐙 GitHub: [@cgmafia](https://github.com/cgmafia)
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## ⭐ Show Your Support
|
|
170
|
+
|
|
171
|
+
If this tool helped you, please consider giving it a ⭐ on GitHub!
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Markdown Toolkit — mdtoolkit
|
|
3
|
+
============================
|
|
4
|
+
A CLI toolkit to extract code blocks, export tables, generate styled
|
|
5
|
+
HTML/PDF from Markdown files — with GitHub repository support.
|
|
6
|
+
|
|
7
|
+
Author : Anand Venkataraman <vand3dup@gmail.com>
|
|
8
|
+
License : MIT
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__version__ = "1.0.0"
|
|
12
|
+
__author__ = "Anand Venkataraman"
|
|
13
|
+
__email__ = "vand3dup@gmail.com"
|
|
14
|
+
__license__ = "MIT"
|
|
15
|
+
|
|
16
|
+
from mdtoolkit.extractor import extract_code_blocks, save_code_files
|
|
17
|
+
from mdtoolkit.tables import extract_tables, export_tables
|
|
18
|
+
from mdtoolkit.renderer import build_html, save_html, export_pdf
|
|
19
|
+
from mdtoolkit.github import github_flow
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"extract_code_blocks",
|
|
23
|
+
"save_code_files",
|
|
24
|
+
"extract_tables",
|
|
25
|
+
"export_tables",
|
|
26
|
+
"build_html",
|
|
27
|
+
"save_html",
|
|
28
|
+
"export_pdf",
|
|
29
|
+
"github_flow",
|
|
30
|
+
]
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Entry point for:
|
|
3
|
+
python -m mdtoolkit [file.md]
|
|
4
|
+
mdtoolkit [file.md] ← after pip install
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from mdtoolkit import __version__
|
|
11
|
+
from mdtoolkit.colors import banner, info, ok, warn, err, head, B, W, G, DIM, RST
|
|
12
|
+
from mdtoolkit.extractor import extract_code_blocks, save_code_files, EXT_MAP
|
|
13
|
+
from mdtoolkit.tables import extract_tables, export_tables
|
|
14
|
+
from mdtoolkit.renderer import build_html, save_html, export_pdf
|
|
15
|
+
from mdtoolkit.github import github_flow
|
|
16
|
+
import re
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# ── Helpers ───────────────────────────────────────────────────────────────────
|
|
20
|
+
|
|
21
|
+
def load_md(path: Path) -> str:
|
|
22
|
+
if not path.exists():
|
|
23
|
+
err("File not found: " + str(path))
|
|
24
|
+
sys.exit(1)
|
|
25
|
+
return path.read_text(encoding="utf-8")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def file_summary(md_path: Path, md_text: str) -> None:
|
|
29
|
+
head("📋 Summary of " + md_path.name)
|
|
30
|
+
lines = md_text.splitlines()
|
|
31
|
+
blocks = extract_code_blocks(md_text)
|
|
32
|
+
tables = extract_tables(md_text)
|
|
33
|
+
links = re.findall(r"\[([^\]]+)\]\(([^)]+)\)", md_text)
|
|
34
|
+
|
|
35
|
+
info("Total lines : " + str(len(lines)))
|
|
36
|
+
info("Words : " + str(len(md_text.split())))
|
|
37
|
+
info("H1 headings : " + str(sum(1 for l in lines if l.startswith("# "))))
|
|
38
|
+
info("H2 headings : " + str(sum(1 for l in lines if l.startswith("## "))))
|
|
39
|
+
info("H3 headings : " + str(sum(1 for l in lines if l.startswith("### "))))
|
|
40
|
+
info("Code blocks : " + str(len(blocks)))
|
|
41
|
+
info("Tables : " + str(len(tables)))
|
|
42
|
+
info("Links : " + str(len(links)))
|
|
43
|
+
|
|
44
|
+
if blocks:
|
|
45
|
+
head("Code blocks")
|
|
46
|
+
for i, (lang, hint, code, line_no) in enumerate(blocks, 1):
|
|
47
|
+
ext = EXT_MAP.get(lang.lower(), "txt") if lang else "txt"
|
|
48
|
+
label = hint if hint else "(→ code_line" + str(line_no) + "." + ext + ")"
|
|
49
|
+
print(" " + DIM + "#" + str(i).ljust(3) +
|
|
50
|
+
" line=" + str(line_no).ljust(5) +
|
|
51
|
+
" lang=" + (lang or "none").ljust(12) +
|
|
52
|
+
" " + label + RST)
|
|
53
|
+
|
|
54
|
+
if tables:
|
|
55
|
+
head("Tables")
|
|
56
|
+
for i, tbl in enumerate(tables, 1):
|
|
57
|
+
print(" " + DIM + "#" + str(i) + " " +
|
|
58
|
+
str(len(tbl[0])) + " cols x " + str(len(tbl)) +
|
|
59
|
+
" rows | header: " + ", ".join(tbl[0]) + RST)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# ── Per-file menu ─────────────────────────────────────────────────────────────
|
|
63
|
+
|
|
64
|
+
MENU_ITEMS = [
|
|
65
|
+
("1", "🗂 Extract Code Blocks", "named from markdown or code_line<N>.ext"),
|
|
66
|
+
("2", "📊 Export Tables -> CSV", "one .csv per table"),
|
|
67
|
+
("3", "📊 Export Tables -> XLSX", "all tables in one styled workbook"),
|
|
68
|
+
("4", "🎨 Export Styled HTML", "dark-themed HTML with embedded CSS"),
|
|
69
|
+
("5", "📄 Export PDF", "via wkhtmltopdf or Chrome headless"),
|
|
70
|
+
("6", "🚀 Do Everything", "run all 5 actions at once"),
|
|
71
|
+
("7", "🔍 File Summary", "headings, code blocks, tables count"),
|
|
72
|
+
("Q", "🚪 Quit / Back", ""),
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def print_file_menu() -> None:
|
|
77
|
+
print("\n" + W + " ┌─ What would you like to do? ─────────────────────────┐" + RST)
|
|
78
|
+
for key, label, hint in MENU_ITEMS:
|
|
79
|
+
hint_str = (" " + DIM + hint + RST) if hint else ""
|
|
80
|
+
print(" " + B + "[" + key + "]" + RST + " " + label + hint_str)
|
|
81
|
+
print(W + " └──────────────────────────────────────────────────────────┘" + RST)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def run_menu(md_path: Path, out_dir: Path, single_shot: bool = False) -> None:
|
|
85
|
+
"""
|
|
86
|
+
Interactive per-file action menu.
|
|
87
|
+
single_shot=True → execute 'Do Everything' once and return (batch mode).
|
|
88
|
+
"""
|
|
89
|
+
md_text = load_md(md_path)
|
|
90
|
+
|
|
91
|
+
if not single_shot:
|
|
92
|
+
info("File : " + str(md_path))
|
|
93
|
+
info("Output: " + str(out_dir) + "/")
|
|
94
|
+
|
|
95
|
+
while True:
|
|
96
|
+
if single_shot:
|
|
97
|
+
choice = "6"
|
|
98
|
+
else:
|
|
99
|
+
print_file_menu()
|
|
100
|
+
choice = input("\n " + W + "Enter choice: " + RST).strip().upper()
|
|
101
|
+
|
|
102
|
+
if choice == "1":
|
|
103
|
+
head("📂 Extracting Code")
|
|
104
|
+
save_code_files(md_path, md_text, out_dir / "code")
|
|
105
|
+
elif choice == "2":
|
|
106
|
+
head("📊 Exporting Tables -> CSV")
|
|
107
|
+
export_tables(md_path, md_text, "csv", out_dir / "tables")
|
|
108
|
+
elif choice == "3":
|
|
109
|
+
head("📊 Exporting Tables -> XLSX")
|
|
110
|
+
export_tables(md_path, md_text, "xlsx", out_dir / "tables")
|
|
111
|
+
elif choice == "4":
|
|
112
|
+
head("🎨 Exporting Styled HTML")
|
|
113
|
+
ok("HTML saved -> " + str(save_html(md_path, md_text, out_dir)))
|
|
114
|
+
elif choice == "5":
|
|
115
|
+
head("📄 Exporting PDF")
|
|
116
|
+
export_pdf(md_path, md_text, out_dir)
|
|
117
|
+
elif choice == "6":
|
|
118
|
+
head("🚀 Running All Actions")
|
|
119
|
+
save_code_files(md_path, md_text, out_dir / "code")
|
|
120
|
+
export_tables(md_path, md_text, "csv", out_dir / "tables")
|
|
121
|
+
export_tables(md_path, md_text, "xlsx", out_dir / "tables")
|
|
122
|
+
ok("HTML -> " + str(save_html(md_path, md_text, out_dir)))
|
|
123
|
+
export_pdf(md_path, md_text, out_dir)
|
|
124
|
+
ok("All done!")
|
|
125
|
+
if single_shot:
|
|
126
|
+
return
|
|
127
|
+
elif choice == "7":
|
|
128
|
+
file_summary(md_path, md_text)
|
|
129
|
+
elif choice in ("Q", "QUIT", "EXIT", "0", "B", "BACK"):
|
|
130
|
+
return
|
|
131
|
+
else:
|
|
132
|
+
warn("Invalid choice. Please try again.")
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
# ── Launch menu ───────────────────────────────────────────────────────────────
|
|
136
|
+
|
|
137
|
+
LAUNCH_ITEMS = [
|
|
138
|
+
("1", "📂 Open local Markdown file", "pass a path or enter it now"),
|
|
139
|
+
("2", "🐙 GitHub repository", "clone & pick a Markdown file"),
|
|
140
|
+
("Q", "🚪 Quit", ""),
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def print_launch_menu() -> None:
|
|
145
|
+
print("\n" + W + " ┌─ Choose mode ────────────────────────────────────────────┐" + RST)
|
|
146
|
+
for key, label, hint in LAUNCH_ITEMS:
|
|
147
|
+
hint_str = (" " + DIM + hint + RST) if hint else ""
|
|
148
|
+
print(" " + B + "[" + key + "]" + RST + " " + label + hint_str)
|
|
149
|
+
print(W + " └───────────────────────────────────────────────────────────┘" + RST)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
# ── CLI entry point ───────────────────────────────────────────────────────────
|
|
153
|
+
|
|
154
|
+
def main() -> None:
|
|
155
|
+
"""Console-script entry point: `mdtoolkit [file.md]`"""
|
|
156
|
+
banner(__version__)
|
|
157
|
+
|
|
158
|
+
# Direct file argument
|
|
159
|
+
if len(sys.argv) >= 2:
|
|
160
|
+
if sys.argv[1] in ("-v", "--version"):
|
|
161
|
+
print("mdtoolkit v" + __version__)
|
|
162
|
+
sys.exit(0)
|
|
163
|
+
md_path = Path(sys.argv[1]).resolve()
|
|
164
|
+
out_dir = md_path.parent / (md_path.stem + "_output")
|
|
165
|
+
run_menu(md_path, out_dir)
|
|
166
|
+
sys.exit(0)
|
|
167
|
+
|
|
168
|
+
# Interactive launcher
|
|
169
|
+
base_out = Path.cwd() / "md_toolkit_output"
|
|
170
|
+
base_out.mkdir(parents=True, exist_ok=True)
|
|
171
|
+
|
|
172
|
+
while True:
|
|
173
|
+
print_launch_menu()
|
|
174
|
+
choice = input("\n " + W + "Enter choice: " + RST).strip().upper()
|
|
175
|
+
|
|
176
|
+
if choice == "1":
|
|
177
|
+
raw = input(" " + W + "Path to Markdown file: " + RST).strip()
|
|
178
|
+
if not raw:
|
|
179
|
+
warn("No path entered.")
|
|
180
|
+
continue
|
|
181
|
+
md_path = Path(raw).expanduser().resolve()
|
|
182
|
+
if not md_path.exists():
|
|
183
|
+
err("File not found: " + str(md_path))
|
|
184
|
+
continue
|
|
185
|
+
out_dir = base_out / md_path.stem
|
|
186
|
+
run_menu(md_path, out_dir)
|
|
187
|
+
|
|
188
|
+
elif choice == "2":
|
|
189
|
+
github_flow(base_out, run_menu)
|
|
190
|
+
|
|
191
|
+
elif choice in ("Q", "QUIT", "EXIT", "0"):
|
|
192
|
+
print("\n " + G + "Goodbye! ✨" + RST + "\n")
|
|
193
|
+
break
|
|
194
|
+
else:
|
|
195
|
+
warn("Invalid choice.")
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
if __name__ == "__main__":
|
|
199
|
+
main()
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""ANSI colour constants and print helpers."""
|
|
2
|
+
|
|
3
|
+
R = "\033[0;31m"
|
|
4
|
+
G = "\033[0;32m"
|
|
5
|
+
Y = "\033[0;33m"
|
|
6
|
+
B = "\033[0;34m"
|
|
7
|
+
C = "\033[0;36m"
|
|
8
|
+
W = "\033[1;37m"
|
|
9
|
+
M = "\033[0;35m"
|
|
10
|
+
DIM = "\033[2m"
|
|
11
|
+
RST = "\033[0m"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def info(msg): print(" " + C + "ℹ " + RST + str(msg))
|
|
15
|
+
def ok(msg): print(" " + G + "✔ " + RST + str(msg))
|
|
16
|
+
def warn(msg): print(" " + Y + "⚠ " + RST + str(msg))
|
|
17
|
+
def err(msg): print(" " + R + "✖ " + RST + str(msg))
|
|
18
|
+
def head(msg): print("\n" + W + str(msg) + RST + "\n" + "─" * 52)
|
|
19
|
+
def dim(msg): print(" " + DIM + str(msg) + RST)
|
|
20
|
+
def step(msg): print(" " + M + "▶ " + RST + str(msg))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def banner(version: str = "1.0.0"):
|
|
24
|
+
print(B + "╔══════════════════════════════════════════════════════════╗")
|
|
25
|
+
print("║ " + W + "📄 M A R K D O W N T O O L K I T v" + version + B + " ║")
|
|
26
|
+
print("║ " + DIM + "Parse • Extract Code • Export Tables • PDF • GitHub" + B + " ║")
|
|
27
|
+
print("║ " + DIM + "Author: Anand Venkataraman <vand3dup@gmail.com>" + B + " ║")
|
|
28
|
+
print("╚══════════════════════════════════════════════════════════╝" + RST)
|
|
29
|
+
print()
|