A slide carries a straight-line connector between two points, emitted as a <p:cxnSp> with preset geometry 'line'.
Library verdicts: python-pptx: — pptxjs: fail
| Feature id | pptx/shape-line |
|---|---|
| Format | pptx |
| Category | shapes |
| Spec | ecma-376-5-part-1 § 20.1.2.2.29 p:cxnSp |
| ID / part | Predicate | XPath | python-pptx | pptxjs |
|---|---|---|---|---|
line-connector-existsppt/slides/slide1.xml | existA <p:cxnSp> connector shape must exist on the slide. | //p:cxnSp | — | — |
line-connector-preset-geomppt/slides/slide1.xml | equal = lineThe <p:cxnSp> connector's preset geometry must be 'line'. | //p:cxnSp/p:spPr/a:prstGeom/@prst | — | — |
| ID | Predicate | Selector | python-pptx | pptxjs |
|---|---|---|---|---|
line-shape-visible | css_selector/ existA DOM node representing a horizontal line (hr, svg line, or a shape element annotated as a line) must be present. This is a weak check — accept a rendering gap as a signal rather than a hard failure. | hr, svg line, [data-shape='line'], [data-shape-preset='line'] | — | fail |
slide-count | css_selector/ equal-countExactly one slide container must be rendered. Catches renderers that emit zero slides (hard failure) or duplicate the slide. | section.pptx-slide, .pptx-slide, section[data-slide], .slide, [data-slide] | — | — |
scripts/gen_shape_line.py
#!/usr/bin/env python3
"""Generate ``fixtures/pptx/shape-line.pptx``.
A one-slide presentation carrying a straight-line connector between two
points. python-pptx emits this as a <p:cxnSp> with <a:prstGeom prst="line"/>.
Designed to satisfy the assertions in ``features/pptx/shape-line.json``.
"""
from __future__ import annotations
from pathlib import Path
from pptx import Presentation
from pptx.enum.shapes import MSO_CONNECTOR
from pptx.util import Inches
import datetime as _dt
_REPRODUCIBLE_DT = _dt.datetime(2000, 1, 1, 0, 0, 0)
_REPO_ROOT = Path(__file__).resolve().parent.parent
_OUT = _REPO_ROOT / "fixtures" / "pptx" / "shape-line.pptx"
def main() -> int:
prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[5])
slide.shapes.add_connector(
MSO_CONNECTOR.STRAIGHT, Inches(1), Inches(1), Inches(5), Inches(1)
)
_OUT.parent.mkdir(parents=True, exist_ok=True)
prs.save(_OUT, zip_date_time=_REPRODUCIBLE_DT)
print(_OUT)
return 0
if __name__ == "__main__":
raise SystemExit(main()){
"$schema": "../manifest.schema.json",
"id": "pptx/shape-line",
"title": "Straight-line connector shape",
"format": "pptx",
"category": "shapes",
"summary": "A slide carries a straight-line connector between two points, emitted as a <p:cxnSp> with preset geometry 'line'.",
"spec": {
"source": "ecma-376-5-part-1",
"clause": "20.1.2.2.29",
"element": "p:cxnSp",
"rnc_reference": "spec/ecma-376-5/part-1/rnc/PresentationML.rnc",
"xsd_reference": "spec/ecma-376-5/part-1/xsd/pml.xsd",
"notes": "python-pptx emits shapes.add_connector(MSO_CONNECTOR.STRAIGHT, ...) as a <p:cxnSp> whose <p:spPr>/<a:prstGeom> declares prst=\"line\". Unlike auto-shapes, connectors live under <p:cxnSp> rather than <p:sp>."
},
"fixtures": {
"machine": "pptx/shape-line",
"office": "pptx/shape-line"
},
"generator": {
"python": "scripts/gen_shape_line.py"
},
"assertions": [
{
"id": "line-connector-exists",
"part": "ppt/slides/slide1.xml",
"namespaces": {
"p": "http://schemas.openxmlformats.org/presentationml/2006/main",
"a": "http://schemas.openxmlformats.org/drawingml/2006/main"
},
"xpath": "//p:cxnSp",
"must": "exist",
"description": "A <p:cxnSp> connector shape must exist on the slide."
},
{
"id": "line-connector-preset-geom",
"part": "ppt/slides/slide1.xml",
"namespaces": {
"p": "http://schemas.openxmlformats.org/presentationml/2006/main",
"a": "http://schemas.openxmlformats.org/drawingml/2006/main"
},
"xpath": "//p:cxnSp/p:spPr/a:prstGeom/@prst",
"must": "equal",
"value": "line",
"description": "The <p:cxnSp> connector's preset geometry must be 'line'."
}
],
"render_assertions": [
{
"id": "line-shape-visible",
"kind": "css_selector",
"selector": "hr, svg line, [data-shape='line'], [data-shape-preset='line']",
"must": "exist",
"description": "A DOM node representing a horizontal line (hr, svg line, or a shape element annotated as a line) must be present. This is a weak check — accept a rendering gap as a signal rather than a hard failure."
},
{
"id": "slide-count",
"kind": "css_selector",
"selector": "section.pptx-slide, .pptx-slide, section[data-slide], .slide, [data-slide]",
"must": "equal-count",
"count": 1,
"description": "Exactly one slide container must be rendered. Catches renderers that emit zero slides (hard failure) or duplicate the slide."
}
]
}
