Add layout inspection and mutation commands#1
Merged
Merged
Conversation
Extract PrepareMutation to output.go — validates input file and prompts before overwriting an existing output file. All mutation commands now call this instead of doing it inline (colors.go updated accordingly). Add layoutFiltersFromCommand and resetLayoutFlags to layouts.go so the list command reads flags through cobra rather than global vars, and resets them after each execution to prevent filter leakage between repeated calls in the same process. Fix normalizeThemeFilter to trim whitespace and skip empty entries. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Removes p:sldLayout/@matchingName from slide layouts using the encoding/xml Decoder.InputOffset algorithm: locates the exact byte range of the sldLayout start tag by namespace URI, applies a scoped regex to that slice only, leaves the rest of the file byte-identical. Supports the same --layout-id, --name, --matching-name, and --theme filters as layout list. Without filters, removes from all layouts that have the attribute set. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
This PR adds the new
layoutcommand group topptx-toolkitfor inspecting and mutating slide layout naming metadata in PPTX files.It covers the full layout-name workflow we researched:
layout listlayout remove matching-namelayout setThe implementation is based on the OOXML distinction between:
p:cSld/@namep:sldLayout/@matchingNameWhat’s Included
New commands
layout listLists slide layouts and shows:
Layout IDNameMatching NameMasterThemeUsed By SlidesSupports filters:
--layout-id--name--matching-name--themelayout remove matching-nameRemoves
p:sldLayout/@matchingNamefrom all matched layouts.Supports the same filters as
layout list.layout setApplies directional property assignment across all matched layouts:
Supported source forms:
@name@matching-nameSupported target properties:
namematching-nameExamples:
Design Notes
Filter model
Layout mutation commands operate on the set of matched layouts.
setsyntaxThe
layout setparser uses:@on the source side to indicate property referenceThis avoids ambiguity between:
namenameProperty-to-same-property validation
These forms are rejected early:
with a clear error, because they would be no-op self-copies.
OOXML-safe mutation strategy
The mutation code does not reserialize full XML documents.
Instead it:
encoding/xml.Decoderonly to locate exact start-tag byte rangesThis avoids OOXML namespace-prefix corruption while still being structured enough to safely target:
<p:sldLayout ...><p:cSld ...>Test Fixture
cmd/pptx-toolkit/testdata/test.pptxalready contains a dedicated divergent-name layout:slideLayout12.xmlp:cSld/@name = "matchName-test"p:sldLayout/@matchingName = "Layout with matchName property"This fixture is now used for layout inspection and mutation coverage.
Tests
Added/expanded tests for:
layout setmapping parsermatchingNameremoval--layout-idRefactors / shared behavior
PromptOverwritenow reads fromcmd.InOrStdin()instead of global stdin, making it test-safeDocumentation
Updated:
README.md.llm/layouts-matching-names.mdto document:
layout listlayout removelayout setValidation
Ran:
go test ./cmd/pptx-toolkit -count=1and the package test suite passes.