Git Product home page Git Product logo

python-md-to-html-server's Introduction

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

python-md-to-html-server's People

Contributors

treatmesubj avatar

Stargazers

Mad Scientist avatar Christian W. avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

rashidovich2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.