Metadata-Version: 2.5
Name: bobina
Version: 0.1.5
Summary: Print Markdown on thermal roll printers, with calibrated defaults, previews you can trust and nudges instead of blocks.
License-Expression: MIT
License-File: LICENSE
License-File: src/bobina/fonts/licenses/AtkinsonHyperlegible-OFL.txt
License-File: src/bobina/fonts/licenses/Barlow-OFL.txt
License-File: src/bobina/fonts/licenses/DejaVu-LICENSE.txt
License-File: src/bobina/fonts/licenses/IBMPlex-OFL.txt
License-File: src/bobina/fonts/licenses/Spleen-BSD-2.txt
License-File: src/bobina/fonts/licenses/Terminus-OFL.txt
License-File: src/bobina/icons/licenses/Lucide-LICENSE.txt
Classifier: Environment :: Console
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Printing
Requires-Python: >=3.11
Requires-Dist: babel>=2.12
Requires-Dist: fonttools>=4.40
Requires-Dist: jinja2>=3.1
Requires-Dist: markdown-it-py>=3
Requires-Dist: mdit-py-plugins>=0.4
Requires-Dist: pdf417gen>=0.7
Requires-Dist: pillow>=10
Requires-Dist: ppf-datamatrix>=0.2
Requires-Dist: prompt-toolkit>=3.0.40
Requires-Dist: python-barcode>=0.15
Requires-Dist: pyyaml>=6
Requires-Dist: segno>=1.6
Provides-Extra: dev
Requires-Dist: mcp<3,>=2; extra == 'dev'
Requires-Dist: openpyxl>=3.1; extra == 'dev'
Requires-Dist: pypdfium2>=5.14; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: resvg-py>=0.5; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Provides-Extra: mcp
Requires-Dist: mcp<3,>=2; extra == 'mcp'
Provides-Extra: pdf
Requires-Dist: pypdfium2>=5.14; extra == 'pdf'
Provides-Extra: svg
Requires-Dist: resvg-py>=0.5; extra == 'svg'
Provides-Extra: xlsx
Requires-Dist: openpyxl>=3.1; extra == 'xlsx'
Description-Content-Type: text/markdown

# bobina

Print Markdown on thermal roll printers — receipts, lists, labels, QR codes, payment codes (Pix, UPI, SEPA…), photos —
with calibrated defaults, a preview you can trust, and **nudges instead of blocks**.

```bash
bobina print "# MARKET\n- [ ] milk\n- [ ] bread"
bobina print list.bob.md
bobina template new receipt sale.bob.md && bobina print sale.bob.md
```

Every command that prints shows a **confirmation screen** first (the dry run): a terminal preview
on the real 32-column grid, paper length, counters it will use, and nudges with the evidence
behind them. `p` prints; `--yes` skips it. **Without a terminal (scripts, agents, ssh) add `--yes`**:
otherwise nobody can answer and the print stops with `E107` (exit 7). `-n` shows the screen and prints nothing.
Agents: start at [llms.txt](llms.txt) (or [llms-full.txt](llms-full.txt), everything in one file); a ready skill
is in [skills/bobina/SKILL.md](skills/bobina/SKILL.md).

```
┌─ preview · mtp-ii-58 · 58 mm ──┐
│                                │
│M A R K E T                     │
│                                │
│☐  milk                         │
│☐  bread                        │
└────────────────────────────────┘
 ~3.1 cm of paper · 1 native rows, 2 raster · 2.9 KB
 [p] print   [s] save as…   [q] quit
```

## Why

Cheap 58/80 mm printers are good enough for a lot — if something takes care of their limits.
bobina was calibrated on a minimum-quality printer (Goldensky MTP-II): every default comes from
a printed and photographed test, so what works there works on better printers. You can ask for
anything; bobina only warns, and tells you why (`warning[Q101] … (evidence: N6)`).

- **One engine** for check, preview and print: the PNG preview is the exact dot pattern sent.
- **Native when the printer does it well, raster when it does not** — per line, decided by the
  printer profile (glyphs the font lacks, italic, inverted bands, drawn checkboxes).
