@iasiv5/dsh-skills 1.3.4 → 1.3.6

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.
Files changed (85) hide show
  1. package/README.md +1 -0
  2. package/package.json +3 -4
  3. package/skills/answer-me-with-html/SKILL.md +3 -3
  4. package/skills/answer-me-with-html/references/video.md +1 -0
  5. package/skills/answer-me-with-html/scripts/am.mjs +1671 -1131
  6. package/skills/code-review/results.tsv +6 -0
  7. package/skills/code-review/test-prompts.json +63 -10
  8. package/skills/darwin-skill/README.md +136 -121
  9. package/skills/darwin-skill/README_EN.md +138 -123
  10. package/skills/darwin-skill/SKILL.md +256 -421
  11. package/skills/darwin-skill/_archive/hero-2.0.gif +0 -0
  12. package/skills/darwin-skill/assets/banner-en.svg +1 -1
  13. package/skills/darwin-skill/assets/banner.svg +2 -2
  14. package/skills/darwin-skill/assets/chart-loop-en.html +2 -2
  15. package/skills/darwin-skill/assets/chart-loop-en.png +0 -0
  16. package/skills/darwin-skill/assets/chart-loop.html +2 -2
  17. package/skills/darwin-skill/assets/chart-loop.png +0 -0
  18. package/skills/darwin-skill/assets/chart-phases-en.html +12 -12
  19. package/skills/darwin-skill/assets/chart-phases-en.png +0 -0
  20. package/skills/darwin-skill/assets/chart-phases.html +13 -13
  21. package/skills/darwin-skill/assets/chart-phases.png +0 -0
  22. package/skills/darwin-skill/assets/darwin-3.0-launch.mp4 +0 -0
  23. package/skills/darwin-skill/assets/hero.gif +0 -0
  24. package/skills/darwin-skill/assets/result-card-example.png +0 -0
  25. package/skills/darwin-skill/docs/index.html +93 -357
  26. package/skills/darwin-skill/references/about-author.md +101 -0
  27. package/skills/darwin-skill/references/eval-protocol.md +156 -0
  28. package/skills/darwin-skill/references/skilllens-evidence.md +2 -1
  29. package/skills/darwin-skill/references/v3-evidence.md +114 -0
  30. package/skills/darwin-skill/scripts/darwin.py +400 -0
  31. package/skills/darwin-skill/scripts/screenshot.mjs +3 -2
  32. package/skills/darwin-skill/showcase.html +93 -357
  33. package/skills/darwin-skill/templates/result-card.html +36 -20
  34. package/skills/darwin-skill/templates/result-card.png +0 -0
  35. package/skills/darwin-skill/test-prompts.json +36 -12
  36. package/skills/docx/SKILL.md +5 -4
  37. package/skills/docx/scripts/office/helpers/__init__.py +22 -4
  38. package/skills/docx/scripts/office/helpers/pptx_chart.py +124 -11
  39. package/skills/docx/scripts/office/helpers/pptx_slide.py +43 -3
  40. package/skills/docx/scripts/office/soffice.py +85 -1
  41. package/skills/docx/scripts/office/validate.py +50 -7
  42. package/skills/docx/scripts/office/validators/base.py +16 -4
  43. package/skills/docx/scripts/office/validators/docx.py +59 -6
  44. package/skills/docx/scripts/office/validators/pptx.py +116 -8
  45. package/skills/docx/scripts/office/validators/redlining.py +292 -113
  46. package/skills/impeccable/SKILL.md +4 -2
  47. package/skills/impeccable/reference/adapt.md +1 -1
  48. package/skills/impeccable/reference/animate.md +17 -0
  49. package/skills/impeccable/reference/critique-rubric.md +496 -0
  50. package/skills/impeccable/reference/critique.md +12 -504
  51. package/skills/impeccable/reference/degraded/documenter.md +1 -1
  52. package/skills/impeccable/reference/degraded/motion-reviewer.md +29 -0
  53. package/skills/impeccable/reference/document.md +3 -1
  54. package/skills/impeccable/reference/foundations.md +44 -0
  55. package/skills/impeccable/reference/hooks.md +3 -3
  56. package/skills/impeccable/reference/live-setup.md +1 -1
  57. package/skills/impeccable/reference/live.md +26 -12
  58. package/skills/impeccable/reference/new-work-comp.md +24 -0
  59. package/skills/impeccable/reference/new-work-world.md +20 -0
  60. package/skills/impeccable/reference/new-work.md +6 -34
  61. package/skills/impeccable/reference/typeset.md +6 -0
  62. package/skills/impeccable/reference/visualize.md +1 -1
  63. package/skills/impeccable/scripts/VERSION +1 -1
  64. package/skills/impeccable/scripts/engine-checksums.txt +5 -5
  65. package/skills/impeccable/scripts/live-browser.js +51 -22
  66. package/skills/pdf/{forms.md → FORMS.md} +1 -1
  67. package/skills/pdf/{reference.md → REFERENCE.md} +3 -2
  68. package/skills/xlsx/SKILL.md +19 -14
  69. package/skills/xlsx/scripts/office/helpers/__init__.py +22 -4
  70. package/skills/xlsx/scripts/office/helpers/pptx_chart.py +124 -11
  71. package/skills/xlsx/scripts/office/helpers/pptx_slide.py +43 -3
  72. package/skills/xlsx/scripts/office/soffice.py +85 -1
  73. package/skills/xlsx/scripts/office/validate.py +50 -7
  74. package/skills/xlsx/scripts/office/validators/base.py +16 -4
  75. package/skills/xlsx/scripts/office/validators/docx.py +59 -6
  76. package/skills/xlsx/scripts/office/validators/pptx.py +116 -8
  77. package/skills/xlsx/scripts/office/validators/redlining.py +292 -113
  78. package/skills/xlsx/scripts/recalc.py +731 -136
  79. package/skills-manifest.json +1 -1
  80. /package/skills/darwin-skill/{assets → _archive}/chart-ratchet-en.html +0 -0
  81. /package/skills/darwin-skill/{assets → _archive}/chart-ratchet-en.png +0 -0
  82. /package/skills/darwin-skill/{assets → _archive}/chart-ratchet.html +0 -0
  83. /package/skills/darwin-skill/{assets → _archive}/chart-ratchet.png +0 -0
  84. /package/skills/darwin-skill/{templates → _archive}/result-card-dark.html +0 -0
  85. /package/skills/darwin-skill/{templates → _archive}/result-card-white.html +0 -0
