@dickpy/dsh-oil-slide 0.2.8 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  Oil Slide plugin for DeepSeek Harness. Review an outline, pick from 1–3 design samples, then download the image PPTX. Generate an editable PPTX separately when you need native text and shapes. The sidebar also includes the existing HTML preview and export tools.
4
4
 
5
- 在 DSH 右侧面板审阅大纲、选择实际设计稿、下载纯图版和按需生成可编辑版。「生图设置」支持自定义 API、多渠道、模型检测与备用顺序。[项目首页](../README.md)
5
+ 在 DSH 右侧面板审阅大纲、选择实际设计稿、下载纯图版和按需生成可编辑版。在「PPT 素材库」保存企业 Logo、产品图和参考演示文稿,大纲阶段选用。Logo 默认在每页右上角,可调整位置、大小和应用页面,可编辑版中能单独移动或替换。
6
+
7
+ 「生图设置」支持自定义 API、多渠道、模型检测与备用顺序。[项目首页](../README.md)
6
8
 
7
9
  ## Requirements
8
10
 
@@ -10,7 +10,7 @@ Create an outline JSON array in a new deck directory. Each entry needs `title` a
10
10
  "${W[@]}" outline --file /path/to/outline.json --ratio 16:9
11
11
  ```
12
12
 
13
- Show the actual outline with each page's title/content, ask for corrections, and ask how many **actual** design images to produce (1–3). Suggest a representative content page, not always the cover. No images or PPTX before explicit acceptance of both outline and count. If the user revises the outline, call `outline` again and request approval of the new revision. The DSH outline editor saves titles, content, page order and a brand preset directly. Read status before approving so edits from the panel are included. A preset is reusable on this host and is copied into the project when selected. Brand colors, typography, footer and optional PPT theme guide rendering. The logo and embedded PPT thumbnail, when available, travel as image references. For CLI use, `brand-list` returns preset IDs and `edit-outline --file edits.json` takes `{"revision":"<outlineRevision>","pages":[...],"brandId":"<preset id>"}` (null clears a preset). In DSH, use a single question with id `outlineQuestionId` if asking for outline approval. The panel displays the outline and count/page controls; after each state change, use the existing preview-open functionality when available, targeting this deck, or provide paths in hosts with no panel.
13
+ Show the actual outline with each page's title/content, ask for corrections, and ask how many **actual** design images to produce (1–3). Suggest a representative content page, not always the cover. No images or PPTX before explicit acceptance of both outline and count. If the user revises the outline, call `outline` again and request approval of the new revision. The DSH outline editor saves titles, content, page order and a brand preset directly. Read status before approving so edits from the panel are included. A preset is reusable on this host and is copied into the project when selected. Brand colors, typography, footer and optional PPT theme guide rendering. The PPT materials library accepts company logos, product or scene reference images, and reference decks. Reference images and an embedded PPT thumbnail can guide the image model. The workflow reserves space for the company logo and overlays it locally using the selected corner, size and page scope. Supply logo-free artwork when importing images. Editable reconstruction uses the clean slide artwork and restores the original logo as a separate PowerPoint picture. Saved projects retain a snapshot of the material kit. For CLI use, `brand-list` returns preset IDs and `edit-outline --file edits.json` takes `{"revision":"<outlineRevision>","pages":[...],"brandId":"<preset id>"}` (null clears a preset). In DSH, use a single question with id `outlineQuestionId` if asking for outline approval. The panel displays the outline and count/page controls; after each state change, use the existing preview-open functionality when available, targeting this deck, or provide paths in hosts with no panel.
14
14
 
15
15
  ```bash
16
16
  "${W[@]}" approve-outline --revision <current-outlineRevision> --count 3 --sample-page 2
@@ -17,9 +17,39 @@ def library():
17
17
  return (Path(config) if config else Path.home() / ".config") / "oil-slide/brands"
18
18
 
19
19
 
20
+ def read_preset(key):
21
+ if not isinstance(key, str) or not re.fullmatch("[a-f0-9]{32}", key):
22
+ raise ValueError("Unknown material kit")
23
+ return json.loads((library() / key / "brand.json").read_text(encoding="utf-8"))
24
+
25
+
26
+ def for_display(preset):
27
+ if "logo.png" not in preset["images"]:
28
+ return preset
29
+ from PIL import Image
30
+ with Image.open(library() / preset["id"] / "logo.png") as logo:
31
+ logo.thumbnail((128, 64))
32
+ data = BytesIO()
33
+ logo.save(data, "PNG")
34
+ return dict(preset, logoPreview="data:image/png;base64," + base64.b64encode(data.getvalue()).decode())
35
+
36
+
20
37
  def list_brands():
