Metadata-Version: 2.3
Name: laudo
Version: 0.2.4
Summary: Generate forensic report using docxtpl templates
Author: renatormc
Author-email: renatormc <renatomartinsrmc@gmail.com>
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Legal Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Office Suites
Requires-Dist: beautifulsoup4>=4.14.3
Requires-Dist: docxtpl[subdoc]>=0.20.2
Requires-Dist: inquirer>=3.4.1
Requires-Dist: piexif>=1.1
Requires-Dist: pillow>=10.0
Requires-Dist: pyside6>=6.6
Requires-Dist: python-dateutil>=2.9.0.post0
Requires-Dist: python-docx-replace>=0.4.4
Requires-Python: >=3.13
Project-URL: Homepage, https://github.com/renatormc/laudo
Project-URL: Repository, https://github.com/renatormc/laudo
Project-URL: Issues, https://github.com/renatormc/laudo/issues
Description-Content-Type: text/markdown

# laudo

Convert markdown files to **docx** or **pdf** using `docxtpl` templates.

## Installation

The recommended way to install the `laudo` CLI is with [pipx](https://pipx.pypa.io/), which installs it in an isolated environment and puts the command on your `PATH`.

Requires **Python 3.13+** and **LibreOffice** (only for PDF output).

### 1. Install pipx

Ubuntu/Debian:

```bash
sudo apt update
sudo apt install pipx
pipx ensurepath
```

Arch Linux:

```bash
sudo pacman -S python-pipx
pipx ensurepath
```

macOS (Homebrew):

```bash
brew install pipx
pipx ensurepath
```

Windows (PowerShell):

```powershell
py -m pip install --user pipx
py -m pipx ensurepath
```

Restart your terminal afterwards so the `PATH` change takes effect. For other systems, see the [pipx installation guide](https://pipx.pypa.io/stable/installation/).

### 2. Install laudo

From PyPI:

```bash
pipx install laudo
```

A specific version:

```bash
pipx install laudo==0.2.3
```

The latest code from GitHub:

```bash
pipx install git+https://github.com/renatormc/laudo.git
```

From a local clone, in editable mode (code changes take effect without reinstalling):

```bash
git clone https://github.com/renatormc/laudo.git
pipx install --editable ./laudo
```

If Python 3.13+ is not your default interpreter, point pipx at it:

```bash
pipx install --python python3.13 laudo
```

Check the installation:

```bash
laudo --help
```

### 3. Upgrade or uninstall

```bash
pipx upgrade laudo                # upgrade to the latest release
pipx install --force laudo        # reinstall (e.g. after switching source)
pipx uninstall laudo
```

`pipx list` shows the installed version and the Python interpreter in use.

> To use the [Python API](#python-api) from your own code, install `laudo` into that project's virtual environment instead (e.g. `uv add laudo` or `pip install laudo`).

## Usage

### CLI

```bash
laudo gen [--dir <folder>] [--debug] [--pdf] [--output <path>] [--template <path>]
laudo captions [--dir <folder>]
laudo template <name> [--dir <folder>]
laudo vars [--dir <folder>]
laudo init <name> [--dir <folder>]
laudo reduce-images <source> <dest> [--max <pixels>]
laudo install
```

### Python API

```python
from laudo import convert

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

### Reducing images

`laudo reduce-images` shrinks images so that neither side exceeds the chosen size (aspect ratio is kept):

```bash
laudo reduce-images fotos/ fotos_small/          # folder -> folder (recursive)
laudo reduce-images report.docx report.docx      # images embedded in a .docx/.odt
laudo reduce-images report.docx small.docx --max 600
```

Without `--max`, an interactive list lets you pick the size (default 450px).

## Input Folder Structure

```
my_project/
├── template.docx          # docxtpl template with Jinja2 placeholders
├── fotos/                 # Images (captions edited via GUI)
│   ├── image1.png
│   └── events/
│       └── party.jpg
├── context.txt            # (optional) Variables one per line: key = value
├── intro.md               # One or more .md files
└── chapter-1.md
```

### Template

A standard Word document using [docxtpl](https://github.com/elapouya/python-docxtpl) syntax with Jinja2 placeholders like `{{ variable }}` or `{{p intro|markdown }}`.

To use a template from a shared folder, create `.laudo/.template` with the template name and set the `LAUDOS_TEMPLATES_FOLDER` environment variable.

### context.txt

Optional file with variables in `key = value` format, one per line. Lines starting with `#` and empty lines are ignored. These variables are available for substitution inside `.md` files via `{{ varname }}`.

### Markdown files

Every `.md` file is read and its content is injected as a template variable named after the filename (without extension, spaces → underscores):

| File | Template variable |
|---|---|
| `intro.md` | `intro` |
| `chapter 1.md` | `chapter_1` |

Inside markdown files you can reference context variables with `{{ varname }}` and embed image groups with `image_group(name, cols)`.

### Images

All images in `fotos/` (including subdirectories) are available as the `pics` variable in templates. Use `pics.group("events")` to get images from a subfolder, or `pics.all` for all images. Captions are edited via the `laudo captions` GUI.

### Template helpers

- `{{p variable\|markdown }}` — render markdown as formatted docx content
- `{{p subdoc("file.docx", key=val) }}` — embed a sub-template
- `{{p image("fotos/logo.png", width=50) }}` — inline image with size control

## License

MIT
