Skip to content

Commit 87ae1a9

Browse files
committed
v0.1.4
1 parent 502f8d7 commit 87ae1a9

File tree

4 files changed

+62
-61
lines changed

4 files changed

+62
-61
lines changed

README.md

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,60 @@
1-
# Python Markdown-to-HTML Server
2-
3-
It's the standard Python [http.server module](https://docs.python.org/3/library/http.server.html) but via [markdown-it-py](https://github.com/executablebooks/markdown-it-py), requested Markdown files are rendered and served as HTML
4-
5-
The `http.server` module's `SimpleHTTPRequestHandler` class is inherited by a new class with its `do_GET` method overridden. [beautifulsoup](https://pypi.org/project/beautifulsoup4/) and [html5lib](https://pypi.org/project/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.
6-
7-
It makes for a simple way to write up some Markdown with a terminal & a web browser
8-
9-
**TIP**: In most browsers, keyboard shortcut `Ctrl+Shift+R` will refresh the page and ignore cache
10-
11-
## Installation
12-
- from [PyPI](https://pypi.org/project/httpmdhtml/): `pip install httpmdhtml`
13-
- from [GitHub](https://github.com/treatmesubj/python-md-to-html-server): `pip install "git+https://github.com/treatmesubj/python-md-to-html-server"`
14-
15-
## Usage
16-
### Markdown-to-HTML Server
17-
```
18-
python -m httpmdhtml.server -b 127.0.0.1 -d . --css_file ../mystyle.css -l 5000
19-
---
20-
usage: server.py [-h] [--cgi] [--bind ADDRESS] [--directory DIRECTORY] [--css_file CSS_FILE]
21-
[--live_md_rr LIVE_MD_RR]
22-
[port]
23-
24-
positional arguments:
25-
port Specify alternate port [default: 8000]
26-
27-
optional arguments:
28-
-h, --help show this help message and exit
29-
--cgi Run as CGI Server
30-
--bind ADDRESS, -b ADDRESS
31-
Specify alternate bind address [default: all interfaces]
32-
--directory DIRECTORY, -d DIRECTORY
33-
Specify alternative directory [default:current directory]
34-
--css_file CSS_FILE css-file-path whose content will be written to the <style> element. Can be "none"; do not
35-
use any css
36-
--live_md_rr LIVE_MD_RR, -l LIVE_MD_RR
37-
Continuous refresh rate of MD page, in ms. Respects cache
38-
```
39-
40-
### Markdown-to-HTML Out-File
41-
```
42-
python -m httpmdhtml.md_to_html -i in_file.md -o out_file.html --encode_local_images
43-
---
44-
usage: md_to_html.py [-h] [--in_file_path IN_FILE_PATH] [--out_file_path OUT_FILE_PATH] [--encode_local_images]
45-
[--css_file CSS_FILE]
46-
47-
optional arguments:
48-
-h, --help show this help message and exit
49-
--in_file_path IN_FILE_PATH, -i IN_FILE_PATH
50-
in-file-path; your existing markdown file
51-
--out_file_path OUT_FILE_PATH, -o OUT_FILE_PATH
52-
out-file-path; your HTML file to be created
53-
--encode_local_images, -e
54-
in HTML, embed base64-encoded data of local images linked to in your markdown; remove
55-
dependency on presence of external local images
56-
--css_file CSS_FILE css-file-path whose content will be written to the <style> element. Can be "none"; do not
57-
use any css
58-
```
59-
![](<./scrot.png>)
1+
# Python Markdown-to-HTML Server
2+
3+
It's the standard Python [http.server module](https://docs.python.org/3/library/http.server.html) but via [markdown-it-py](https://github.com/executablebooks/markdown-it-py), requested Markdown files are rendered and served as HTML
4+
5+
The `http.server` module's `SimpleHTTPRequestHandler` class is inherited by a new class with its `do_GET` method overridden. [beautifulsoup](https://pypi.org/project/beautifulsoup4/) and [html5lib](https://pypi.org/project/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.\
6+
[highlightjs](https://highlightjs.org) adds syntax highlighting to code blocks.
7+
8+
It makes for a simple way to write up some Markdown with a terminal & a web browser
9+
10+
**TIP**: In most browsers, keyboard shortcut `Ctrl+Shift+R` will refresh the page and ignore cache
11+
12+
## Installation
13+
- from [PyPI](https://pypi.org/project/httpmdhtml/): `pip install httpmdhtml`
14+
- from [GitHub](https://github.com/treatmesubj/python-md-to-html-server): `pip install "git+https://github.com/treatmesubj/python-md-to-html-server"`
15+
16+
## Usage
17+
### Markdown-to-HTML Server
18+
```
19+
python -m httpmdhtml.server -b 127.0.0.1 -d . --css_file ../mystyle.css -l 5000
20+
---
21+
usage: server.py [-h] [--cgi] [--bind ADDRESS] [--directory DIRECTORY] [--css_file CSS_FILE]
22+
[--live_md_rr LIVE_MD_RR]
23+
[port]
24+
25+
positional arguments:
26+
port Specify alternate port [default: 8000]
27+
28+
optional arguments:
29+
-h, --help show this help message and exit
30+
--cgi Run as CGI Server
31+
--bind ADDRESS, -b ADDRESS
32+
Specify alternate bind address [default: all interfaces]
33+
--directory DIRECTORY, -d DIRECTORY
34+
Specify alternative directory [default:current directory]
35+
--css_file CSS_FILE css-file-path whose content will be written to the <style> element. Can be "none"; do not
36+
use any css
37+
--live_md_rr LIVE_MD_RR, -l LIVE_MD_RR
38+
Continuous refresh rate of MD page, in ms. Respects cache
39+
```
40+
41+
### Markdown-to-HTML Out-File
42+
```
43+
python -m httpmdhtml.md_to_html -i in_file.md -o out_file.html --encode_local_images
44+
---
45+
usage: md_to_html.py [-h] [--in_file_path IN_FILE_PATH] [--out_file_path OUT_FILE_PATH] [--encode_local_images]
46+
[--css_file CSS_FILE]
47+
48+
optional arguments:
49+
-h, --help show this help message and exit
50+
--in_file_path IN_FILE_PATH, -i IN_FILE_PATH
51+
in-file-path; your existing markdown file
52+
--out_file_path OUT_FILE_PATH, -o OUT_FILE_PATH
53+
out-file-path; your HTML file to be created
54+
--encode_local_images, -e
55+
in HTML, embed base64-encoded data of local images linked to in your markdown; remove
56+
dependency on presence of external local images
57+
--css_file CSS_FILE css-file-path whose content will be written to the <style> element. Can be "none"; do not
58+
use any css
59+
```
60+
![](<./skrot.png>)

scrot.png

-756 KB
Binary file not shown.

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
setup(
88
name="httpmdhtml",
9-
version="0.1.3",
9+
version="0.1.4",
1010
license="gpl-3.0",
1111
author="John Hupperts",
1212
author_email="[email protected]",
1313
description="HTTP server that converts markdown to HTML",
1414
long_description=long_description,
1515
long_description_content_type="text/markdown",
1616
url="https://github.com/treatmesubj/python-md-to-html-server",
17-
download_url="https://github.com/treatmesubj/python-md-to-html-server/archive/refs/tags/v0.1.3.tar.gz",
17+
download_url="https://github.com/treatmesubj/python-md-to-html-server/archive/refs/tags/v0.1.4.tar.gz",
1818
packages=["httpmdhtml"],
1919
package_dir={"python-md-to-html-server": "httpmdhtml"},
2020
project_urls={

skrot.png

979 KB
Loading

0 commit comments

Comments
 (0)