21
- return sorted([json.loads(f.read_text(encoding="utf-8")) for f in library().glob("[0-9a-f]*/brand.json")],
22
- key=lambda item: item["name"].casefold())
38
+ presets = [read_preset(f.parent.name) for f in library().glob("[0-9a-f]*/brand.json")]
39
+ replaced = {p.get("previousId") for p in presets}
40
+ return sorted((for_display(p) for p in presets if p["id"] not in replaced), key=lambda p: p["name"].casefold())
41
+
42
+
43
+ DEFAULT_LOGO = {"corner": "top-right", "size": "medium", "scope": "all"}
44
+ SIZES = {"small": 0.10, "medium": 0.14, "large": 0.18}
45
+
46
+
47
+ def logo_settings(value):
48
+ settings = {**DEFAULT_LOGO, **(value or {})}
49
+ if (settings["corner"] not in {"top-left", "top-right", "bottom-left", "bottom-right"} or
50
+ settings["size"] not in SIZES or settings["scope"] not in {"all", "cover", "body"}):
51
+ raise ValueError("Invalid logo placement")
52
+ return settings
23
53
 
24
54
 
25
55
  def materialize_asset(asset, workspace, dest, limit):
@@ -54,11 +84,44 @@ def save_brand(data, workspace):
54
84
  with tempfile.TemporaryDirectory(dir=root, prefix=".brand-") as tmp:
55
85
  folder = Path(tmp) / "preset"
56
86
  folder.mkdir()
87
+ previous = read_preset(data["baseId"]) if data.get("baseId") else {}
88
+ previous_dir = root / previous["id"] if previous else None
89
+ if previous:
90
+ preset["previousId"] = previous["id"]
91
+ if previous_dir and "logo.png" in previous["images"] and "logo" not in data:
92
+ shutil.copyfile(previous_dir / "logo.png", folder / "logo.png")
57
93
  if data.get("logo"):
58
94
  src = Path(tmp) / "logo"
59
95
  materialize_asset(data["logo"], workspace, src, 6 << 20)
60
96
  png_image(src, folder / "logo.png")
97
+ if (folder / "logo.png").is_file():
61
98
  preset["images"].append("logo.png")
99
+ preset["logoPlacement"] = logo_settings(data.get("logoPlacement", previous.get("logoPlacement")))
100
+ materials = data.get("materials", previous.get("materials", []))
101
+ if len(materials) > 4:
102
+ raise ValueError("Choose up to four reference images")
103
+ preset["materials"] = []
104
+ existing = {m["file"] for m in previous.get("materials", [])}
105
+ for index, item in enumerate(materials, 1):
106
+ file = f"material-{index}.png"
107
+ if item.get("asset"):
108
+ src = Path(tmp) / "material"
109
+ materialize_asset(item["asset"], workspace, src, 6 << 20)
110
+ png_image(src, folder / file)
111
+ elif item.get("file") in existing:
112
+ shutil.copyfile(previous_dir / item["file"], folder / file)
113
+ else:
114
+ raise ValueError("Unknown reference image")
115
+ preset["materials"].append({"file": file, "name": str(item["name"])[:120]})
116
+ preset["images"].append(file)
117
+ if previous.get("template") and "template" not in data:
118
+ for file in ("reference.pptx", "reference.png"):
119
+ if (previous_dir / file).is_file():
120
+ shutil.copyfile(previous_dir / file, folder / file)
121
+ if (folder / "reference.png").is_file():
122
+ preset["images"].append("reference.png")
123
+ preset["template"] = True
124
+ preset["templateStyle"] = previous.get("templateStyle", "")
62
125
  if data.get("template"):
63
126
  pptx = folder / "reference.pptx"
64
127
  materialize_asset(data["template"], workspace, pptx, 80 << 20)
@@ -83,7 +146,7 @@ def save_brand(data, workspace):
83
146
  preset["template"] = True
84
147
  (folder / "brand.json").write_text(json.dumps(preset, ensure_ascii=False), encoding="utf-8")