@@ -14,6 +14,7 @@ Auto-repair fixes:
14
14
  """
15
15
 
16
16
  import argparse
17
+ import shlex
17
18
  import sys
18
19
  import tempfile
19
20
  import zipfile
@@ -22,17 +23,34 @@ from pathlib import Path
22
23
  import defusedxml.ElementTree as ET
23
24
  from defusedxml.common import DefusedXmlException
24
25
 
25
- from helpers import OOXML_FAMILY, rezip, safe_extract
26
+ from helpers import OOXML_FAMILY, folder_entries, rezip, safe_extract
26
27
  from validators import DOCXSchemaValidator, PPTXSchemaValidator, RedliningValidator
27
28
 
28
29
  WORD_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
29
30
 
30
31
 
32
+ def _as_argument(path: Path) -> str:
33
+ name = str(path)
34
+ return shlex.quote("./" + name if name.startswith("-") else name)
35
+
36
+
37
+ def _count(folders: list[str]) -> str:
38
+ return "1 folder entry" if len(folders) == 1 else f"{len(folders)} folder entries"
39
+
40
+
31
41
  def _fail(message: str):
32
42
  print(f"Error: {message}", file=sys.stderr)
33
43
  sys.exit(2)
34
44
 
35
45
 
46
+ def _unpack(package: Path, dest: Path):
47
+ try:
48
+ with zipfile.ZipFile(package, "r") as zf:
49
+ safe_extract(zf, dest)
50
+ except Exception as e:
51
+ _fail(f"cannot unpack {package}: {e}")
52
+
53
+
36
54
  def _has_tracked_changes(unpacked_dir: Path) -> bool:
37
55
  document = unpacked_dir / "word" / "document.xml"
38
56
  if not document.is_file():
@@ -95,6 +113,8 @@ def main():
95
113
  _fail(f"{original_file} is not a file")
96
114
  if original_file.suffix.lower() not in OOXML_FAMILY:
97
115
  _fail(f"{original_file} must be one of: {', '.join(sorted(OOXML_FAMILY))}")
116
+ with tempfile.TemporaryDirectory() as scratch:
117
+ _unpack(original_file, Path(scratch))
98
118
 
99
119
  family = OOXML_FAMILY.get((original_file or path).suffix.lower())
100
120
  if family is None:
@@ -111,11 +131,7 @@ def main():
111
131
  packed_file = path
112
132
  temp_dir_ctx = tempfile.TemporaryDirectory()
113
133
  unpacked_dir = Path(temp_dir_ctx.name)
114
- try:
115
- with zipfile.ZipFile(path, "r") as zf:
116
- safe_extract(zf, unpacked_dir)
117
- except (zipfile.BadZipFile, ValueError, OSError) as e:
118
- _fail(f"cannot unpack {path}: {e}")
134
+ _unpack(path, unpacked_dir)
119
135
  else:
120
136
  if not path.is_dir():
121
137
  _fail(f"{path} is not a directory or Office file")
@@ -150,16 +166,43 @@ def main():
150
166
  print(f"Error: Validation not supported for file type {family}")
151
167
  sys.exit(1)
152
168
 
169
+ folders = folder_entries(packed_file) if packed_file is not None else []
170
+
171
+ unsaved_repairs = 0
153
172
  if args.auto_repair:
154
173
  total_repairs = sum(v.repair() for v in validators)
155
174
  if total_repairs:
156
175
  print(f"Auto-repaired {total_repairs} issue(s)")
157
- if packed_file is not None:
176
+ if packed_file is not None and (total_repairs or folders):
177
+ try:
158
178
  rezip(unpacked_dir, packed_file)
179
+ except OSError as e:
180
+ unsaved_repairs = total_repairs
181
+ left = []
182
+ if total_repairs:
183
+ left.append(f"{total_repairs} repair(s) not saved")
184
+ if folders:
185
+ left.append(f"{_count(folders)} in its ZIP")
186
+ print(f"Could not write {packed_file} ({e.strerror or e}): it is as it was, "
187
+ f"with {' and '.join(left)}. Run --auto-repair on a copy in a folder "
188
+ "you can write to.")
189
+ else:
190
+ if folders:
191
+ print(f"Removed {_count(folders)} from the ZIP")
159
192
  print(f"Wrote repaired file to {packed_file}")
193
+ elif folders:
194
+ print(
195
+ f"Note: {_count(folders)} in the ZIP. Such files have failed to open or co-edit "
196
+ f"through a cloud service. Remove them: zip -dq {_as_argument(packed_file)} '*/'"
197
+ )
160
198
 
161
199
  success = all([v.validate() for v in validators])
162
200
 
201
+ if unsaved_repairs:
202
+ print(f"FAILED - {packed_file} was not rewritten and still has the {unsaved_repairs} "
203
+ "issue(s) repaired above; the checks ran on a repaired copy")
204
+ success = False
205
+
163
206
  if temp_dir_ctx is not None:
164
207
  temp_dir_ctx.cleanup()
165
208
 
@@ -2,6 +2,7 @@
2
2
  Base validator with common validation logic for document files.
3
3
  """
