A slide references a slide-layout part via a r:slideLayout relationship. PowerPoint's default template ships eleven standard layouts (Title, Title+Content, Section Header, Two Content, Comparison, Title Only, Blank, Content+Caption, Picture+Caption, Title+Vertical Text, Vertical Title+Text).
Library verdicts: python-pptx: — pptxjs: —
| Feature id | pptx/slide-layout--title-only |
|---|---|
| Format | pptx |
| Category | slide-layout |
| Family | pptx/slide-layout |
| Axis values | layout=title-only |
| Spec | ecma-376-5-part-1 § 19.3.1.15 sldLayout |
| ID / part | Predicate | XPath | python-pptx | pptxjs |
|---|---|---|---|---|
slide-has-layout-rel-title-onlyppt/slides/_rels/slide1.xml.rels | match = ^1(\.0)?$slide1 must carry exactly one slideLayout relationship. | count(//*[local-name()='Relationship'][@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout']) | — | — |
layout-ref-from-slide-title-onlyppt/slides/_rels/slide1.xml.rels | match = slideLayout\d+\.xml$The slideLayout relationship target must point at a slideLayoutN.xml part; the exact N depends on theme ordering, not on the axis idx. | //*[local-name()='Relationship'][@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout']/@Target | — | — |
No render assertions declared.
scripts/gen_slide_layout.py
#!/usr/bin/env python3
"""Generate a ``fixtures/pptx/slide-layout--<id>.pptx`` fixture.
Parameterised generator for the ``pptx/slide-layout`` manifest family.
python-pptx's default template ships eleven standard slide layouts
(idx 0-10); this generator adds a single slide based on the layout
at the requested index, sets the title placeholder text when one is
present, and writes the result to ``--out``.
The ``features/pptx/slide-layout.json`` manifest's
``generator.arg_template`` field drives these args at expansion time.
"""
from __future__ import annotations
import argparse
import datetime as _dt
from pathlib import Path
from pptx import Presentation
_REPRODUCIBLE_DT = _dt.datetime(2000, 1, 1, 0, 0, 0)
_REPO_ROOT = Path(__file__).resolve().parent.parent
def _write(layout_idx: int, out: Path) -> None:
prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[layout_idx])
# Not every layout has a title placeholder (e.g. Blank). Set it
# where present so visual renders have at least one text anchor.
if slide.shapes.title is not None:
slide.shapes.title.text = f"Layout idx {layout_idx}"
out.parent.mkdir(parents=True, exist_ok=True)
prs.save(out, zip_date_time=_REPRODUCIBLE_DT)
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
"--layout-idx",
type=int,
default=0,
help="Slide layout index in the default template (0-10).",
)
parser.add_argument(
"--out",
default=str(_REPO_ROOT / "fixtures" / "pptx" / "slide-layout.pptx"),
)
args = parser.parse_args()
out_path = Path(args.out)
if not out_path.is_absolute():
out_path = _REPO_ROOT / out_path
_write(args.layout_idx, out_path)
print(out_path)
return 0
if __name__ == "__main__":
raise SystemExit(main())
{
"$schema": "../manifest.schema.json",
"id": "pptx/slide-layout--title-only",
"kind": "literal",
"title": "Slide layout",
"format": "pptx",
"category": "slide-layout",
"summary": "A slide references a slide-layout part via a r:slideLayout relationship. PowerPoint's default template ships eleven standard layouts (Title, Title+Content, Section Header, Two Content, Comparison, Title Only, Blank, Content+Caption, Picture+Caption, Title+Vertical Text, Vertical Title+Text).",
"spec": {
"source": "ecma-376-5-part-1",
"clause": "19.3.1.15",
"element": "sldLayout",
"rnc_reference": "spec/ecma-376-5/part-1/rnc/PresentationML.rnc",
"xsd_reference": "spec/ecma-376-5/part-1/xsd/pml.xsd",
"notes": "Each slide part carries exactly one slideLayout relationship pointing at its parent layout. The default presentation template in python-pptx ships 11 standard layouts at indices 0-10 that map to slideLayout1.xml ... slideLayout11.xml; however the target filename depends on the layout ordering inside the theme and should not be asserted on. This manifest is a parameterised family: one manifest expands into eleven concrete cases, one per standard layout. Each expanded case targets a distinct fixture pptx/slide-layout--<id>.pptx generated from gen_slide_layout.py parameterised by --layout-idx."
},
"fixtures": {
"machine": "pptx/slide-layout--title-only"
},
"generator": {
"python": "scripts/gen_slide_layout.py",
"arg_template": "--layout-idx {layout.idx} --out fixtures/pptx/slide-layout--{layout.id}.pptx"
},
"_expansion": {
"parent_id": "pptx/slide-layout",
"bindings": {
"layout": "title-only"
}
},
"assertions": [
{
"id": "slide-has-layout-rel-title-only",
"part": "ppt/slides/_rels/slide1.xml.rels",
"namespaces": {
"r": "http://schemas.openxmlformats.org/package/2006/relationships"
},
"xpath": "count(//*[local-name()='Relationship'][@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout'])",
"must": "match",
"value": "^1(\\.0)?$",
"description": "slide1 must carry exactly one slideLayout relationship."
},
{
"id": "layout-ref-from-slide-title-only",
"part": "ppt/slides/_rels/slide1.xml.rels",
"namespaces": {
"r": "http://schemas.openxmlformats.org/package/2006/relationships"
},
"xpath": "//*[local-name()='Relationship'][@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout']/@Target",
"must": "match",
"value": "slideLayout\\d+\\.xml$",
"description": "The slideLayout relationship target must point at a slideLayoutN.xml part; the exact N depends on theme ordering, not on the axis idx."
}
]
}