85
148
  folder.rename(root / preset["id"])
86
- return preset
149
+ return for_display(preset)
87
150
 
88
151
 
89
152
  def attach_brand(root, key):
@@ -98,14 +161,46 @@ def attach_brand(root, key):
98
161
  copied = Path(tmp) / "snapshot"
99
162
  shutil.copytree(library() / key, copied)
100
163
  copied.rename(target)
101
- return json.loads((target / "brand.json").read_text(encoding="utf-8"))
164
+ preset = json.loads((target / "brand.json").read_text(encoding="utf-8"))
165
+ if "logo.png" in preset["images"]:
166
+ preset.setdefault("logoPlacement", DEFAULT_LOGO)
167
+ return preset
102
168
 
103
169
 
104
- def brand_inputs(state):
170
+ def brand_inputs(state, number):
105
171
  brand = state.get("brand") or {}
106
172
  if not brand:
107
173
  return "", []
108
174
  detail = {k: brand[k] for k in ("name", "colors", "font", "footer", "templateStyle") if brand.get(k)}
109
- refs = [f"assets/brand-presets/{brand['id']}/{name}" for name in brand["images"]]
110
- return ("\nBrand guidelines (use exact footer; preserve logo proportions): " +
111
- json.dumps(detail, ensure_ascii=False) + ". Brand asset references: " + ", ".join(brand["images"])), refs
175
+ names = list(brand["images"])
176
+ hints = ""
177
+ if brand.get("logoPlacement"):
178
+ names.remove("logo.png")
179
+ hints = " Do not draw a logo or company wordmark. The original logo is added locally."
180
+ if applies(brand, number):
181
+ placement = brand["logoPlacement"]
182
+ hints += (f" Reserve the {placement['corner']} corner with quiet background, inset 3% on each axis, "
183
+ f"within {SIZES[placement['size']]:.0%} of slide width and {SIZES[placement['size']]/2:.0%} of height.")
184
+ labels = {m["file"]: m["name"] for m in brand.get("materials", [])}
185
+ detail["references"] = [labels.get(n, n) for n in names]
186
+ refs = [f"assets/brand-presets/{brand['id']}/{name}" for name in names]
187
+ return "\nBrand guidelines: " + json.dumps(detail, ensure_ascii=False) + hints, refs
188
+
189
+
190
+ def applies(brand, number):
191
+ placement = (brand or {}).get("logoPlacement")
192
+ if not placement:
193
+ return False
194
+ scope = placement["scope"]
195
+ return scope == "all" or (scope == "cover" and number == 1) or (scope == "body" and number > 1)
196
+
197
+
198
+ def logo_box(placement, canvas, logo_size):
199
+ width, height = canvas
200
+ size = SIZES[placement["size"]]
201
+ scale = min(width * size / logo_size[0], height * size / 2 / logo_size[1])
202
+ w, h = [max(1, round(n * scale)) for n in logo_size]
203
+ x, y = round(width * .03), round(height * .03)
204
+ corner = placement["corner"]
205
+ return (x if corner.endswith("left") else width - x - w,
206
+ y if corner.startswith("top") else height - y - h, w, h)
@@ -13,7 +13,7 @@ import sys
13
13
  import tempfile
14
14
  import uuid
15
15
  from types import SimpleNamespace
16
- from slide_brand import list_brands, save_brand, attach_brand, brand_inputs
16
+ from slide_brand import list_brands, save_brand, attach_brand, brand_inputs, applies, logo_box
17
17
 
18
18
 
19
19
  STATE = "slide-workflow.json"
@@ -100,6 +100,66 @@ def canvas_image(src, out, ratio):
100
100
  atomic_write(out, buf.getvalue())
101
101
 
102
102
 
