Add template doctor workflow to analyze and repair real-world PowerPoint templates#132
Merged
jongalloway merged 3 commits intomainfrom Mar 15, 2026
Merged
Conversation
Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
jongalloway
March 14, 2026 23:36
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a “template doctor” capability to MarpToPptx for inspecting PPTX templates for structural issues that affect rendering, optionally applying safe fix-ups, and exposing the feature via the TemplateDiagnostics CLI.
Changes:
- Introduce
TemplateDoctor+ report/issue models to analyze templates and optionally materialize placeholder geometry from slide masters. - Extend
MarpToPptx.TemplateDiagnosticsinto a subcommand-based CLI (diagnose+doctor) with human-readable and JSON output modes. - Add xUnit tests covering doctor reports, issue shapes, and write-vs-dry-run behavior; update template usage documentation.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/MarpToPptx.Tests/TemplateDoctorTests.cs | Adds coverage for TemplateDoctor report shape and write/dry-run behaviors. |
| src/MarpToPptx.TemplateDiagnostics/Program.cs | Adds diagnose/doctor subcommands and reporting output (text/JSON). |
| src/MarpToPptx.Pptx/Diagnostics/TemplateDoctorReport.cs | Defines the top-level TemplateDoctor report contract. |
| src/MarpToPptx.Pptx/Diagnostics/TemplateDoctorIssue.cs | Defines per-issue records (severity/code/description/proposed fix). |
| src/MarpToPptx.Pptx/Diagnostics/TemplateDoctor.cs | Implements template analysis and optional fix-up application. |
| src/MarpToPptx.Pptx/Diagnostics/IssueSeverity.cs | Introduces severity enum for doctor issues. |
| doc/using-templates.md | Documents how to run diagnostics/doctor and explains issue codes. |
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+472
to
+485
| // For typed placeholders, match by type. | ||
| if (placeholder.Type is { } phType) | ||
| { | ||
| if (masterTypes.Any(t => ph.Type?.Value == t)) | ||
| { | ||
| return shape; | ||
| } | ||
|
|
||
| continue; | ||
| } | ||
|
|
||
| // For typeless placeholders, look for body/content type on master. | ||
| if (masterTypes.Any(t => ph.Type?.Value == t) || ph.Type?.Value is null) | ||
| { |
Comment on lines
+141
to
+152
| var layout = layouts[i].SlideLayout; | ||
| var hasMatchingName = layout?.MatchingName?.Value is { Length: > 0 }; | ||
| var hasCsdName = layout?.CommonSlideData?.Name?.Value is { Length: > 0 }; | ||
|
|
||
| if (!hasMatchingName && !hasCsdName) | ||
| { | ||
| issues.Add(new TemplateDoctorIssue( | ||
| LayoutName: null, | ||
| Severity: IssueSeverity.Warning, | ||
| Code: "EmptyLayoutName", | ||
| Description: $"Layout at position {i + 1} has no name and will be referenced as \"Layout {i + 1}\". " + | ||
| "Unnamed layouts are hard to target by name in Markdown directives.")); |
Comment on lines
+103
to
+109
| // There should be no such issue on the built-in content layout (which has a body). | ||
| foreach (var issue in missingBodyIssues) | ||
| { | ||
| // If any are reported, they must not be for the content layout. | ||
| Assert.NotEqual("Title and Content", issue.LayoutName, | ||
| StringComparer.OrdinalIgnoreCase); | ||
| } |
| /// </summary> | ||
| /// <param name="TemplatePath">Path of the template that was inspected.</param> | ||
| /// <param name="Issues"> | ||
| /// All structural issues and observations found, ordered by severity then by layout order. |
| default: | ||
| if (arg.StartsWith('-')) | ||
| { | ||
| Console.Error.WriteLine($"Unknown option '{arg}'. Run 'doctor --help' for usage."); |
Owner
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
Contributor
Author
Applied all 5 review items in fd1d79f:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #86.
Summary
Adds a
template doctorworkflow that goes beyond diagnostics to identify and optionally repair structural issues in real-world PPTX templates that degrade MarpToPptx output.What's new
New types in
MarpToPptx.Pptx/Diagnostics/IssueSeverityInfo/Warning/FixableTemplateDoctorIssueTemplateDoctorReportTemplateDoctorChecks implemented
DuplicateLayoutNameEmptyLayoutNameContentLayoutMissingTitlePlaceholderContentLayoutMissingBodyPlaceholderPlaceholderGeometryInheritedTypelessIndexedBodyPlaceholderUnmappableLayoutRoleVisuallyRedundantLayoutsSafe write-back
When
--write-fixed-template <path>is supplied the doctor:MarpToPptx.TemplateDiagnosticsCLI extendedNow supports two subcommands (backward-compatible — a bare path still runs
diagnose):Tests
12 new tests in
TemplateDoctorTests.cscovering:PresentationDocumentAll 339 tests pass (327 pre-existing + 12 new).
Documentation
doc/using-templates.mdupdated with:diagnoseusage and invocationtemplate doctorsection with issue-code reference table and example CLI invocations for all three modes (dry-run, write, JSON)Security
CodeQL: 0 alerts.