4
4
 
5
+ import os
5
6
  import re
6
7
  from pathlib import Path
7
8
 
@@ -10,7 +11,7 @@ from functools import lru_cache
10
11
 
11
12
  import lxml.etree
12
13
 
13
- from helpers import safe_extract
14
+ from helpers import names_another_root, safe_extract
14
15
 
15
16
 
16
17
  @lru_cache(maxsize=None)
@@ -352,6 +353,9 @@ class BaseSchemaValidator:
352
353
  if target and not target.startswith(
353
354
  ("http", "mailto:")
354
355
  ):
356
+ if names_another_root(target.lstrip("/")):
357
+ broken_refs.append((target, rel.sourceline))
358
+ continue
355
359
  if target.startswith("/"):
356
360
  target_path = self.unpacked_dir / target.lstrip("/")
357
361
  elif rels_file.name == ".rels":
@@ -360,9 +364,18 @@ class BaseSchemaValidator:
360
364
  base_dir = rels_dir.parent
361
365
  target_path = base_dir / target
362
366
 
367
+ target_path = Path(os.path.normpath(target_path))
368
+ if not target_path.is_relative_to(self.unpacked_dir):
369
+ broken_refs.append((target, rel.sourceline))
370
+ continue
371
+
363
372
  try:
364
373
  target_path = target_path.resolve()
