pptx/shape-line

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

Metadata

Feature idpptx/shape-line
Formatpptx
Categoryshapes
Spececma-376-5-part-1 § 20.1.2.2.29 p:cxnSp

XPath assertions

ID / partPredicateXPathpython-pptxpptxjs
line-connector-exists
ppt/slides/slide1.xml
exist
A <p:cxnSp> connector shape must exist on the slide.
//p:cxnSp
line-connector-preset-geom
ppt/slides/slide1.xml
equal = line
The <p:cxnSp> connector's preset geometry must be 'line'.
//p:cxnSp/p:spPr/a:prstGeom/@prst

Render assertions

IDPredicateSelectorpython-pptxpptxjs
line-shape-visiblecss_selector/ exist
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.
hr, svg line, [data-shape='line'], [data-shape-preset='line']fail
slide-countcss_selector/ equal-count
Exactly 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]

Generator source

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())

Manifest (expanded)

{
  "$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."
    }
  ]
}

Fixture

Download shape-line.pptx (27.6 KB)

Reference preview

Reference (machine, page 1 PNG)

pptx/shape-line page 1 reference

Reference PDF


Download PDF Open in PDF.js

Spec 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>.