Skip to main content

CLI toolkit to extract code, export tables, generate styled HTML/PDF from Markdown โ€” with GitHub repo support

Project description

๐Ÿ“„ 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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdtoolkit-1.0.0.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mdtoolkit-1.0.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file mdtoolkit-1.0.0.tar.gz.

File metadata

  • Download URL: mdtoolkit-1.0.0.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for mdtoolkit-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7b8c1c0ea92c402a7adaca0e9142924695a955c0bb33b7671f49c98a436f78f2
MD5 0ba69de3f9d835b46d0452c0645c8a70
BLAKE2b-256 22bbe8f3b153566c2e7a0afd9e66a506d4c599a0a59f0a96ed35b264b2c02d3f

See more details on using hashes here.

File details

Details for the file mdtoolkit-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: mdtoolkit-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for mdtoolkit-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22ea693f42ec1e19fd5618b000383af24bab95e9ef1b70157bff18f7b290f806
MD5 6df4dc49693ca2cf229621edb1644084
BLAKE2b-256 7627c346e0f842408f5d8facaef45a0d066bf18fdc41cadd46abd9fa41c4dc8d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page