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.2.tar.gz (68.0 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.2-py3-none-any.whl (76.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: laudo-0.1.2.tar.gz
  • Upload date:
  • Size: 68.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":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.2.tar.gz
Algorithm Hash digest
SHA256 9e249f3887a31c3a784796f7abbe083b4218d3356c63adb25ff4575fb6b47a97
MD5 df2caf5b1d0a0ce84a673e5ffe987678
BLAKE2b-256 fc581ab97cca0f9e3bcb933600ff61e1d0e4b1b7d3eb6c3624d2deb2792e1881

See more details on using hashes here.

File details

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

File metadata

  • Download URL: laudo-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 76.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fe4d823031913f08738563e2d7d9fade723068257b6e9ee3ecbbce72fb0c62b0
MD5 af50a766a0620056e50984bce3b203dc
BLAKE2b-256 7e058607df8e94afb0a61660f196a9d224d2bd50b3c48adddf693f284a9b0e07

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