GitHunt
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.

License: MIT
Python
Author


โœจ 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.txt

Usage

# 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:

  1. Clone the repo (depth 1 for speed), with ZIP fallback
  2. Scan for all .md / .markdown files (skipping node_modules, .git, etc.)
  3. Present an interactive picker (README.md always listed first)
  4. Process the chosen file โ€” or all files at once
  5. 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 openpyxl

Install 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.

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.


๐Ÿ‘ค Author

Anand Venkataraman


โญ Show Your Support

If this tool helped you, please consider giving it a โญ on GitHub!

cgmafia/mdtoolkit | GitHunt