365
- if target_path.exists() and target_path.is_file():
374
+ if (
375
+ target_path.is_relative_to(self.unpacked_dir)
376
+ and target_path.exists()
377
+ and target_path.is_file()
378
+ ):
366
379
  referenced_files.add(target_path)
367
380
  all_referenced_files.add(target_path)
368
381
  else:
@@ -783,8 +796,7 @@ class BaseSchemaValidator:
783
796
  try:
784
797
  schema = _load_schema(str(schema_path))
785
798
 
786
- with open(xml_file, "r") as f:
787
- xml_doc = lxml.etree.parse(f)
799
+ xml_doc = lxml.etree.parse(str(xml_file))
788
800
 
789
801
  xml_doc, _ = self._remove_template_tags_from_text_nodes(xml_doc)
790
802
  xml_doc = self._preprocess_for_mc_ignorable(xml_doc)
@@ -6,12 +6,13 @@ import random
6
6
  import re
7
7
  import tempfile
8
8
  import zipfile
9
+ from collections import Counter
9
10
  from pathlib import Path
10
11
 
11
12
  import defusedxml.minidom
12
13
  import lxml.etree
13
14
 
14
- from helpers import safe_extract
15
+ from helpers import one_line, safe_extract
15
16
 
16
17
  from .base import BaseSchemaValidator
17
18
 
@@ -62,6 +63,9 @@ class DOCXSchemaValidator(BaseSchemaValidator):
62
63
  if not self.validate_comment_markers():
63
64
  all_valid = False
64
65
 
66
+ if not self.validate_style_ids():
67
+ all_valid = False
68
+
65
69
  self.compare_paragraph_counts()
66
70
 
67
71
  return all_valid
@@ -264,7 +268,9 @@ class DOCXSchemaValidator(BaseSchemaValidator):
264
268
 
265
269
  for xml_file in self.xml_files:
266
270
  try:
267
- for elem in lxml.etree.parse(str(xml_file)).iter():
271
+ tree = lxml.etree.parse(str(xml_file))
272
+ is_numbering = lxml.etree.QName(tree.getroot()).localname == "numbering"
273
+ for elem in tree.iter():
268
274
  if val := elem.get(para_id_attr):
269
275
  try:
270
276
  if self._parse_id_value(val, base=16) >= 0x80000000:
@@ -278,7 +284,7 @@ class DOCXSchemaValidator(BaseSchemaValidator):
278
284
  )
279
285
 
280
286
  if val := elem.get(durable_id_attr):
281
- if xml_file.name == "numbering.xml":
287
+ if is_numbering:
282
288
  try:
283
289
  if self._parse_id_value(val, base=10) >= 0x7FFFFFFF:
