CG
cgmafia/mdtoolkit
A CLI toolkit to extract code, export tables, generate HTML/PDF from Markdown โ with GitHub repo support
๐ Markdown Toolkit โ mdtoolkit
A powerful CLI toolkit to extract code blocks, export tables, generate styled HTML/PDF, and process entire GitHub repositories โ all from your Markdown files.
โจ Features
| Feature | Description |
|---|---|
| ๐ Code Extraction | Extracts all fenced code blocks; named from markdown hint or code_line<N>.ext |
| ๐ Table Export | Exports Markdown tables to CSV or styled XLSX workbooks |
| ๐จ Styled HTML | Generates dark-themed professional HTML with embedded CSS |
| ๐ PDF Export | Renders PDF via wkhtmltopdf or headless Chrome |
| ๐ GitHub Mode | Clones any public repo, discovers all .md files, lets you pick and process |
| ๐ File Summary | Quick stats โ headings, code blocks, tables, word count |
๐ Quick Start
Installation
# Clone the repo
git clone https://github.com/cgmafia/mdtoolkit.git
cd mdtoolkit
# Install dependencies
pip install -r requirements.txtUsage
# Process a local Markdown file directly
python3 tool.py README.md
# Interactive launcher (local file OR GitHub mode)
python3 tool.py๐ Menu Options
[1] ๐ Extract Code Blocks named from markdown or code_line<N>.ext
[2] ๐ Export Tables -> CSV one .csv per table
[3] ๐ Export Tables -> XLSX all tables in one styled workbook
[4] ๐จ Export Styled HTML dark-themed HTML with embedded CSS
[5] ๐ Export PDF via wkhtmltopdf or Chrome headless
[6] ๐ Do Everything run all 5 actions at once
[7] ๐ File Summary headings, code blocks, tables count
๐ GitHub Mode
When you run python3 tool.py without arguments, you get a launch menu with a GitHub repository option. Accepts any URL format:
https://github.com/owner/repo
https://github.com/owner/repo/tree/develop
https://github.com/owner/repo/tree/feature/my-branch
git@github.com:owner/repo.git
owner/repo
The tool will:
- Clone the repo (depth 1 for speed), with ZIP fallback
- Scan for all
.md/.markdownfiles (skippingnode_modules,.git, etc.) - Present an interactive picker (README.md always listed first)
- Process the chosen file โ or all files at once
- Cache the clone and offer to reuse it on repeat runs
Output is written to:
md_toolkit_output/
github_output/
owner_repo/
README/
code/
tables/
README.html
README.pdf
๐ Code Block Naming
| Fence in Markdown | Saved As |
|---|---|
```java:SecurityConfig.java |
SecurityConfig.java |
```python at line 42 |
code_line42.py |
```sql at line 87 |
code_line87.sql |
๐ฆ Dependencies
| Package | Purpose | Required? |
|---|---|---|
markdown |
MD โ HTML conversion | Recommended |
openpyxl |
XLSX table export | For XLSX feature |
wkhtmltopdf |
PDF rendering (system tool) | For PDF feature |
Install Python packages:
pip install markdown openpyxlInstall wkhtmltopdf (system):
# Ubuntu / Debian
sudo apt install wkhtmltopdf
# macOS
brew install wkhtmltopdf
# Windows โ download installer from:
# https://wkhtmltopdf.org/downloads.html๐ฅ Platform Support
| Platform | Status |
|---|---|
| Linux | โ Fully supported |
| macOS | โ Fully supported |
| Windows | โ
Works (use python tool.py not python3) |
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
๐ License
This project is licensed under the MIT License โ see the LICENSE file for details.
๐ค Author
Anand Venkataraman
- ๐ง Email: vand3dup@gmail.com
- ๐ GitHub: @cgmafia
โญ Show Your Support
If this tool helped you, please consider giving it a โญ on GitHub!