103
+ def logo_file(root, brand):
104
+ return inside(root, f"assets/brand-presets/{brand['id']}/logo.png")
105
+
106
+
107
+ def clean_file(root, state, image, number):
108
+ if not applies(state.get("brand"), number):
109
+ return image
110
+ clean = inside(root, f"assets/logo-backgrounds/{digest(image)}.png")
111
+ need(clean.is_file(), f"Missing logo-free artwork for page {number}")
112
+ return clean
113
+
114
+
115
+ def place_logo(root, state, clean, out):
116
+ from io import BytesIO
117
+ from PIL import Image
118
+ brand = state["brand"]
119
+ with Image.open(clean) as page, Image.open(logo_file(root, brand)) as logo:
120
+ x, y, w, h = logo_box(brand["logoPlacement"], page.size, logo.size)
121
+ mark = logo.convert("RGBA").resize((w, h), Image.Resampling.LANCZOS)
122
+ merged = page.convert("RGB")
123
+ merged.paste(mark, (x, y), mark)
124
+ buf = BytesIO()
125
+ merged.save(buf, format="PNG")
126
+ data = buf.getvalue()
127
+ background = inside(root, f"assets/logo-backgrounds/{hashlib.sha256(data).hexdigest()}.png")
128
+ atomic_write(background, clean.read_bytes())
129
+ atomic_write(out, data)
130
+
131
+
132
+ def import_artwork(root, state, number, image, out):
133
+ if not applies(state.get("brand"), number):
134
+ canvas_image(image, out, state["ratio"])
135
+ return
136
+ with tempfile.TemporaryDirectory() as tmp:
137
+ clean = Path(tmp) / "normalized.png"
138
+ canvas_image(image, clean, state["ratio"])
139
+ place_logo(root, state, clean, out)
140
+
141
+
142
+ def native_logos(root, state, numbers, source, out):
143
+ """Stamp only newly reconstructed slides, before merging them into the user's file."""
144
+ from PIL import Image
145
+ from pptx import Presentation
146
+ brand = state.get("brand")
147
+ if not any(applies(brand, n) for n in numbers):
148
+ return source
149
+ pres = Presentation(source)
150
+ need(len(pres.slides) == len(numbers), "Editable conversion returned the wrong slide count")
151
+ logo = logo_file(root, brand)
152
+ canvas = CANVASES[state["ratio"]]
153
+ with Image.open(logo) as image:
154
+ box = logo_box(brand["logoPlacement"], canvas, image.size)
155
+ dims = [round(n * axis / px) for n, axis, px in zip(box, (pres.slide_width, pres.slide_height) * 2, canvas * 2)]
156
+ for slide, number in zip(pres.slides, numbers):
157
+ if applies(brand, number):
158
+ slide.shapes.add_picture(str(logo), *dims).name = f"{brand['name']} · Logo"
159
+ pres.save(out)
160
+ return out
161
+
162
+
103
163
  def assemble(root, state, pages, destination=IMAGE_PPTX):
104
164
  path = VENDOR / "codex-ppt" / "assemble_ppt.py"
105
165
  spec = importlib.util.spec_from_file_location("oil_codex_ppt_assemble", path)
@@ -136,7 +196,7 @@ def checked_pages(root, state):
136
196
  return ordered
137
197
 
138
198
 
139
- def check_editable(path, pages):
199
+ def check_editable(path, pages, clean_pages=None):
140
200
  from pptx import Presentation
141
201
  from pptx.enum.shapes import MSO_SHAPE_TYPE as Shape
142
202
  pres = Presentation(path)
@@ -155,9 +215,11 @@ def check_editable(path, pages):
155
215
  need(any((s.has_text_frame and s.text.strip())
156
216
  or (s.has_table and any(cell.text.strip() for cell in s.table.iter_cells()))
157
217
  for s in all_shapes), f"Page {number} has no native editable text")
158
- source_bytes = source.read_bytes()
218
+ forbidden = {digest(source)}
219
+ if clean_pages and clean_pages[number - 1] != source:
220
+ forbidden.add(digest(clean_pages[number - 1]))
159
221
  def original_picture(s):
160
- return s.shape_type == Shape.PICTURE and s.image.blob == source_bytes
222
+ return s.shape_type == Shape.PICTURE and hashlib.sha256(s.image.blob).hexdigest() in forbidden
161
223
  need(not any(original_picture(s) for s in all_shapes),
162
224
  f"Page {number} embeds the original slide image")
163
225
  return pres
@@ -263,11 +325,11 @@ Approved visual direction: {draft['style']}
263
325
  prompt += ("\nThe last reference is the previous version of THIS page. Preserve its content and "
264
326
  "unaffected details. Apply these user changes, which supersede earlier directions: "
265
327
  + revision["feedback"])
