Skip to main content

A Python package that converts Markdown to HTML using Tailwind CSS 4 for styling.

Project description

md2html-tailwind4

A Python package that converts Markdown to clean, styled HTML using Tailwind CSS 4 utilities and semantic theme tokens.

Designed for projects that render HTML inside a Tailwind-powered frontend (Django, FastAPI, static sites, etc.).

Features

  • Converts Markdown to HTML with Tailwind CSS 4 classes and DaisyUI-compatible semantic tokens (base-*, primary, secondary-*)
  • Configurable font size scale (sm, base, lg)
  • Abbreviations (abbr) with dotted underline tooltip
  • Definition lists (dl/dt/dd)
  • Footnotes ([^1] syntax)
  • Admonition callout boxes (!!! note, !!! warning, !!! danger, etc.) with color-coded Tailwind styling
  • Inline/block math parsing via pymdownx.arithmatex (e.g. $\\rightarrow$) with automatic MathJax loader injection
  • Heading anchor IDs auto-generated via toc extension
  • List items immediately following a paragraph (no blank line) render correctly
  • Responsive tables with overflow scrolling
  • Audio table support (3-column tables with media URLs become interactive audio players)
  • Automatically escapes Django template delimiters ({{ }}, {% %}) inside code blocks
  • External links get target="_blank" and rel="noopener noreferrer" automatically
  • Dark mode support via Tailwind's dark: variants
  • CLI tool included

Installation

pip install md2html-tailwind4

To style semantic tokens correctly, compile the provided stylesheet in your app:

npm install
npm run tailwind:build

Usage

Python API

from md2html_tailwind4 import Converter

# font_size: 'sm' | 'base' (default) | 'lg'
converter = Converter(font_size='sm')
html = converter.convert_md_to_html("# Hello\n\nThis is **Markdown**.")
print(html)

Command Line

md2html input.md output.html

# Use a smaller font size
md2html input.md output.html --font-size sm

Font Size Scales

Scale Heading 1 Body text Code block
sm text-xltext-3xl text-sm text-xs
base (default) text-2xltext-4xl text-base text-sm
lg text-3xltext-5xl text-lg text-base

HTML Output & Integration

The generated HTML is production-ready with:

  • Tailwind CSS 4 + DaisyUI token-based classes already applied
  • MathJax 3 automatically injected when math expressions detected
  • Dark mode support via dark: variants
  • Responsive design for all elements
  • Security hardening (Django template escaping, external link attributes)

See HTML_HANDLING.md for detailed integration guides with Django, FastAPI, and more.

Math Support

Format math expressions with $...$ or \(...\):

Pricing: $4.99 \rightarrow $14.99
Physics: $E=mc^2$
Formula: \[\sum_{i=1}^{n} x_i\]

Smart normalization handles split expressions:

  • $4.99 \rightarrow $14.99$4.99 \rightarrow 14.99$
  • MathJax loaded automatically when needed

Requirements

  • Python >= 3.11

License

MIT — White Neuron Co., Ltd.

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

md2html_tailwind4-1.5.2.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

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

md2html_tailwind4-1.5.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file md2html_tailwind4-1.5.2.tar.gz.

File metadata

  • Download URL: md2html_tailwind4-1.5.2.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for md2html_tailwind4-1.5.2.tar.gz
Algorithm Hash digest
SHA256 c4f41372ede3801e9fd03f23ab836c3ab443a3010b39bb5cdb5a8af722d6b3b0
MD5 746694524fbbe37c9a5d1a423520f79a
BLAKE2b-256 283f501cfa61ce212e865631e58ebe78004dab853eaee677437739677ee0bda0

See more details on using hashes here.

Provenance

The following attestation bundles were made for md2html_tailwind4-1.5.2.tar.gz:

Publisher: python-publish.yml on White-Neuron/md2html-tailwind4

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file md2html_tailwind4-1.5.2-py3-none-any.whl.

File metadata

File hashes

Hashes for md2html_tailwind4-1.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b51756a928d9c73ed20a9e54e6919b1451739a62b9a159e9e8626d42200603c4
MD5 68873b504412639bb912f07adcff950d
BLAKE2b-256 86df2edb8e0ca5a8c04ac55ab19db58a3de75d5cf3fe6a454385e75ceb823423

See more details on using hashes here.

Provenance

The following attestation bundles were made for md2html_tailwind4-1.5.2-py3-none-any.whl:

Publisher: python-publish.yml on White-Neuron/md2html-tailwind4

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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