284
290
  errors.append(
@@ -288,7 +294,7 @@ class DOCXSchemaValidator(BaseSchemaValidator):
288
294
  except ValueError:
289
295
  errors.append(
290
296
  f" {xml_file.name}:{elem.sourceline}: "
291
- f"durableId={val} must be decimal in numbering.xml"
297
+ f"durableId={val} must be decimal in a numbering part"
292
298
  )
293
299
  else:
294
300
  try:
@@ -308,11 +314,58 @@ class DOCXSchemaValidator(BaseSchemaValidator):
308
314
  if errors:
309
315
  print(f"FAILED - {len(errors)} ID constraint violations:")
310
316
  for e in errors:
311
- print(e)
317
+ print(one_line(e, 300))
312
318
  elif self.verbose:
313
319
  print("PASSED - All paraId/durableId values within constraints")
314
320
  return not errors
315
321
 
322
+ def _repeated_style_ids(self, styles_root) -> set[str]:
323
+ attr = f"{{{self.WORD_2006_NAMESPACE}}}styleId"
324
+ ids = Counter(s.get(attr) for s in styles_root.iter(f"{{{self.WORD_2006_NAMESPACE}}}style"))
325
+ return {i for i, n in ids.items() if i is not None and n > 1}
326
+
327
+ def _original_part(self, xml_file) -> bytes | None:
328
+ if self.original_file is None:
329
+ return None
330
+ name = xml_file.relative_to(self.unpacked_dir).as_posix()
331
+ try:
332
+ with zipfile.ZipFile(self.original_file) as zf:
333
+ return zf.read(name)
334
+ except (KeyError, OSError, zipfile.BadZipFile):
335
+ return None
336
+
337
+ def validate_style_ids(self):
338
+ errors = []
339
+ styles_tag = f"{{{self.WORD_2006_NAMESPACE}}}styles"
340
+ if self.original_file is None:
341
+ return True
342
+
343
+ for xml_file in self.xml_files:
344
+ try:
345
+ root = lxml.etree.parse(str(xml_file)).getroot()
346
+ if root.tag != styles_tag:
347
+ continue
348
+ repeated = self._repeated_style_ids(root)
349
+ original = self._original_part(xml_file) if repeated else None
350
+ if original is not None:
351
+ repeated -= self._repeated_style_ids(lxml.etree.fromstring(original))
352
+ except lxml.etree.XMLSyntaxError:
353
+ continue
354
+ errors.extend(
355
+ f" {xml_file.relative_to(self.unpacked_dir)}: style id {style_id!r:.40} is now "
356
+ f"defined more than once, and Word uses only the last definition, without "
357
+ f"warning. Delete the earlier ones"
358
+ for style_id in sorted(repeated)
359
+ )
360
+
361
+ if errors:
362
+ print(f"FAILED - Found {len(errors)} style id(s) defined more than once:")
363
+ for error in errors:
364
+ print(one_line(error, 300))
365
+ elif self.verbose:
366
+ print("PASSED - The edit defined no style id a second time")
367
+ return not errors
368
+
316
369
  def validate_comment_markers(self):
317
370
  errors = []
318
371
 
@@ -415,7 +468,7 @@ class DOCXSchemaValidator(BaseSchemaValidator):
415
468
  try:
416
469
  content = xml_file.read_text(encoding="utf-8")
417
470
  dom = defusedxml.minidom.parseString(content)
418
- is_numbering = xml_file.name == "numbering.xml"
471
+ is_numbering = dom.documentElement.localName == "numbering"
419
472
  base = 10 if is_numbering else 16
420
473
  pending = []
421
474
  seen_in_file = set()
@@ -63,6 +63,9 @@ class PPTXSchemaValidator(BaseSchemaValidator):
63
63
  if not self.validate_master_theme_uniqueness():
64
64
  all_valid = False
65
65
 
66
+ if not self.validate_tags():
67
+ all_valid = False
68
+
66
69
  if not self.validate_charts():
67
70
  all_valid = False
68
71
 
@@ -87,6 +90,30 @@ class PPTXSchemaValidator(BaseSchemaValidator):
87
90
  if p.is_file()
88
91
  }
89
92
 
93
+ @staticmethod
94
+ def _print_line(text: str, limit: int) -> None:
95
+ from helpers import one_line
96
+
97
+ print(one_line(text, limit))
98
+
99
+ def _listed_slides(self) -> set[str] | None:
100
+ import lxml.etree
101
+
102
+ from helpers import SLIDE_REL_TYPE
103
+
104
+ r_id = f"{{{self.OFFICE_RELATIONSHIPS_NAMESPACE}}}id"
105
+ try:
106
+ pres = lxml.etree.parse(str(self.unpacked_dir / "ppt" / "presentation.xml"))
107
+ rels = lxml.etree.parse(str(self.unpacked_dir / "ppt" / "_rels" / "presentation.xml.rels"))
108
+ listed = {e.get(r_id) for e in pres.iter(f"{{{self.PRESENTATIONML_NAMESPACE}}}sldId")}
109
+ return {
110
+ opc_target(rel.get("Target", ""), "ppt/presentation.xml", rel.get("TargetMode", ""))
111
+ for rel in rels.getroot()
112
+ if rel.get("Id") in listed and rel.get("Type") == SLIDE_REL_TYPE
113
+ }
114
+ except (OSError, ValueError, lxml.etree.XMLSyntaxError):
115
+ return None
116
+
90
117
  def validate_master_theme_uniqueness(self):
91
118
  from helpers.pptx_theme import _NOTES_MASTERS, live_shared_master_themes
92
119
 
@@ -94,7 +121,7 @@ class PPTXSchemaValidator(BaseSchemaValidator):
94
121
  if shared:
95
122
  print(f"FAILED - Found {len(shared)} master(s) sharing a theme part:")
96
123
  for message in shared:
97
- print(f" {message}")
124
+ self._print_line(f" {message}", 300)
98
125
  if any(m.startswith(_NOTES_MASTERS) for m in shared):
99
126
  print(" Fix: in ppt/presentation.xml, move <p:notesMasterIdLst> back to "
100
127
  "directly after <p:sldIdLst>. PowerPoint reads that happily.")
