Lightweight Markup to PDF Builder
lwm2pdf is a Python script for building lightweight markup content into styled PDFs via
WeasyPrint.
To install:
pip install lwm2pdf
Basic usage:
lwm2pdf -i myfile.adoc --open y
Requirements
See pyproject.toml for Python requirements. For optimal asciidoc conversion, I strongly recommend that you install some version of Asciidoctor for asciidoc conversion, but a port of the original asciidoc converter is used as a backup.
Supported Filetypes
Currently, lwm2pdf supports the following filetypes:
- Asciidoc (.adoc or .asciidoc)
- Markdown (.md)
Options
| Option | Description | Required? |
|---|---|---|
-i, --input |
The file to convert (full or relative path) | True |
-o, --output |
Output filename and destination (optional) | False |
-od,--output-dir |
Output directory and destination (optional); not recommended for use with the -o option |
False |
-s, --stylesheet |
Select user stylesheet (css) (optional) | False |
-p, --preserve-buildfiles |
Preserve buildfiles in output/src in current working directory or buildfile directory | False |
-b',--buildfile-dir |
Destination for buildfile(s) directory | False |
-rsp',--run-smartypants |
Run smartpants on resultant HTML |
False |
--open |
"y" or "n" to automatically open or not open the pdf (doesn't ask) | 'ask' |
Stylesheets and Themes
A "manuscript" stylesheet is provided and selected as default.
Known Issues
Some known issues include:
- Table handling is not the best
- All footnotes are rendered as end notes (this is a constraint from WeasyPrint)
- Markdown support is spotty
- Code highlighting is not working as expected
- Image URIs have to be absolute paths for Weasyprint to process them successfully. The script will take care of that...eventually.
Release Notes
v.0.1.4
- Add option to run
smartypantsfor nicer quotes and things
v.0.1.3
- Add description for pypy page
v.0.1.2
- First release to pypi
- Includes many more tests (~82% coverage)
- Removes handling of smart quotes due to bugs (noted for future development)
- Move to a Poetry-based workflow
Metadata
Release files for lwm2pdf 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lwm2pdf-0.1.4.tar.gz | 12.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lwm2pdf-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.4 kB
Release files / lwm2pdf-0.1.4.tar.gz
| Download URL | lwm2pdf-0.1.4.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8b4394a6a39b9b999758226a402db1a833044e6ad216add0409810bce77bbf9
|
|
BLAKE2b-256 checksum How to use checksums |
c7af7605732c4d748aa4374ba0457613ea6a5f444c68aee01e2ad985c16c67c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / lwm2pdf-0.1.4-py3-none-any.whl
| Download URL | lwm2pdf-0.1.4-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f7ee03f6b1748f60be6b455d4ad3aaf09bfdbc9db8539bf4ea68cd00b7e81e7b
|
|
BLAKE2b-256 checksum How to use checksums |
82898b9fb3797504f004be7f2c40566b38bc58df6a0b82926af79c4876701642
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|