Skip to main content

Takes a variety of lighweight markup files and returns PDFs styled with provided css (via WeasyPrint)

Project description

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
--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.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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lwm2pdf-0.1.3.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

lwm2pdf-0.1.3-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file lwm2pdf-0.1.3.tar.gz.

File metadata

  • Download URL: lwm2pdf-0.1.3.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.3 Darwin/20.6.0

File hashes

Hashes for lwm2pdf-0.1.3.tar.gz
Algorithm Hash digest
SHA256 916964ac07f92e6f59bbca29db18dbb921e182ee2e2847d233470819e303c2af
MD5 9541910b84d6045d8165e0d5e5ff6a86
BLAKE2b-256 976dac19809568c250175f19512feff466cb83373c34b602d7b19921bd935a8d

See more details on using hashes here.

File details

Details for the file lwm2pdf-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: lwm2pdf-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.3 Darwin/20.6.0

File hashes

Hashes for lwm2pdf-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f18821c73c701d39a409fc9465e975f347f5cf7d5ec98f1bf827710e21e4b273
MD5 ebce9729f4b02c97ccf7857035400550
BLAKE2b-256 0888dd0744dcb7534e39801a17db2f8159921ca355d558b43611506ed15ca0b3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page