@@ -106,6 +133,64 @@ class PPTXSchemaValidator(BaseSchemaValidator):
106
133
  print("PASSED - No master shares a theme part in a way PowerPoint refuses")
107
134
  return True
108
135
 
136
+ def validate_tags(self):
137
+ from collections import Counter
138
+
139
+ import lxml.etree
140
+
141
+ ns = {"p": self.PRESENTATIONML_NAMESPACE, "mc": self.MC_NAMESPACE}
142
+ r_id = f"{{{self.OFFICE_RELATIONSHIPS_NAMESPACE}}}id"
143
+ errors = []
144
+ owners: dict[str, list[str]] = {}
145
+ listed = self._listed_slides()
146
+
147
+ for slide in sorted(self.unpacked_dir.glob("ppt/slides/*.xml")):
148
+ relative = slide.relative_to(self.unpacked_dir).as_posix()
149
+ if listed is not None and relative not in listed:
150
+ continue
151
+ try:
152
+ root = lxml.etree.parse(str(slide)).getroot()
153
+ named = [t.get(r_id) for t in root.xpath(
154
+ ".//p:tags[not(ancestor::mc:Fallback) and not(ancestor::mc:Choice[preceding-sibling::mc:Choice])]",
155
+ namespaces=ns)]
156
+ rels_file = slide.parent / "_rels" / f"{slide.name}.rels"
157
+ targets = {
158
+ rel.get("Id"): opc_target(rel.get("Target", ""), relative, rel.get("TargetMode", ""))
159
+ for rel in lxml.etree.parse(str(rels_file)).getroot()
160
+ if rel.get("Type", "").endswith("/relationships/tags")
161
+ } if rels_file.is_file() else {}
162
+ except (lxml.etree.XMLSyntaxError, ValueError):
163
+ continue
164
+ for rid, count in sorted(Counter(r for r in named if r).items()):
165
+ if count > 1:
166
+ errors.append(
167
+ f" {relative[:80]}: {count} <p:tags> elements name the tags relationship "
168
+ f"{rid!r:.20}. Fix: a copied shape kept its <p:custDataLst>; delete that "
169
+ f"from the copy, or give it a tags part and relationship of its own"
170
+ )
171
+ if targets.get(rid):
172
+ owners.setdefault(targets[rid], []).append(relative)
173
+
174
+ for part, slides in sorted(owners.items()):
175
+ if len(slides) > 1:
176
+ named_from = sorted(set(slides))
177
+ more = f" and {len(named_from) - 3} more" if len(named_from) > 3 else ""
178
+ errors.append(
179
+ f" {part[:80]}: {len(slides)} tags relationships name it, from "
180
+ f"{', '.join(s[:60] for s in named_from[:3])}{more}. Fix: copy the part under a new name, add "
181
+ f"its Override to [Content_Types].xml and point every relationship but one at a copy of its own "
182
+ f"(add_slide.py does this when it duplicates a slide)"
183
+ )
184
+
185
+ if errors:
186
+ print(f"FAILED - Found {len(errors)} tags part(s) with more than one owner; PowerPoint offers to repair the deck:")
187
+ for error in errors:
188
+ self._print_line(error, 700)
189
+ return False
190
+ if self.verbose:
191
+ print("PASSED - Every tags part has one owner")
192
+ return True
193
+
109
194
  def validate_charts(self):
110
195
  from helpers.pptx_chart import find_chart_problems
111
196
 
@@ -113,7 +198,7 @@ class PPTXSchemaValidator(BaseSchemaValidator):
113
198
  if problems:
114
199
  print(f"FAILED - Found {len(problems)} chart problem(s) PowerPoint rejects:")
115
200
  for message in problems:
116
- print(f" {message}")
201
+ self._print_line(f" {message}", 600)
117
202
  return False
118
203
 
119
204
  if self.verbose:
@@ -151,14 +236,18 @@ class PPTXSchemaValidator(BaseSchemaValidator):
151
236
  return found
152
237
 
153
238
  def validate_slides(self):
239
+ import lxml.etree
240
+
154
241
  from helpers.pptx_slide import (
155
242
  SLIDE_PART_RE,
156
243
  fatal_slide_errors,
157
244
  is_schema_verdict,
245
+ stranded_animation_targets,
158
246
  )
159
247
 