266
- return dict(prompt=prompt, reference=str(anchor), canvas=CANVASES[state["ratio"]])
328
+ return dict(prompt=prompt, reference=str(clean_file(root, state, anchor, state["samplePage"])), canvas=CANVASES[state["ratio"]])
267
329
 
268
330
 
269
- def provider_render(root, prompt, refs, state, out, a):
270
- brand_prompt, brand_refs = brand_inputs(state)
331
+ def provider_render(root, prompt, refs, state, out, a, page, *, overlay=True):
332
+ brand_prompt, brand_refs = brand_inputs(state, page)
271
333
  prompt += brand_prompt
272
334
  # Keep the style anchor first and the previously rendered page last.
273
335
  split = 1 if refs else 0
@@ -288,7 +350,10 @@ def provider_render(root, prompt, refs, state, out, a):
288
350
  need(source.is_file(), f"Missing reference image: {ref}")
289
351
  command += ["--image", str(source)]
290
352
  subprocess.run(command, check=True, stdout=sys.stderr, cwd=root)
291
- canvas_image(response, out, state["ratio"])
353
+ if overlay:
354
+ import_artwork(root, state, page, response, out)
355
+ else:
356
+ canvas_image(response, out, state["ratio"])
292
357
 
293
358
 
294
359
  def update(root, a):
@@ -367,13 +432,13 @@ def update(root, a):
367
432
  refs = a.ref
368
433
  if a.feedback:
369
434
  need(current, "Choose the design to revise first")
370
- refs = [old_image.relative_to(root), *refs]
435
+ refs = [clean_file(root, state, old_image, state["samplePage"]).relative_to(root), *refs]
371
436
  prompt += "\nEdit reference 1. Keep what was not requested to change. Feedback: " + a.feedback
372
- provider_render(root, prompt, refs, state, inside(root, path), a)
437
+ provider_render(root, prompt, refs, state, inside(root, path), a, state["samplePage"])
373
438
  elif a.cmd == "restore-draft":
374
439
  atomic_write(inside(root, path), source.read_bytes())
375
440
  else:
376
- canvas_image(a.image, inside(root, path), state["ratio"])
441
+ import_artwork(root, state, state["samplePage"], a.image, inside(root, path))
377
442
  entries = [x for x in state["candidates"] if x["number"] != a.number]
378
443
  hash_now = digest(inside(root, path))