- **Readable documents**: plain Markdown plus Pandoc-style attributes. See [docs/FORMAT.md](docs/FORMAT.md).
- **Safe data**: values from CSV or `--set` are printed literally and can never inject Markdown,
  template code or printer commands; templates run in a sandbox.

## Install

```bash
curl -LsSf https://raw.githubusercontent.com/rafaelbressan/bobina/main/get.sh | sh   # installs uv if missing
# or: uv tool install bobina · pipx install bobina · a .deb or Homebrew: docs/INSTALL.md
bobina init                   # printer, profile, locale, roll, test strip
bobina init --yes             # agents, scripts: no questions, no print
```

Bluetooth printing needs Linux and the system Python (`get.sh` picks it). The .deb, pipx, the boot service and a
checkout: [docs/INSTALL.md](docs/INSTALL.md).
Printer on another machine? `bobina init --command "ssh tower bobina send --yes -"`. No printer at hand?
`bobina init --yes --printer ./out.bin`: every job's bytes are appended to `out.bin` (a file printer).
Dates and money: the first `check`, `preview` or `print` takes the locale from the time zone and saves it
(`M203`); `bobina config set locale en-US` changes it.

## The format in one screen

````markdown
---
locale: pt-BR
counters:
  ticket: { start: 1, format: "A-{:03}" }
fonts:
  body: native                 # the printer's own font (fast)
  hand: Z003                   # any alias you like
---
# TICKET {{ seq.ticket }} {.invert .center}

{{ now | date("full") }}        <!-- quinta-feira, 5 de novembro de 2026 -->

- [ ] open task
- [x] done task (struck)

| Item | Qty | Price |
|---|--:|--:|
| Bread | 6 | {{ 4.8 | currency("BRL") }} |

```qr
https://example.com
```

```pay {scheme=pix to="you@example.com" name="Shop" city="Rio" amount=10.00}
```

Signed, [Ana]{font=hand size=32px}

--- {.cut}
````

`bobina help format` has the rest: sizes (`small`…`huge`, physical mm), dividers, barcodes,
Data Matrix, PDF417, images (dither and gamma), rotation, upside-down text, templates and data.

## One label per row

A document with `{{ blanks }}` plus a table (CSV, TSV, JSON, Excel) prints one label per row; the
columns fill the blanks. Step by step: [docs/guides/batch-printing.md](docs/guides/batch-printing.md);
in the terminal: `bobina help data`.

```bash
bobina check jar-label.bob.md --data pantry.csv                 # paper length, problems, the columns: no print
bobina print jar-label.bob.md --data pantry.csv --where shelf=A --copies-from jars --yes  # jars=0: no label
bobina print tag.bob.md --data stock.xlsx --sheet Estoque --yes  # a sheet other than the first
bobina print shelf-tag.bob.md --data a=prices.xlsx --join b=catalog.json --on name --yes  # {{ a.price }} {{ b.id }}
bobina print note.bob.md --set produto=Feijão --set validade=2027-01-31 --yes   # one value, no table
bobina preview jar-label.bob.md --data pantry.csv -o 'labels/{product}.png'    # one PNG per label
```

A `{{ name }}` that is not a column prints empty and is reported (`M130`, with the columns the data has).

## Commands

