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.6.tar.gz (19.1 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.6-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: laudo-0.1.6.tar.gz
  • Upload date:
  • Size: 19.1 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.6.tar.gz
Algorithm Hash digest
SHA256 bb98c930fda766a3b47c597d01a880464233f0084c40c7a9ce956e3a4deb2802
MD5 3ff726ca81121cfa407e4ee386db21b9
BLAKE2b-256 8cf7efcdea487a64225b1e647a91e2d1219b682994243049eabc311dafe35777

See more details on using hashes here.

File details

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

File metadata

  • Download URL: laudo-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 25.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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 390d3d3728392ff380420746b2bf3d9696c33a4caa588fbd552c2080e0d1626e
MD5 185b6690ef28a25b8540b1c905dfdfa9
BLAKE2b-256 2b92f63a089157cad476bcde8852b20e31902c9871a6aded4a8fa5a56d7bae65

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