Three consecutive paragraphs styled with the built-in List Bullet style to form an unordered list.
Library verdicts: python-docx: — docxjs: pass
| Feature id | docx/bulleted-list |
|---|---|
| Format | docx |
| Category | lists |
| Spec | ecma-376-5-part-1 § 17.3.1.19 w:numPr |
| ID / part | Predicate | XPath | python-docx | docxjs |
|---|---|---|---|---|
bulleted-list-item-one-presentword/document.xml | existThe first bullet paragraph must carry pStyle='ListBullet' and contain the fixture text 'Bullet item one'. | //w:p[w:pPr/w:pStyle[@w:val='ListBullet']][w:r/w:t[normalize-space()='Bullet item one']] | — | — |
bulleted-list-item-two-presentword/document.xml | existThe second bullet paragraph must carry pStyle='ListBullet' and contain the fixture text 'Bullet item two'. | //w:p[w:pPr/w:pStyle[@w:val='ListBullet']][w:r/w:t[normalize-space()='Bullet item two']] | — | — |
bulleted-list-item-three-presentword/document.xml | existThe third bullet paragraph must carry pStyle='ListBullet' and contain the fixture text 'Bullet item three'. | //w:p[w:pPr/w:pStyle[@w:val='ListBullet']][w:r/w:t[normalize-space()='Bullet item three']] | — | — |
bulleted-list-item-countword/document.xml | match = ^3(\.0)?$Exactly three paragraphs must use the ListBullet style. | count(//w:p[w:pPr/w:pStyle[@w:val='ListBullet']]) | — | — |
| ID | Predicate | Selector | python-docx | docxjs |
|---|---|---|---|---|
bulleted-list-item-one-rendered | css_selector/ match-text = Bullet item oneA list-item DOM node (ul > li, or a paragraph carrying the List Bullet style) must contain the first fixture item. Falls back to any paragraph since renderer conventions vary. | .docx-wrapper ul li, .docx-wrapper [data-style='List Bullet'], .docx-wrapper [class*='list-bullet'], .docx-wrapper [class*='ListBullet'], .docx-wrapper p | — | pass |
bulleted-list-item-count | css_selector/ equal-countExactly three list-item DOM nodes must be rendered — one per fixture bullet. Catches phantom or dropped items the match-text assertion can't see. Includes docxjs's `p.docx-num-<id>-<lvl>` list-item markup in the selector fallback chain. | .docx-wrapper ul li, .docx-wrapper [data-style='List Bullet'], .docx-wrapper [class*='list-bullet'], .docx-wrapper [class*='ListBullet'], .docx-wrapper p[class*='-num-'] | — | — |
bulleted-list-item-two-rendered | css_selector/ match-text = Bullet item twoThe second list-item must contain 'Bullet item two'. Catches renderers that repeat item-one content across siblings (content leak between <li> nodes). | .docx-wrapper ul li:nth-of-type(2), .docx-wrapper [data-style='List Bullet']:nth-of-type(2), .docx-wrapper [class*='ListBullet']:nth-of-type(2), .docx-wrapper p:nth-of-type(2) | — | — |
bulleted-list-item-three-rendered | css_selector/ match-text = Bullet item threeThe third list-item must contain 'Bullet item three'. Catches content leaks and dropped-sibling bugs. | .docx-wrapper ul li:nth-of-type(3), .docx-wrapper [data-style='List Bullet']:nth-of-type(3), .docx-wrapper [class*='ListBullet']:nth-of-type(3), .docx-wrapper p:nth-of-type(3) | — | — |
scripts/gen_bulleted_list.py
#!/usr/bin/env python3
"""Generate ``fixtures/docx/bulleted-list.docx``.
A minimal document exercising the built-in ``List Bullet`` paragraph
style. Three consecutive paragraphs form an unordered list. Designed
to satisfy the assertions in ``features/docx/bulleted-list.json``.
"""
from __future__ import annotations
from pathlib import Path
from docx import Document
_REPO_ROOT = Path(__file__).resolve().parent.parent
_OUT = _REPO_ROOT / "fixtures" / "docx" / "bulleted-list.docx"
def main() -> int:
doc = Document()
doc.add_paragraph("Bullet item one", style="List Bullet")
doc.add_paragraph("Bullet item two", style="List Bullet")
doc.add_paragraph("Bullet item three", style="List Bullet")
_OUT.parent.mkdir(parents=True, exist_ok=True)
doc.save(_OUT, reproducible=True)
print(_OUT)
return 0
if __name__ == "__main__":
raise SystemExit(main())
{
"$schema": "../manifest.schema.json",
"id": "docx/bulleted-list",
"title": "Bulleted list",
"format": "docx",
"category": "lists",
"summary": "Three consecutive paragraphs styled with the built-in List Bullet style to form an unordered list.",
"spec": {
"source": "ecma-376-5-part-1",
"clause": "17.3.1.19",
"element": "w:numPr",
"rnc_reference": "spec/ecma-376-5/part-1/rnc/WordprocessingML.rnc",
"xsd_reference": "spec/ecma-376-5/part-1/xsd/wml.xsd",
"notes": "List membership is expressed via the paragraph's pStyle pointing at a list style (e.g. 'ListBullet') or directly via <w:pPr><w:numPr><w:numId w:val='n'/><w:ilvl w:val='0'/></w:numPr></w:pPr>. Word collapses whitespace in style names, so the 'List Bullet' built-in style appears as pStyle w:val='ListBullet' in the XML, not 'List Bullet'."
},
"fixtures": {
"machine": "docx/bulleted-list",
"office": "docx/bulleted-list"
},
"generator": {
"python": "scripts/gen_bulleted_list.py"
},
"assertions": [
{
"id": "bulleted-list-item-one-present",
"part": "word/document.xml",
"namespaces": {
"w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
},
"xpath": "//w:p[w:pPr/w:pStyle[@w:val='ListBullet']][w:r/w:t[normalize-space()='Bullet item one']]",
"must": "exist",
"description": "The first bullet paragraph must carry pStyle='ListBullet' and contain the fixture text 'Bullet item one'."
},
{
"id": "bulleted-list-item-two-present",
"part": "word/document.xml",
"namespaces": {
"w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
},
"xpath": "//w:p[w:pPr/w:pStyle[@w:val='ListBullet']][w:r/w:t[normalize-space()='Bullet item two']]",
"must": "exist",
"description": "The second bullet paragraph must carry pStyle='ListBullet' and contain the fixture text 'Bullet item two'."
},
{
"id": "bulleted-list-item-three-present",
"part": "word/document.xml",
"namespaces": {
"w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
},
"xpath": "//w:p[w:pPr/w:pStyle[@w:val='ListBullet']][w:r/w:t[normalize-space()='Bullet item three']]",
"must": "exist",
"description": "The third bullet paragraph must carry pStyle='ListBullet' and contain the fixture text 'Bullet item three'."
},
{
"id": "bulleted-list-item-count",
"part": "word/document.xml",
"namespaces": {
"w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
},
"xpath": "count(//w:p[w:pPr/w:pStyle[@w:val='ListBullet']])",
"must": "match",
"value": "^3(\\.0)?$",
"description": "Exactly three paragraphs must use the ListBullet style."
}
],
"render_assertions": [
{
"id": "bulleted-list-item-one-rendered",
"kind": "css_selector",
"selector": ".docx-wrapper ul li, .docx-wrapper [data-style='List Bullet'], .docx-wrapper [class*='list-bullet'], .docx-wrapper [class*='ListBullet'], .docx-wrapper p",
"must": "match-text",
"value": "Bullet item one",
"description": "A list-item DOM node (ul > li, or a paragraph carrying the List Bullet style) must contain the first fixture item. Falls back to any paragraph since renderer conventions vary."
},
{
"id": "bulleted-list-item-count",
"kind": "css_selector",
"selector": ".docx-wrapper ul li, .docx-wrapper [data-style='List Bullet'], .docx-wrapper [class*='list-bullet'], .docx-wrapper [class*='ListBullet'], .docx-wrapper p[class*='-num-']",
"must": "equal-count",
"count": 3,
"description": "Exactly three list-item DOM nodes must be rendered — one per fixture bullet. Catches phantom or dropped items the match-text assertion can't see. Includes docxjs's `p.docx-num-<id>-<lvl>` list-item markup in the selector fallback chain."
},
{
"id": "bulleted-list-item-two-rendered",
"kind": "css_selector",
"selector": ".docx-wrapper ul li:nth-of-type(2), .docx-wrapper [data-style='List Bullet']:nth-of-type(2), .docx-wrapper [class*='ListBullet']:nth-of-type(2), .docx-wrapper p:nth-of-type(2)",
"must": "match-text",
"value": "Bullet item two",
"description": "The second list-item must contain 'Bullet item two'. Catches renderers that repeat item-one content across siblings (content leak between <li> nodes)."
},
{
"id": "bulleted-list-item-three-rendered",
"kind": "css_selector",
"selector": ".docx-wrapper ul li:nth-of-type(3), .docx-wrapper [data-style='List Bullet']:nth-of-type(3), .docx-wrapper [class*='ListBullet']:nth-of-type(3), .docx-wrapper p:nth-of-type(3)",
"must": "match-text",
"value": "Bullet item three",
"description": "The third list-item must contain 'Bullet item three'. Catches content leaks and dropped-sibling bugs."
}
]
}
