A free-standing text box shape carries a rectangular preset geometry and a single text paragraph.
Library verdicts: python-pptx: — pptxjs: fail
| Feature id | pptx/textbox-plain |
|---|---|
| Format | pptx |
| Category | shapes |
| Spec | ecma-376-5-part-1 § 19.3.1.49 p:sp |
| ID / part | Predicate | XPath | python-pptx | pptxjs |
|---|---|---|---|---|
textbox-preset-geom-rectppt/slides/slide1.xml | equal = rectThe shape carrying the 'Plain text box' text must declare <a:prstGeom prst="rect"/> — python-pptx's default preset geometry for text boxes. | //p:sp[.//a:t[normalize-space()='Plain text box']]/p:spPr/a:prstGeom/@prst | — | — |
textbox-text-presentppt/slides/slide1.xml | existA <p:sp> must contain an <a:t> run whose value is 'Plain text box'. | //p:sp//a:t[normalize-space()='Plain text box'] | — | — |
| ID | Predicate | Selector | python-pptx | pptxjs |
|---|---|---|---|---|
textbox-text-visible | css_selector/ match-text = Plain text boxA DOM node annotated as a text box (via data-shape-type / .pptx-textbox / data-kind='sp') or a generic slide paragraph must carry the 'Plain text box' text. | [data-shape-type='textbox'], .pptx-textbox, [data-kind='sp'], section[data-slide] p, section.slide p | — | 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_textbox_plain.py
#!/usr/bin/env python3
"""Generate ``fixtures/pptx/textbox-plain.pptx``.
A one-slide presentation carrying a free-standing text box shape whose
preset geometry is ``prst="rect"`` — python-pptx's default for
``shapes.add_textbox()``. Designed to satisfy the assertions in
``features/pptx/textbox-plain.json``.
"""
from __future__ import annotations
from pathlib import Path
from pptx import Presentation
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" / "textbox-plain.pptx"
def main() -> int:
prs = Presentation()
# slide_layouts[6] is the blank layout — no placeholders — so the
# only shape on the slide is the text box we add.
slide = prs.slides.add_slide(prs.slide_layouts[6])
tb = slide.shapes.add_textbox(Inches(1), Inches(1), Inches(4), Inches(1))
tb.text_frame.text = "Plain text box"
_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/textbox-plain",
"title": "Plain text box shape",
"format": "pptx",
"category": "shapes",
"summary": "A free-standing text box shape carries a rectangular preset geometry and a single text paragraph.",
"spec": {
"source": "ecma-376-5-part-1",
"clause": "19.3.1.49",
"element": "p:sp",
"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_textbox() as a <p:sp> whose <p:cNvSpPr> carries txBox=\"1\" and whose <p:spPr>/<a:prstGeom> declares prst=\"rect\". The text lives in the shape's <p:txBody>."
},
"fixtures": {
"machine": "pptx/textbox-plain",
"office": "pptx/textbox-plain"
},
"generator": {
"python": "scripts/gen_textbox_plain.py"
},
"assertions": [
{
"id": "textbox-preset-geom-rect",
"part": "ppt/slides/slide1.xml",
"namespaces": {
"p": "http://schemas.openxmlformats.org/presentationml/2006/main",
"a": "http://schemas.openxmlformats.org/drawingml/2006/main"
},
"xpath": "//p:sp[.//a:t[normalize-space()='Plain text box']]/p:spPr/a:prstGeom/@prst",
"must": "equal",
"value": "rect",
"description": "The shape carrying the 'Plain text box' text must declare <a:prstGeom prst=\"rect\"/> — python-pptx's default preset geometry for text boxes."
},
{
"id": "textbox-text-present",
"part": "ppt/slides/slide1.xml",
"namespaces": {
"p": "http://schemas.openxmlformats.org/presentationml/2006/main",
"a": "http://schemas.openxmlformats.org/drawingml/2006/main"
},
"xpath": "//p:sp//a:t[normalize-space()='Plain text box']",
"must": "exist",
"description": "A <p:sp> must contain an <a:t> run whose value is 'Plain text box'."
}
],
"render_assertions": [
{
"id": "textbox-text-visible",
"kind": "css_selector",
"selector": "[data-shape-type='textbox'], .pptx-textbox, [data-kind='sp'], section[data-slide] p, section.slide p",
"must": "match-text",
"value": "Plain text box",
"description": "A DOM node annotated as a text box (via data-shape-type / .pptx-textbox / data-kind='sp') or a generic slide paragraph must carry the 'Plain text box' text."
},
{
"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."
}
]
}
