Add configurable slides path and malformed marker detection

- project.json now supports "slides" field pointing to slides.json location
- Slide images are loaded from same directory as slides.json
- Validation detects malformed markers (missing ], extra spaces)
- Reports line numbers for each malformed marker

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-12 11:49:46 +01:00
co-authored by Claude Opus 4.5
parent b347841634
commit 7f7425da46
6 changed files with 65 additions and 20 deletions
+16 -4
View File
@@ -12,6 +12,7 @@ def validate_project(
config: ProjectConfig,
slides: dict[str, SlideDefinition],
videos: dict[str, VideoSource],
malformed_markers: list[tuple[int, str]] = None,
) -> None:
"""
Validate all parsed project data. Raises ValidationError if any issues found.
@@ -22,9 +23,19 @@ def validate_project(
- All video files exist on disk
- Background video exists (if specified)
- Slide types are valid
- No malformed markers in manuscript
"""
issues: list[ValidationIssue] = []
# Check for malformed markers first (these are likely typos)
if malformed_markers:
for line_num, marker_text in malformed_markers:
issues.append(ValidationIssue(
f"Malformed marker: {marker_text}",
project_path / "manuscript.txt",
line_num
))
# Check all manuscript markers have corresponding slides
for marker in manuscript_markers:
if marker not in slides:
@@ -34,15 +45,16 @@ def validate_project(
))
# Check all slide images exist
media_path = project_path / "media"
slides_path = media_path / "slides"
# Slides are in the same directory as the slides.json file
slides_json_path = project_path / config.slides_path
slides_dir = slides_json_path.parent
for slide_id, slide_def in slides.items():
image_path = slides_path / slide_def.image
image_path = slides_dir / slide_def.image
if not image_path.exists():
issues.append(ValidationIssue(
f"Slide image not found: {slide_def.image}",
project_path / "slides.json"
slides_json_path
))
# Check slide type is valid