Skip to main content

Generate forensic report using docxtpl templates

Project description

laudo

Convert markdown files to docx or pdf using docxtpl templates and LibreOffice headless.

Installation

pip install laudo

Requires Python 3.13+ and LibreOffice installed system-wide for PDF output.

Usage

CLI

laudo <folder> <output>
  • <folder> — directory with your project files.
  • <output> — output file (.docx or .pdf).

Python API

from laudo import convert

convert("my_project/", "output.docx")
convert("my_project/", "output.pdf")

Input Folder Structure

my_project/
├── template.docx          # docxtpl template with Jinja2 placeholders
├── fotos/                 # Images with captions (EXIF)
│   ├── logo.png
│   └── photo.jpg
├── context.txt            # (optional) Variables one per line
├── intro.md               # One or more .md files
└── chapter-1.md

template.docx

A standard Word document using docxtpl syntax. Use Jinja2 placeholders like {{ variable }} or {{p intro|markdown }}.

context.txt

Optional file with variables in key = value format, one per line:

author = John Doe
title = My Document

Lines starting with # and empty lines are ignored.

These variables are also available for substitution inside your .md files (see below).

Markdown files

Every .md file is read and its content is injected into the template context. The variable name is the filename without extension (whitespace replaced by underscores):

File Context key
intro.md intro
chapter 1.md chapter_1

You can use {{ varname }} inside .md files to reference values from context.txt:

context.txt:

name = John Doe

intro.md:

# Hello {{ name }}

The result will be # Hello John Doe, then stored in context key intro.

Use the subdoc global function to embed .docx files from the assets/ folder:

{{p subdoc("cover.docx") }}

Use the markdown filter in your template:

{{p intro|markdown }}

Fotos

All image files inside fotos/ are listed in the pics context variable:

{
  "logo": {"path": "fotos/logo.png", "caption": "", "thumb": "fotos/.thumbs/logo_thumb.jpg", "reduced": "fotos/.thumbs/logo_reduced.jpg"},
  "photo": {"path": "fotos/photo.jpg", "caption": "", "thumb": "fotos/.thumbs/photo_thumb.jpg", "reduced": "fotos/.thumbs/photo_reduced.jpg"}
}

Captions are read from EXIF ImageDescription metadata.

PDF Output

When the output path ends with .pdf, a docx is generated first and then converted to PDF via LibreOffice headless:

laudo my_project/ output.pdf

The intermediate docx file is automatically removed.

License

MIT

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

laudo-0.1.5.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

laudo-0.1.5-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file laudo-0.1.5.tar.gz.

File metadata

  • Download URL: laudo-0.1.5.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for laudo-0.1.5.tar.gz
Algorithm Hash digest
SHA256 9c64fa9e8c35d80634e95f1898b56cb4ef2832695e4060257cf354c71dd5e646
MD5 2105c2a1b0e738d2b92984b51ec87f14
BLAKE2b-256 63449cee2c1c0ea567fd00a367e9e7edf30ef96803f3c1b8974103a2ef903635

See more details on using hashes here.

File details

Details for the file laudo-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: laudo-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for laudo-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fe2978e6d618975040be16a3f1a73f225dba36d81213c17a08dff4abc3342827
MD5 73030c30655212f080e56b64ce35e440
BLAKE2b-256 933bef8cc3f6f52867ec896e0fd4403cc911a70c8e3f8ee314ac7fb06fce078b

See more details on using hashes here.

Supported by

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