Skip to main content

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


📝 md2htmlify

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 md2htmlify using pip:

pip install md2htmlify

🖼️ 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 md2htmlify 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 md2htmlify 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 md2htmlify is available globally.

📌 Basic Syntax

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

md2htmlify -m notes/readme.md -f html

Convert to PDF in a custom directory:

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

Use CDN for styles and MathJax:

md2htmlify -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 md2htmlify?

I built md2htmlify 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.

Metadata

Release files for md2htmlify 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for md2htmlify 0.0.1
File Size Uploaded
md2htmlify-0.0.1.tar.gz 572.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for md2htmlify 0.0.1
File Interpreter ABI Platform
md2htmlify-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / md2htmlify-0.0.1.tar.gz

Download URL md2htmlify-0.0.1.tar.gz
Size 572.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0c577a51987458e605d712d8dea1472046f42bad95be47cb4c20d1dccad5d0b2
BLAKE2b-256 checksum
How to use checksums
b54bd05f5f37c52142081f0eba4b4f2fff554c3cedb78987b96b678695f545b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.8

Release files / md2htmlify-0.0.1-py3-none-any.whl

Download URL md2htmlify-0.0.1-py3-none-any.whl
Size 579.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0a304be3a00e4c1f27f50b45d760eea8d6a0dc42111d46d0b239e21a6a0b0ea
BLAKE2b-256 checksum
How to use checksums
a682e51d22e433752b6e155e183883bdafdb6204cfb4da9f32c9ecae9a73ddb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.8

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page