blob: 10e49cac772dfac0f8ce1cc4865fb90f39d7553e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# likha-pdf
a simple web app that converts markdown to pdf.
<img width="1280" height="800" alt="likha-pdf screenshot" src="https://github.com/user-attachments/assets/578b8410-53ad-4323-a45a-19ae3aabe61d" />
> this project originally started as a way for me to learn NimLang, but I found it useful enough that I decided to rewrite it in Python for easier personal maintenance 😅
> the original Nim source files are still available in the `__legacy_src` directory
## features
- markdown to pdf export
- image upload with markdown snippet insertion
- paper size, margin, font, line spacing, and page number options
- syntax-highlighted code blocks
- always produces a pdf (reportlab fallback if weasyprint fails)
## requirements
- python 3.10+
- system packages: `libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 shared-mime-info`
- gunicorn (installed from `requirements.txt`)
## image usage
1. upload an image from the page
2. click `insert into markdown`
3. generate pdf
## run
### local
```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cd src/
python3 app.py
```
### production (vps + nginx)
```bash
cd src/
../.venv/bin/gunicorn \
--bind 127.0.0.1:5001 \
--worker-class gthread \
--workers 1 \
--threads 2 \
--timeout 240 \
--graceful-timeout 30 \
--keep-alive 5 \
--max-requests 300 \
--max-requests-jitter 50 \
--access-logfile - \
--error-logfile - \
app:app
```
nginx should reverse proxy to `127.0.0.1:5001` and pass:
- `X-Forwarded-For`
- `X-Forwarded-Proto`
- `X-Forwarded-Host`
### docker
```bash
docker build -t likha-pdf .
docker run -p 5001:5001 likha-pdf
```
open `http://localhost:5001`
|