Skip to main content

Python Markdown-to-HTML Server

It's the standard Python http.server module but via markdown-it-py, requested Markdown files are rendered and served as HTML

The http.server module's SimpleHTTPRequestHandler class is inherited by a new class with its do_GET method overridden. beautifulsoup and html5lib add <html>, <head>, & <body> elements and I insert a <style> element with some personally preferred CSS styling. Optionally, a custom CSS file can be used to style instead.
highlightjs adds syntax highlighting to code blocks.

It makes for a simple way to write up some Markdown with a terminal & a web browser

TIP: In most browsers, keyboard shortcut Ctrl+Shift+R will refresh the page and ignore cache

Installation

  • from PyPI: pip install httpmdhtml
  • from GitHub: pip install "git+https://github.com/treatmesubj/python-md-to-html-server"

Usage

Markdown-to-HTML Server

python -m httpmdhtml.server -b 127.0.0.1 -d . --css_file ../mystyle.css -l 5000
---
usage: server.py [-h] [--cgi] [--bind ADDRESS] [--directory DIRECTORY] [--css_file CSS_FILE]
                 [--live_md_rr LIVE_MD_RR]
                 [port]

positional arguments:
  port                  Specify alternate port [default: 8000]

optional arguments:
  -h, --help            show this help message and exit
  --cgi                 Run as CGI Server
  --bind ADDRESS, -b ADDRESS
                        Specify alternate bind address [default: all interfaces]
  --directory DIRECTORY, -d DIRECTORY
                        Specify alternative directory [default:current directory]
  --css_file CSS_FILE   css-file-path whose content will be written to the <style> element. Can be "none"; do not
                        use any css
  --live_md_rr LIVE_MD_RR, -l LIVE_MD_RR
                        Continuous refresh rate of MD page, in ms. Respects cache

Markdown-to-HTML Out-File

python -m httpmdhtml.md_to_html -i in_file.md -o out_file.html --encode_local_images
---
usage: md_to_html.py [-h] [--in_file_path IN_FILE_PATH] [--out_file_path OUT_FILE_PATH] [--encode_local_images]
                     [--css_file CSS_FILE]

optional arguments:
  -h, --help            show this help message and exit
  --in_file_path IN_FILE_PATH, -i IN_FILE_PATH
                        in-file-path; your existing markdown file
  --out_file_path OUT_FILE_PATH, -o OUT_FILE_PATH
                        out-file-path; your HTML file to be created
  --encode_local_images, -e
                        in HTML, embed base64-encoded data of local images linked to in your markdown; remove
                        dependency on presence of external local images
  --css_file CSS_FILE   css-file-path whose content will be written to the <style> element. Can be "none"; do not
                        use any css

Metadata

Release files for httpmdhtml 0.1.4

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

Source distribution (sdist)

Source distribution for httpmdhtml 0.1.4
File Size Uploaded
httpmdhtml-0.1.4.tar.gz 17.9 kB Details

Built distribution (wheel)

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

Total release size: 36.4 kB

Release files / httpmdhtml-0.1.4.tar.gz

Download URL httpmdhtml-0.1.4.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
db95f48629e7ec03950ac374939755d1cfe789d2459a51887f8bc7bda697cf01
BLAKE2b-256 checksum
How to use checksums
abb53c82a4d42b1e8ddc99c8decd151e18acd5de1d0727068ff4b925d9b3c803
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / httpmdhtml-0.1.4-py3-none-any.whl

Download URL httpmdhtml-0.1.4-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
408a335655b417e7c9fb8f7b1f59d7a92feac7493a4a7c1f73dab8ffde708a38
BLAKE2b-256 checksum
How to use checksums
c9ad638022f5cd6aea0cdddaad8a199584b387c96bdf1b1a125b51acdb89b016
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

1 release file

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