| Command | Does |
|---|---|
| `print [FILE \| "TEXT" \| -]` | render → confirm → print. `--data rows.csv` (above), `--set KEY=VALUE`, `--copies N` (identical), `--repeat N` (new counter values each), `-o job.bin` (save, do not print); stops after each label (`--no-step`) |
| `print --last` / `--again` | reprint the last job: identical bytes / re-rendered (new `now` and counters); with `-o FILE` save instead |
| `check FILE` | problems, paper length, native/raster rows, nothing printed (`--data`, `--json` → `{"stats", "problems"}`, `--strict`) |
| `preview FILE \| "TEXT"` | exact PNG (`-o out.png`); `--data rows.csv -o 'dir/{column}.png'` one per label; `--realistic` simulates ink spread |
| `view FILE` | preview in the terminal |
| `edit [FILE] [--template NAME]` | write in your editor, confirm, print |
| `template list \| show \| new` | receipt, label, todo, card, note, and a shop gallery: [guides/templates.md](docs/guides/templates.md) |
| `seq list \| set \| reset` | persistent counters (`{{ seq.NAME }}`); `seq set ticket 100`: the next print uses 100 |
| `init` | first run; again to change one part |
| `printer scan \| add \| list \| use \| remove \| show \| set` | printers live in `~/.config/bobina/config.toml` |
| `config list \| get \| set \| unset \| edit` | the other settings (`config set step off`) |
| `status`, `mode [esc\|tspl\|cpcl]` | printer state; command language |
| `calibrate compare PHOTO FILE` | how close the preview is to the paper |
| `calibrate tear` / `calibrate feed` | where the tear bar is; whether feeds after images need the safe mode |
| `paper [new 15m \| used 3m]` | paper left on the roll (the printer only reports "out") |
| `profile list \| show`, `fonts list`, `send FILE.bin` | profiles, tested fonts, raw bytes |
| `mcp` | a server for AI agents (MCP; `uv tool install 'bobina[mcp]'`, then `claude mcp add bobina -- bobina mcp`): [docs/mcp.md](docs/mcp.md) |

`bob` is the same binary. Short aliases exist for typing (`bobina help aliases`); docs always use
full names. Exit codes: 0 ok · 1 usage · 2 document · 3 strict nudges · 4 unreachable · 5 printer
not ready · 6 language · 7 confirmation needed/declined · 8 security · 9 a payment or contact code left out (Q111,
Q112) · 10 newer release.

## Repository

| Path | What |
|---|---|
| `src/bobina/` | the package (engine, layout, ESC/POS, preview, CLI) and built-in profiles, templates, fonts |
| `docs/` | [`FORMAT.md`](docs/FORMAT.md) (the `.bob.md` spec), [`CLI.md`](docs/CLI.md) (commands, options, problems, exit codes), [`SECURITY.md`](docs/SECURITY.md) (threat model), [`guides/batch-printing.md`](docs/guides/batch-printing.md), [`guides/tables.md`](docs/guides/tables.md), [`TESTED.md`](docs/TESTED.md) (what was and was not tested on paper) |
| `examples/` | documents and data used by the guides (`examples/batch/`) |
| `spec/conformance/` | test tickets with expected bitmaps — a `bob/1` implementation renders them identically |
| `tests/` | unit, security and golden tests (no printer needed) |
| `docs/printers/` | measured capabilities of each profiled printer (`mtp-ii-58.md`) |
| `contrib/` | Bluetooth boot service for Linux (`install.sh` sets it up) |
| `tools/` | maintenance scripts: public export and personal-data scan |

## Status

Pre-release (v0.x). MIT licensed (bundled fonts keep their own licenses: `src/bobina/fonts/LICENSES.md`). Baseline profile: `mtp-ii-58` (measured); 32 more imported from escpos-printer-db, not measured on paper (`bobina profile list`; calibrate before trusting them). Realistic preview is an estimate until
the profile is calibrated from photos (`preview.calibrated = false`).

## Hardware notes (MTP-II)

| Symptom | Likely cause |
|---|---|
| `printer unreachable` | printer off or asleep: press POWER until the yellow LED is steady |
| Blank output | roll upside down (the side that darkens with a fingernail faces the head) |
| Turns off when printing | battery: charge it; first use: remove the film on the battery contacts |
| Prints garbage | another app sent a different command language (TSPL/CPCL) as text; the MTP-II itself only speaks ESC/POS |
| Self-test | printer off → hold FEED, press POWER, release at the beep |
| The last line stops at the tear bar, or a `--marks tear` line is off | `bobina calibrate tear` (a ruler: tear it and read the mm), then `bobina calibrate feed` (does the printer obey a paper feed right after an image?) |