379
444
  entries.append(dict(number=a.number, path=path, sha256=hash_now, style=style,
@@ -397,7 +462,9 @@ def update(root, a):
397
462
  state.update(stage="production", approved=draft, pages={str(sample): {"path":ref,"sha256":a.sha256}})
398
463
  elif a.cmd == "page-prompt":
399
464
  need(stage == "production", "Confirm a visual draft before producing pages")
400
- return production_prompt(root, state, a.number)
465
+ job = production_prompt(root, state, a.number)
466
+ guidelines, references = brand_inputs(state, a.number)
467
+ return dict(job, prompt=job["prompt"] + guidelines, materialReferences=references)
401
468
  elif a.cmd in {"add-page", "render-page"}:
402
469
  need(stage == "production", "Confirm a visual draft before recording final images")
403
470
  pending_pages = state.get("revisionsPending", {})
@@ -411,10 +478,10 @@ def update(root, a):
411
478
  refs = [Path(job["reference"]).relative_to(root), *a.ref]
412
479
  pending = state.get("revisionsPending", {}).get(str(a.number))
413
480
  if pending:
414
- refs.append(pending["previous"])
415
- provider_render(root, job["prompt"], refs, state, p, a)
481
+ refs.append(clean_file(root, state, inside(root, pending["previous"]), a.number).relative_to(root))
482
+ provider_render(root, job["prompt"], refs, state, p, a, a.number)
416
483
  else:
417
- canvas_image(a.image, p, state["ratio"])
484
+ import_artwork(root, state, a.number, a.image, p)
418
485
  state["pages"][str(a.number)] = dict(path=rel, sha256=digest(p))
419
486
  change = pending_pages.pop(str(a.number), None)
420
487
  if change and change.get("restyle"):
@@ -469,7 +536,7 @@ def update(root, a):
469
536
  x, y, right, bottom = a.box
470
537
  need(0 <= x < right <= 1000 and 0 <= y < bottom <= 1000, "Invalid region coordinates")
471
538
  from PIL import Image, ImageDraw
472
- source = checked_pages(root, state)[a.number - 1]
539
+ source = clean_file(root, state, checked_pages(root, state)[a.number - 1], a.number)
473
540
  proposal = uuid.uuid4().hex
474
541
  folder = inside(root, f"assets/region-edits/{proposal}")
475
542
  folder.mkdir(parents=True)
@@ -483,11 +550,17 @@ def update(root, a):
483
550
  generated = Path(tmp) / "generated.png"
484
551
  provider_render(root, "Edit the first full slide, keeping all elements aligned. The last image marks "
485
552
  "the edit area in red. Return the full slide without the red border. User feedback: " +
486
- a.feedback, [source.relative_to(root), guide_path.relative_to(root)], state, generated, a)
553
+ a.feedback, [source.relative_to(root), guide_path.relative_to(root)], state, generated, a, a.number, overlay=False)
487
554
  with Image.open(generated) as result:
488
555
  merged = original.convert("RGB")
489
556
  merged.paste(result.crop(box), box[:2])
490
- merged.save(folder / "candidate.png")
557
+ candidate = folder / "candidate.png"
558
+ if applies(state.get("brand"), a.number):
559
+ clean = Path(tmp) / "merged.png"
560
+ merged.save(clean)
561
+ place_logo(root, state, clean, candidate)
562
+ else:
563
+ merged.save(candidate)
491
564
  state["regionProposal"] = dict(id=proposal, number=a.number, revision=a.revision, box=a.box,
492
565
  feedback=a.feedback, sha256=digest(folder / "candidate.png"))
493
566
  elif a.cmd == "resolve-region":
@@ -509,7 +582,7 @@ def update(root, a):
509
582
  need(state.get("deckRevision") == rev + 1, "Proposal revision no longer active")
510
583
  if state["stage"] == "production":
511
584
  if str(page) not in state["pages"]:
512
- state = update(root, SimpleNamespace(cmd="add-page", number=page, image=candidate))
585
+ state = update(root, SimpleNamespace(cmd="add-page", number=page, image=clean_file(root, state, candidate, page)))
513
586
  state = update(root, SimpleNamespace(cmd="export-images"))
514
587
  del state["regionProposal"]
515
588
  elif a.cmd == "revise-pages":
@@ -566,10 +639,10 @@ def update(root, a):
566
639
  return dict(run=str(target), pages=0, changed=[], reused=len(pages), next=["editable-finalize"])
567
640
  if not (target / "deck_manifest.json").is_file():
568
641
  source = inside(root, IMAGE_PPTX)
569
- if plan:
570
- source = target.parent / "changed-input.pptx"
642
+ if plan or any(applies(state.get("brand"), n) for n in changed):
643
+ source = target.parent / "conversion-input.pptx"
571
644
  assemble(root, dict(state, outline=[state["outline"][n-1] for n in changed]),
572
- [pages[n-1] for n in changed], source)
645
+ [clean_file(root, state, pages[n-1], n) for n in changed], source)
573
646
  command = ["prepare", source, "--job-dir", target, "--serial-local"]
574
647
  command += ["--image-backend", "openai-compatible-api"]
575
648
  editppt(command)
@@ -593,6 +666,8 @@ def update(root, a):
593
666
  manifest = json.loads((target / "deck_manifest.json").read_text(encoding="utf-8"))
594
667
  result = inside(target.resolve(), manifest["output"])
595
668
  need(result.is_file(), "Converter did not produce an editable PPTX")
669
+ rebuilt = plan["changed"] if plan else list(range(1, len(pages)+1))
670
+ result = native_logos(root, state, rebuilt, result, Path(tmp) / "with-logos.pptx")
596
671
  staged = Path(tmp) / "result.pptx"
597
672
  if plan:
598
673
  base = inside(root, plan["base"])
@@ -601,7 +676,7 @@ def update(root, a):
601
676
  patch_native_slides(base, result, plan["changed"], staged)
602
677
  else:
603
678
  shutil.copyfile(result, staged)
604
- check_editable(staged, pages)
679
+ check_editable(staged, pages, [clean_file(root, state, p, n) for n, p in enumerate(pages, 1)])
605
680
  staged.replace(out)
606
681
  hashes = [state["pages"][str(n)]["sha256"] for n in range(1, len(pages)+1)]
607
682
  if plan and plan.get("hashes"):