Skip to main content

convertor is a simple and easy to use library for converting markdown files to various formats.

Project description

Sure! Here's a professionally rewritten and polished version of your md2all documentation, designed to feel like official open-source documentation:


📝 md2all

A lightweight Python package to convert Markdown files into beautiful, responsive HTML or PDF documents—styled with Tailwind CSS, MathJax, and optimized for clean typography.

Ideal for note-taking, documentation, and publishing Markdown content without relying on external CDN access.

PyPI
Python Version
License


🚀 Features

  • ✅ Convert .md files into clean HTML or PDF
  • 🎨 Styled using Tailwind CSS
  • 🧮 Built-in MathJax support for LaTeX equations
  • 📝 Beautiful, readable typography with prose class
  • 📦 Works offline — no internet or CDN required
  • 🔄 Support for CLI

🛠️ System Dependencies

To generate PDFs via Playwright, some system libraries must be installed.

On Debian/Ubuntu:

sudo apt update
sudo apt install -y \
    libavif13 \
    libgstreamer-plugins-base1.0-0 \
    gstreamer1.0-plugins-base \
    gstreamer1.0-plugins-good \
    gstreamer1.0-libav \
    libgstreamer-gl1.0-0 \
    libgstreamer-plugins-bad1.0-0 \
    libgstreamer-plugins-base1.0-dev

On Fedora/CentOS/RHEL:

sudo dnf install -y \
    gstreamer1-plugins-base \
    gstreamer1-plugins-good \
    gstreamer1-plugins-bad-free \
    gstreamer1-libav \
    libavif

📦 Installation

Install md2all using pip:

pip install md2all

🖼️ Screenshots

See test_data/ for example Markdown and the output.

Screenshot


✨ Library Usage

Function: convert_markdown

Convert a Markdown file to HTML or PDF with optional offline/online resource support.

📥 Parameters

Parameter Type Description
md_path str Path to the Markdown file (relative or absolute).
output_dir str (Optional) Directory to save the output. Defaults to the input file's directory.
output_format str (Optional) "html" or "pdf" format. Default is "pdf".
use_cdn bool (Optional) If True, loads Tailwind and MathJax via CDN. Default is False.

📤 Returns

  • str: Full path to the converted file.

✅ Sync Example (Recommended for most users)

from md2all import convert_markdown

# Convert to HTML
convert_markdown("test_data/test.md", output_format="html")

# Convert to PDF
convert_markdown("test_data/test.md", output_format="pdf")

⚡ Async Example (Ideal for batch/API usage)

import asyncio
from md2all import convert_markdown

async def convert_all():
    await convert_markdown("test_data/test.md", output_format="html")
    await convert_markdown("test_data/test.md", output_format="pdf")

asyncio.run(convert_all())

🧪 Command Line Interface

After installation, the CLI command md2all is available globally.

📌 Basic Syntax

md2all -m <md_path> -f <format> [options]

🎯 Parameters

Flag Description
-m, --md_path Path to the input Markdown file. (Required)
-f, --format Output format: "html" or "pdf". (Required)
-o, --output_dir (Optional) Output directory. Defaults to the input file’s folder.
-c, --use_cdn (Optional) Use CDN for Tailwind and MathJax. Defaults to offline.

📘 CLI Examples

Convert to HTML:

md2all -m notes/readme.md -f html

Convert to PDF in a custom directory:

md2all -m notes/readme.md -f pdf -o ./exports

Use CDN for styles and MathJax:

md2all -m notes/readme.md -f pdf -c

📁 Output Structure

  • Outputs .html or .pdf file to your chosen directory.
  • Automatically includes all required styling and MathJax configuration.
  • Offline assets (CSS/JS) are stored under ~/.lib/.

🧑‍💻 Author

Deepak Raj
GitHub – codeperfectplus


🤔 Why md2all?

I built md2all to make Markdown publishing easier—especially on systems without internet access. With a built-in offline mode, it's ideal for generating clean documents on secure or offline environments.


💬 Contributions Welcome!

This is an open-source project. Found a bug or want a feature?
Feel free to open an issue or pull request.

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

md2all-0.0.8.tar.gz (572.3 kB view details)

Uploaded Source

Built Distribution

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

md2all-0.0.8-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file md2all-0.0.8.tar.gz.

File metadata

  • Download URL: md2all-0.0.8.tar.gz
  • Upload date:
  • Size: 572.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.8

File hashes

Hashes for md2all-0.0.8.tar.gz
Algorithm Hash digest
SHA256 87609036a557f27341acbeccadba5aa3d2f2af811c5ea4bbeacacc2e3404ec3d
MD5 02c77fa4b199b3d5e6c53efba8c5a7e8
BLAKE2b-256 18542d686124ef609f38f73b63f14618a369cd4609f8a8773c618047f3b9034a

See more details on using hashes here.

File details

Details for the file md2all-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: md2all-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.8

File hashes

Hashes for md2all-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4d9e03ec7f4654eb9082fdb19001c3e5cef1adb7dfe99daec228224a644bc8c0
MD5 5e3bd0e7c9642f719c7e31fd09069629
BLAKE2b-256 d1b670b4101c6387da36939706355e40eec17ff29ada04ce371dc2a536495c4b

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