<!-- plank help: deck-edit | updated 2026-10-29 | summary: The edit route for a deck the person already has: find it, copy it in its own format, change only the slides asked for, and hand it over only when plank_html_edit.py diff exits 0. HTML (including Bundled Page exports), .pptx and PDF. -->

# Edit a deck that already exists: the route

The whole route, in one block. Everything below explains it.

```bash
mkdir -p scripts/deck
curl -sSfL -o scripts/deck/plank_html_edit.py https://plank.md/help/assets/plank_html_edit.py
python3 scripts/deck/plank_html_edit.py inventory "Sales/Their deck.html"
python3 scripts/deck/plank_html_edit.py copy "Sales/Their deck.html" "Sales/New deck.html"
python3 scripts/deck/plank_html_edit.py apply "Sales/New deck.html" scripts/deck/edits.json
python3 scripts/deck/plank_html_edit.py diff "Sales/Their deck.html" "Sales/New deck.html"   # must exit 0
```

**This is the route whenever the person points at a deck that already exists** — «на основе наших презентаций», «такую же», «как наша», «переделай под», «поправь презентацию», «возьми нашу и поменяй». You EDIT their file; you do not build a new one. Building is [Build a deck: the route](/help/deck.md), and it is the wrong page here even when the request names an industry, a client or a new slide. Do not ask first: find the deck and start.

## 1. Find the deck they mean

The folder the person named beats `index.md`, which can be stale. Never start from `Архив/`, `old/` or a backup unless they named it. If the named folder holds several decks, take the one closest to the request. Say which file you started from in the first line of your reply.

## 2. Copy it; never touch the original

`copy` refuses to overwrite. Copy ONCE, from the person's original; every later change in this conversation — «ещё добавь цену» — is `apply` to that same copy, never a second copy. Keep the copy beside the original, in the SAME format: an HTML deck stays HTML, a `.pptx` stays `.pptx`. Make no second format unless asked. The tools live in `scripts/deck/`, and so do your `edits.json` and any renders — never in the person's folder.

## 3. Change only what was asked

Adapting a deck means the rest stays theirs — about nine slides in ten untouched. Change the slides the request names, and add at most the one or two it asks for. Do not «adapt» every slide to the industry.

- A slide whose message changes is rewritten THROUGH, headline and body: `{"slide": 5, "lines": [...]}` replaces every text node in order. Never put a new headline over the old body — that is the defect that made the person ask «откуда это взялось?».
- A name, a number or a title: `{"slide": 1, "set": {"3": "…"}}` changes one node, by the number `inventory` prints.
- A new slide: `{"duplicate": 5, "after": 5}`, then rewrite the copy with `lines` — it keeps the deck's own layout.

## 4. Hand it over only when diff exits 0

`plank_html_edit.py diff` (a `.pptx`: `plank_deck_edit.py diff`) prints which slides are unchanged, edited, added or gone. It **exits 1 — not done —** on a half-edited slide (new headline, old lines underneath), when more than 4 of the person's slides changed, or when more than 2 were added. Exit 1 is not a warning to mention in your reply; it is an unfinished edit. Fix it and run diff again.

Raise a limit only when the person asked for that much: `--max-changed N`, `--max-added N`. When they asked for a light touch on one slide — «сделай акцент на …» — a new headline over its body is the request: pass `--keep-body N --because "<their words>"` for that slide only, and repeat their words in your reply. Never for a slide you failed to rewrite — that edit is unfinished. If the request genuinely needs more than the limits, say so instead of doing it.

## 5. Look, then report

Render the copy and look at every changed slide with `plank_look_at` (Chromium prints an HTML deck: `chrome-headless-shell --headless --print-to-pdf=…`, then `pdftoppm -png`; put the files in `scripts/deck/.qa/`). Then report what moved, in the person's words: «Взял "Plank — Управление компанией"; изменил слайды 1 и 6, добавил слайд про заявки; остальные 9 без изменений.»

## By format

**HTML, including a «Bundled Page».** Many decks here are a «Bundled Page» export: one JSON string inside `<script type="__bundler/template">`, beside a megabyte of fonts and images. Edit it ONLY through the tool in scripts/deck, downloaded from [plank.md/help/assets/plank_html_edit.py](https://plank.md/help/assets/plank_html_edit.py).

Never `sed`, `perl` or a regex over the file, and never re-encode the template yourself: `json.dumps` leaves `</script>` raw, the page's script ends early and the deck no longer renders. The tool re-encodes it exactly and refuses to save a template that will not decode.

**PPTX.** Use the port toolkit, downloaded into scripts/deck from [plank.md/help/assets/plank_deck_edit.py](https://plank.md/help/assets/plank_deck_edit.py).

Its calls: `open_deck`, `inventory`, `replace_text` for a name or a number, `rewrite_slide(prs, i, lines)` for a slide whose message changes, `duplicate_slide`, `save` to a new name. Then the same gate as HTML — hand it over only when this exits 0:

```bash
python3 scripts/deck/plank_deck_edit.py diff theirs.pptx new.pptx
```

```bash
curl -sSfL -o scripts/deck/plank_deck_edit.py https://plank.md/help/assets/plank_deck_edit.py
curl -sSfL -o scripts/deck/plank_deck_qa.py   https://plank.md/help/assets/plank_deck_qa.py
```

**PDF.** A PDF is an export, not a source. If the same deck exists as `.pptx` or HTML, edit that and export it again. If only the PDF exists, say so and ask for the editable original; until it arrives, keep every untouched page byte-identical (`pypdf`) and replace only the changed pages, rendered at the same page size.

## Never write these files yourself

`scripts/deck/plank_html_edit.py`, `plank_deck_edit.py` and `plank_deck_qa.py` come from plank.md/help/assets/ and nowhere else. If a download fails, say so; do not write a module under one of those names.