160
248
  schema = self.schemas_dir / self.SCHEMA_MAPPINGS["ppt"]
161
249
  inherited = self._original_slide_defects(schema)
250
+ listed = self._listed_slides()
162
251
  problems: list[str] = []
163
252
  broken: list[str] = []
164
253
 
@@ -166,6 +255,14 @@ class PPTXSchemaValidator(BaseSchemaValidator):
166
255
  relative = xml_file.relative_to(self.unpacked_dir).as_posix()
167
256
  if not SLIDE_PART_RE.fullmatch(relative):
168
257
  continue
258
+ unlisted = relative.startswith("ppt/slides/") and listed is not None and relative not in listed
259
+ try:
260
+ root = lxml.etree.parse(str(xml_file)).getroot()
261
+ stranded = [] if unlisted else stranded_animation_targets(root)
262
+ except lxml.etree.XMLSyntaxError:
263
+ stranded = []
264
+ problems.extend(f"{relative}: {m}" for m in stranded)
265
+
169
266
  ok, errors = self._validate_single_file_xsd(
170
267
  xml_file.resolve(), self.unpacked_dir.resolve(), schema_path=schema
171
268
  )
@@ -187,12 +284,12 @@ class PPTXSchemaValidator(BaseSchemaValidator):
187
284
  if broken:
188
285
  print(f"FAILED - Could not check {len(broken)} slide part(s):")
189
286
  for message in sorted(broken):
190
- print(f" {message[:240]}")
287
+ self._print_line(f" {message}", 240)
191
288
 
192
289
  if problems:
193
290
  print(f"FAILED - Found {len(problems)} slide problem(s) PowerPoint rejects:")
194
291
  for message in sorted(problems):
195
- print(f" {message[:240]}")
292
+ self._print_line(f" {message}", 240)
196
293
 
197
294
  if broken or problems:
198
295
  return False
@@ -204,6 +301,17 @@ class PPTXSchemaValidator(BaseSchemaValidator):
204
301
  def _get_schema_path(self, xml_file):
205
302
  if xml_file.parent.name == "charts" and xml_file.name.startswith("chart"):
206
303
  return None
304
+ if xml_file.parent.name == "ppt" and xml_file.suffix == ".xml":
305
+ import lxml.etree
306
+
307
+ try:
308
+ root = lxml.etree.parse(str(xml_file)).getroot()
309
+ except (lxml.etree.XMLSyntaxError, OSError):
310
+ root = None
311
+ if root is not None and (lxml.etree.QName(root).namespace or "").startswith(
312
+ "http://schemas.microsoft.com/office/"
313
+ ):
314
+ return None
207
315
  return super()._get_schema_path(xml_file)
208
316
 
209
317
  def _preprocess_for_schema(self, xml_doc, relative_path):
@@ -256,7 +364,7 @@ class PPTXSchemaValidator(BaseSchemaValidator):
256
364
  if errors:
257
365
  print(f"FAILED - Found {len(errors)} UUID ID validation errors:")
258
366
  for error in errors:
259
- print(error)
367
+ self._print_line(error, 300)
260
368
  return False
261
369
  else:
262
370
  if self.verbose:
@@ -325,7 +433,7 @@ class PPTXSchemaValidator(BaseSchemaValidator):
325
433
  if errors:
326
434
  print(f"FAILED - Found {len(errors)} slide layout ID validation errors:")
327
435
  for error in errors:
328
- print(error)
436
+ self._print_line(error, 300)
329
437
  print(
330
438
  "Remove invalid references or add missing slide layouts to the relationships file."
331
439
  )
@@ -366,7 +474,7 @@ class PPTXSchemaValidator(BaseSchemaValidator):
366
474
  if errors:
367
475
  print("FAILED - Found slides with duplicate slideLayout references:")
368
476
  for error in errors:
369
- print(error)
477
+ self._print_line(error, 300)
370
478
  return False
371
479
  else:
372
480
  if self.verbose:
@@ -428,7 +536,7 @@ class PPTXSchemaValidator(BaseSchemaValidator):
428
536
  f"FAILED - Found {len([e for e in errors if not e.startswith(' ')])} notes slide reference validation errors:"
429
537
  )
430
538
  for error in errors:
431
- print(error)
539
+ self._print_line(error, 300)
432
540
  print("Each slide may optionally have its own slide file.")
433
541
  return False
434
542
  else: