|
lino
8491d531fa
All checks were successful
/ test (push) Successful in 7s
|
||
|---|---|---|
| .forgejo/workflows | fix: remove app user and make output dir variable | |
| lib | init | |
| .dockerignore | init | |
| .gitignore | init | |
| .python-version | init | |
| Dockerfile | fix: remove app user and make output dir variable | |
| pyproject.toml | feat: add command to update all translation files | |
| README.md | fix: style readme img | |
| run.py | chore: change naming to booklet | |
| uv.lock | feat: add command to update all translation files | |
| watch.sh | feat: add watcher script | |
Printer
Radarini
Printer helps you to generate beautifully styled PDF booklets from your MD-file input.
Features:
- ✅ Manage content in Markdown files
- ✅ Style with CSS
- ✅ Translate with PO-files
- ❌ Load additional remote content using placeholders
Run
You can run the printer in various ways, as described below.
Regardless of how the printer is executed, it is always important to set the CONTENT_DIR environment variable.
(See configuration for more details.)
Further commands will be displayed in the help text of the executed printer.
A: Python
- Install the python dependencies with uv
uv sync && source .venv/bin/activate - Install pandoc (Tested with version 3.1.11.1).
- Run the script
python run.py.
B: Docker
To run with docker execut the following.
docker run \
--volume $CONTENT_DIR:/root/content \
-e CONTENT_DIR="/root/content" \
codeberg.org/radarini/printer:latest \
uv run run.py
C: Pipeline
You can easily integrate the docker image in your CI-pipelines. For a gitlab reference see the Mutual Aid - Berlin Survival Guide.
D: Watch
For easy editing there is a watch script that regenerates the PDFs automatically on file change.
This could be executed with Docker or Python. Run bash watch.sh to start the watcher.
The package inotifywait is required.
Configure
The printer expects the following file structure with CONTENT_DIR as the root.
If this variable is not set, it falls back to the current directory.
CONTENT_DIR/
├─ code/
│ ├─ template.html
│ ├─ static/
│ │ ├─ style.css
├─ translations/
├─ 1_first_chapter.md
├─ 2_second_chapter.md
│ ...
You could use an other structure, by setting the path for the files explicitly. See run.py for a list of available variables.
Style
There are two files to define the style of the generated PDFs.
template.html- A jinja2 template to generate the transitional HTML file. The stringTitleand the listChaptersare available vars in the context of the template.style.css- The CSS file for styling. To generate PDFs from HTML weasyprint is used. See the weasyprint samples for reference.
Translate
Translations are managed with gettext in PO-files. You can edit them with tools like poedit or weblate. You always need a POT-file as basis. See the printer help text for commands to create this file.
Attribution
- Logo by Szczepanska/toicon.com